@@ -79,7 +79,66 @@ t.test('basic publish', async t => {
79
79
t . ok ( ret , 'publish succeeded' )
80
80
} )
81
81
82
- t . test ( 'scoped publish' , async t => {
82
+ t . test ( 'scoped publish - default access' , async t => {
83
+ const manifest = {
84
+ name : '@claudiahdz/libnpmpublish' ,
85
+ version : '1.0.0' ,
86
+ description : 'some stuff' ,
87
+ }
88
+
89
+ const tarData = await pack ( `file:${ testDir } ` , { ...OPTS } )
90
+ const shasum = crypto . createHash ( 'sha1' ) . update ( tarData ) . digest ( 'hex' )
91
+ const integrity = ssri . fromData ( tarData , { algorithms : [ 'sha512' ] } )
92
+ const packument = {
93
+ _id : '@claudiahdz/libnpmpublish' ,
94
+ name : '@claudiahdz/libnpmpublish' ,
95
+ description : 'some stuff' ,
96
+ 'dist-tags' : {
97
+ latest : '1.0.0' ,
98
+ } ,
99
+ versions : {
100
+ '1.0.0' : {
101
+ _id : '@claudiahdz/libnpmpublish@1.0.0' ,
102
+ _nodeVersion : process . versions . node ,
103
+ _npmVersion : '6.13.7' ,
104
+ name : '@claudiahdz/libnpmpublish' ,
105
+ version : '1.0.0' ,
106
+ description : 'some stuff' ,
107
+ dist : {
108
+ shasum,
109
+ integrity : integrity . toString ( ) ,
110
+ tarball : 'http://mock.reg/@claudiahdz/libnpmpublish/'
111
+ + '-/@claudiahdz/libnpmpublish-1.0.0.tgz' ,
112
+ } ,
113
+ } ,
114
+ } ,
115
+ access : 'public' ,
116
+ _attachments : {
117
+ '@claudiahdz/libnpmpublish-1.0.0.tgz' : {
118
+ content_type : 'application/octet-stream' ,
119
+ data : tarData . toString ( 'base64' ) ,
120
+ length : tarData . length ,
121
+ } ,
122
+ } ,
123
+ }
124
+
125
+ const srv = tnock ( t , REG )
126
+ srv . put ( '/@claudiahdz%2flibnpmpublish' , body => {
127
+ t . same ( body , packument , 'posted packument matches expectations' )
128
+ return true
129
+ } , {
130
+ authorization : 'Bearer deadbeef' ,
131
+ } ) . reply ( 201 , { } )
132
+
133
+ const ret = await publish ( manifest , tarData , {
134
+ ...OPTS ,
135
+ npmVersion : '6.13.7' ,
136
+ token : 'deadbeef' ,
137
+ } )
138
+ t . ok ( ret , 'publish succeeded' )
139
+ } )
140
+
141
+ t . test ( 'scoped publish - restricted access' , async t => {
83
142
const manifest = {
84
143
name : '@claudiahdz/libnpmpublish' ,
85
144
version : '1.0.0' ,
@@ -132,6 +191,7 @@ t.test('scoped publish', async t => {
132
191
133
192
const ret = await publish ( manifest , tarData , {
134
193
...OPTS ,
194
+ access : 'restricted' ,
135
195
npmVersion : '6.13.7' ,
136
196
token : 'deadbeef' ,
137
197
} )
0 commit comments