-
Notifications
You must be signed in to change notification settings - Fork 42
feat: add signature to ZIP tarball URL stored in KV store #875
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
3b96703
02c8db6
8d44b4f
f00174f
cba48f9
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -3,7 +3,8 @@ import { mkdir, writeFile } from 'node:fs/promises'; | |
|
|
||
| import type { ActorCollectionCreateOptions } from 'apify-client'; | ||
|
|
||
| import { ACTOR_SOURCE_TYPES, SOURCE_FILE_FORMATS } from '@apify/consts'; | ||
| import { ACTOR_SOURCE_TYPES, SOURCE_FILE_FORMATS, STORAGE_GENERAL_ACCESS } from '@apify/consts'; | ||
| import { createHmacSignature } from '@apify/utilities'; | ||
|
|
||
| import { testRunCommand } from '../../../src/lib/command-framework/apify-command.js'; | ||
| import { LOCAL_CONFIG_PATH } from '../../../src/lib/consts.js'; | ||
|
|
@@ -236,7 +237,20 @@ describe('[api] apify push', () => { | |
| testActor = (await testActorClient.get())!; | ||
| const testActorVersion = await testActorClient.version(actorJson.version).get(); | ||
| const store = await testUserClient.keyValueStores().getOrCreate(`actor-${testActor.id}-source`); | ||
| await testUserClient.keyValueStore(store.id).delete(); // We just needed the store ID, we can clean up now | ||
|
|
||
| // Update the store's general access to RESTRICTED | ||
| await testUserClient.keyValueStore(store.id).update({ generalAccess: STORAGE_GENERAL_ACCESS.RESTRICTED }); | ||
|
|
||
| expect(store.urlSigningSecretKey).toBeDefined(); | ||
| const signature = createHmacSignature(store.urlSigningSecretKey!, `version-${actorJson.version}.zip`); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. (opt) I'm never fond of when tests simply replicate the code being tested 😄 It's not much of a test... Is this running against actual Apify? If so, I'd suggest to:
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Yes, yes it is!
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Refactored the test |
||
|
|
||
| // Check if the tarball URL is accessible | ||
| await expect(fetch((testActorVersion as { tarballUrl: string }).tarballUrl)).resolves.toHaveProperty( | ||
| 'status', | ||
| 200, | ||
| ); | ||
|
|
||
| await testUserClient.keyValueStore(store.id).delete(); | ||
|
|
||
| if (testActor) await testActorClient.delete(); | ||
|
|
||
|
|
@@ -245,7 +259,7 @@ describe('[api] apify push', () => { | |
| buildTag: 'latest', | ||
| tarballUrl: | ||
| `${testActorClient.baseUrl}/key-value-stores/${store.id}` + | ||
| `/records/version-${actorJson.version}.zip?disableRedirect=true`, | ||
| `/records/version-${actorJson.version}.zip?disableRedirect=true&signature=${signature}`, | ||
| envVars: testActorWithEnvVars.versions[0].envVars, | ||
| sourceType: ACTOR_SOURCE_TYPES.TARBALL, | ||
| }); | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't this use the same getRecordPublicUrl?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd leave it as it is! It helps to make sure, that the URL has correct signature.
If for some reason
getRecordPublicUrlwill return URL without signature, we'll catch it in the test