Skip to content
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

[storage] temporary fix for issue #11505 #11737

Merged
merged 2 commits into from
Oct 9, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

31 changes: 23 additions & 8 deletions sdk/storage/storage-file-share/src/Clients.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1132,12 +1132,23 @@ export class ShareClient extends StorageClient {
};

for (const identifier of response) {
let accessPolicy: any = undefined;
if (identifier.accessPolicy) {
accessPolicy = {
permissions: identifier.accessPolicy.permissions
};

if (identifier.accessPolicy.expiresOn) {
accessPolicy.expiresOn = new Date(identifier.accessPolicy.expiresOn);
}

if (identifier.accessPolicy.startsOn) {
accessPolicy.startsOn = new Date(identifier.accessPolicy.startsOn);
}
}

res.signedIdentifiers.push({
accessPolicy: {
expiresOn: new Date(identifier.accessPolicy!.expiresOn!),
permissions: identifier.accessPolicy!.permissions!,
startsOn: new Date(identifier.accessPolicy!.startsOn!)
},
accessPolicy,
id: identifier.id
});
}
Expand Down Expand Up @@ -1182,9 +1193,13 @@ export class ShareClient extends StorageClient {
for (const identifier of shareAcl || []) {
acl.push({
accessPolicy: {
expiresOn: truncatedISO8061Date(identifier.accessPolicy.expiresOn),
permissions: identifier.accessPolicy.permissions,
startsOn: truncatedISO8061Date(identifier.accessPolicy.startsOn)
expiresOn: identifier.accessPolicy?.expiresOn
? truncatedISO8061Date(identifier.accessPolicy.expiresOn)
: undefined,
permissions: identifier.accessPolicy?.permissions,
startsOn: identifier.accessPolicy?.startsOn
? truncatedISO8061Date(identifier.accessPolicy.startsOn)
: undefined
},
id: identifier.id
});
Expand Down
14 changes: 14 additions & 0 deletions sdk/storage/storage-file-share/test/node/shareclient.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,20 @@ describe("ShareClient Node.js only", () => {
done();
});

it("setAccessPolicy and getAccessPolicy with empty SignedIdentifier", async () => {
const identifiers: any = [
{
id: "MTIzNDU2Nzg5MDEyMzQ1Njc4OTAxMjM0NTY3ODkwMTI="
}
];

await shareClient.setAccessPolicy(identifiers);
const getAccessPolicyResponse = await shareClient.getAccessPolicy();

assert.equal(getAccessPolicyResponse.signedIdentifiers[0].id, identifiers[0].id);
assert.deepStrictEqual(getAccessPolicyResponse.signedIdentifiers[0].accessPolicy, undefined);
});

it("can be created with a url and a credential", async () => {
const factories = (shareClient as any).pipeline.factories;
const credential = factories[factories.length - 1] as StorageSharedKeyCredential;
Expand Down