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