-
Notifications
You must be signed in to change notification settings - Fork 14
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
BYO creds related issue #66
Changes from 1 commit
45d86b3
7fed333
b2131a4
48128e4
b406e00
3b23711
1b7053d
17de909
ff2e6b8
12ebe86
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 |
---|---|---|
|
@@ -73,7 +73,7 @@ class AzureBlobFiles extends Files { | |
constructor (credentials, tvm) { | ||
super() | ||
this.tvm = tvm | ||
moritzraho marked this conversation as resolved.
Show resolved
Hide resolved
|
||
this.hasOwnCredentials = false | ||
this.hasOwnCredentials = (tvm === null) | ||
moritzraho marked this conversation as resolved.
Show resolved
Hide resolved
|
||
const cloned = utils.withHiddenFields(credentials, ['storageAccessKey', 'sasURLPrivate', 'sasURLPublic']) | ||
logger.debug(`init AzureBlobFiles with config ${JSON.stringify(cloned, null, 2)}`) | ||
|
||
|
@@ -110,7 +110,6 @@ class AzureBlobFiles extends Files { | |
this._azure.containerURLPublic = azure.ContainerURL.fromServiceURL(serviceURL, credentials.containerName + '-public') | ||
this._azure.sasCreds = false | ||
this.credentials = utils.clone(credentials) | ||
this.hasOwnCredentials = true | ||
} | ||
} | ||
|
||
|
@@ -383,6 +382,8 @@ class AzureBlobFiles extends Files { | |
* @private | ||
*/ | ||
async _getAzureBlobPresignCredentials (params) { | ||
if (this._azure.sasCreds) { logAndThrow(new codes.ERROR_UNSUPPORTED_OPERATION({ messageValues: ['generatePresignURL'], sdkDetails: params })) } | ||
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. I think the condition should be 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. we already check for 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. ok 👍 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. should we make the |
||
|
||
const sharedKeyCredential = new azure.SharedKeyCredential(this.credentials.storageAccount, this.credentials.storageAccessKey) | ||
const containerName = this.credentials.containerName | ||
// generate SAS token | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -534,7 +534,7 @@ describe('_getUrl', () => { | |
}) | ||
|
||
test('test _getUrl custom host', async () => { | ||
files = new AzureBlobFiles({ ...fakeUserCredentials, hostName: 'fakeHost' }) | ||
files = new AzureBlobFiles({ ...fakeUserCredentials, hostName: 'fakeHost' }, null) | ||
const cleanUrl = 'https://fake.blob.core.windows.net/fake/fakesub/afile' | ||
setMockBlobUrl(cleanUrl) | ||
const expectedUrl = 'https://fakeHost/fake/fakesub/afile' | ||
|
@@ -610,6 +610,7 @@ describe('_getPresignUrl', () => { | |
test('_getPresignUrl with correct options default permission own credentials', async () => { | ||
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. the 4 tests should not simulate an init by setting private control variables. Instead those variable should be set by the constructor depending on the init input. |
||
files.hasOwnCredentials = true | ||
files.credentials = fakeUserCredentials | ||
files._azure.sasCreds = false | ||
const cleanUrl = 'https://fake.blob.core.windows.net/fake/fakesub/afile' | ||
setMockBlobUrl(cleanUrl) | ||
const expectedUrl = 'https://fake.blob.core.windows.net/fake/fakesub/afile?fakeSAS' | ||
|
@@ -620,16 +621,23 @@ describe('_getPresignUrl', () => { | |
test('_getPresignUrl with correct options explicit permission own credentials', async () => { | ||
files.hasOwnCredentials = true | ||
files.credentials = fakeUserCredentials | ||
files._azure.sasCreds = false | ||
const cleanUrl = 'https://fake.blob.core.windows.net/fake/fakesub/afile' | ||
setMockBlobUrl(cleanUrl) | ||
const expectedUrl = 'https://fake.blob.core.windows.net/fake/fakesub/afile?fakeSAS' | ||
const url = await files._getPresignUrl('fakesub/afile', { expiryInSeconds: 60, permissions: 'fake' }) | ||
expect(url).toEqual(expectedUrl) | ||
}) | ||
|
||
test('_getAzureBlobPresignCredentials with correct options', async () => { | ||
test('_getAzureBlobPresignCredentials with sas creds', async () => { | ||
files.hasOwnCredentials = true | ||
await expect(files._getAzureBlobPresignCredentials('fakesub/afile', { expiryInSeconds: 60 })).rejects.toThrow('[FilesLib:ERROR_UNSUPPORTED_OPERATION] Operation generatePresignURL not supported for SAS credentails') | ||
}) | ||
|
||
test('_getAzureBlobPresignCredentials with account creds', async () => { | ||
files.hasOwnCredentials = true | ||
files.credentials = fakeUserCredentials | ||
files._azure.sasCreds = false | ||
const ret = await files._getAzureBlobPresignCredentials('fakesub/afile', { expiryInSeconds: 60 }) | ||
expect(ret).toEqual({ signature: 'fakeSAS' }) | ||
}) | ||
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. missing test with tvm credentials ? you could pass a tvm mock to the init =>
then you can test
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. This one is specific unit test for the private function 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. Ok I see, I think we should test against |
||
|
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.
let's make this more generic: use simply
%s