@@ -24,33 +24,29 @@ const s3Client = new S3Client({
24
24
forcePathStyle : true ,
25
25
} ) ;
26
26
27
- async function deleteS3Object ( s3Client : S3Client , bucketName : string , keysToDelete : Array < string > ) {
28
- if ( keysToDelete . length ) {
29
- const deleteObjectsCommand = new DeleteObjectsCommand ( {
30
- Bucket : bucketName ,
31
- Delete : { Objects : keysToDelete . map ( key => ( { Key : key } ) ) } ,
32
- } ) ;
33
-
34
- await s3Client . send ( deleteObjectsCommand ) ;
35
- }
36
- }
37
-
38
27
async function deleteAllS3BucketObjects ( s3Client : S3Client , bucketName : string ) {
39
28
const listObjectsCommand = new ListObjectsCommand ( {
40
29
Bucket : bucketName ,
41
30
} ) ;
42
31
const result = await s3Client . send ( listObjectsCommand ) ;
43
- const keysToDelete : Array < string > = [ ] ;
32
+ const keysToDelete : Array < { Key : string } > = [ ] ;
44
33
45
34
if ( result . Contents ) {
46
35
for ( const item of result . Contents ) {
47
36
if ( item . Key ) {
48
- keysToDelete . push ( item . Key ) ;
37
+ keysToDelete . push ( { Key : item . Key } ) ;
49
38
}
50
39
}
51
40
}
52
41
53
- await deleteS3Object ( s3Client , bucketName , keysToDelete ) ;
42
+ if ( keysToDelete . length ) {
43
+ const deleteObjectsCommand = new DeleteObjectsCommand ( {
44
+ Bucket : bucketName ,
45
+ Delete : { Objects : keysToDelete } ,
46
+ } ) ;
47
+
48
+ await s3Client . send ( deleteObjectsCommand ) ;
49
+ }
54
50
}
55
51
56
52
async function fetchS3ObjectArtifact (
@@ -159,55 +155,6 @@ function runArtifactsCDNTests(
159
155
expect ( isMatch ) . toEqual ( true ) ;
160
156
} ) ;
161
157
162
- test . concurrent (
163
- 'deleting (legacy) cdn access token from s3 revokes artifact cdn access' ,
164
- async ( ) => {
165
- const { createOrg } = await initSeed ( ) . createOwner ( ) ;
166
- const { createProject } = await createOrg ( ) ;
167
- const { createToken, target } = await createProject ( ProjectType . Single ) ;
168
- const writeToken = await createToken ( {
169
- targetScopes : [ TargetAccessScope . RegistryRead , TargetAccessScope . RegistryWrite ] ,
170
- } ) ;
171
-
172
- const publishSchemaResult = await writeToken
173
- . publishSchema ( {
174
- author : 'Kamil' ,
175
- commit : 'abc123' ,
176
- sdl : `type Query { ping: String }` ,
177
- } )
178
- . then ( r => r . expectNoGraphQLErrors ( ) ) ;
179
-
180
- const cdnAccess = await writeToken . createCdnAccess ( ) ;
181
- const endpointBaseUrl = await getBaseEndpoint ( ) ;
182
-
183
- // First roundtrip
184
- const url = buildEndpointUrl ( endpointBaseUrl , target ! . id , 'sdl' ) ;
185
- let response = await fetch ( url , {
186
- method : 'GET' ,
187
- headers : {
188
- 'x-hive-cdn-key' : cdnAccess . token ,
189
- } ,
190
- } ) ;
191
- expect ( response . status ) . toEqual ( 200 ) ;
192
- expect ( await response . text ( ) ) . toMatchInlineSnapshot ( `
193
- "type Query {
194
- ping: String
195
- }"
196
- ` ) ;
197
-
198
- await deleteS3Object ( s3Client , 'artifacts' , [ `cdn-legacy-keys/${ target . id } ` ] ) ;
199
-
200
- // Second roundtrip
201
- response = await fetch ( url , {
202
- method : 'GET' ,
203
- headers : {
204
- 'x-hive-cdn-key' : cdnAccess . token ,
205
- } ,
206
- } ) ;
207
- expect ( response . status ) . toEqual ( 403 ) ;
208
- } ,
209
- ) ;
210
-
211
158
test . concurrent ( 'access SDL artifact with valid credentials' , async ( ) => {
212
159
const { createOrg } = await initSeed ( ) . createOwner ( ) ;
213
160
const { createProject } = await createOrg ( ) ;
@@ -419,6 +366,7 @@ function runArtifactsCDNTests(
419
366
420
367
expect ( response . status ) . toEqual ( 200 ) ;
421
368
const result = await response . json ( ) ;
369
+ console . log ( result ) ;
422
370
expect ( result . data . __schema . types ) . toContainEqual ( {
423
371
name : 'Query' ,
424
372
fields : [ { name : 'ping' } ] ,
0 commit comments