@@ -28,7 +28,6 @@ t.cleanSnapshot = data => {
2828t . test ( 'respects publishConfig.registry, runs appropriate scripts' , async t => {
2929 const { npm, joinedOutput, prefix } = await loadMockNpm ( t , {
3030 config : {
31- loglevel : 'silent' , // prevent scripts from leaking to stdout during the test
3231 [ `${ alternateRegistry . slice ( 6 ) } /:_authToken` ] : 'test-other-token' ,
3332 } ,
3433 prefixDir : {
@@ -730,3 +729,65 @@ t.test('scoped _auth config scoped registry', async t => {
730729 await npm . exec ( 'publish' , [ ] )
731730 t . matchSnapshot ( joinedOutput ( ) , 'new package version' )
732731} )
732+
733+ t . test ( 'restricted access' , async t => {
734+ const spec = npa ( '@npm/test-package' )
735+ const { npm, joinedOutput, logs } = await loadMockNpm ( t , {
736+ config : {
737+ ...auth ,
738+ access : 'restricted' ,
739+ } ,
740+ prefixDir : {
741+ 'package.json' : JSON . stringify ( {
742+ name : '@npm/test-package' ,
743+ version : '1.0.0' ,
744+ } , null , 2 ) ,
745+ } ,
746+ globals : ( { prefix } ) => ( {
747+ 'process.cwd' : ( ) => prefix ,
748+ } ) ,
749+ } )
750+ const registry = new MockRegistry ( {
751+ tap : t ,
752+ registry : npm . config . get ( 'registry' ) ,
753+ authorization : token ,
754+ } )
755+ registry . nock . put ( `/${ spec . escapedName } ` , body => {
756+ t . equal ( body . access , 'restricted' , 'access is explicitly set to restricted' )
757+ return true
758+ } ) . reply ( 200 , { } )
759+ await npm . exec ( 'publish' , [ ] )
760+ t . matchSnapshot ( joinedOutput ( ) , 'new package version' )
761+ t . matchSnapshot ( logs . notice )
762+ } )
763+
764+ t . test ( 'public access' , async t => {
765+ const spec = npa ( '@npm/test-package' )
766+ const { npm, joinedOutput, logs } = await loadMockNpm ( t , {
767+ config : {
768+ ...auth ,
769+ access : 'public' ,
770+ } ,
771+ prefixDir : {
772+ 'package.json' : JSON . stringify ( {
773+ name : '@npm/test-package' ,
774+ version : '1.0.0' ,
775+ } , null , 2 ) ,
776+ } ,
777+ globals : ( { prefix } ) => ( {
778+ 'process.cwd' : ( ) => prefix ,
779+ } ) ,
780+ } )
781+ const registry = new MockRegistry ( {
782+ tap : t ,
783+ registry : npm . config . get ( 'registry' ) ,
784+ authorization : token ,
785+ } )
786+ registry . nock . put ( `/${ spec . escapedName } ` , body => {
787+ t . equal ( body . access , 'public' , 'access is explicitly set to public' )
788+ return true
789+ } ) . reply ( 200 , { } )
790+ await npm . exec ( 'publish' , [ ] )
791+ t . matchSnapshot ( joinedOutput ( ) , 'new package version' )
792+ t . matchSnapshot ( logs . notice )
793+ } )
0 commit comments