Skip to content

Commit

Permalink
[storage] temporary fix for issue #11505 (#11737)
Browse files Browse the repository at this point in the history
* temporary fix for issue #11505

* format
  • Loading branch information
ljian3377 authored Oct 9, 2020
1 parent 91763cf commit 981933b
Show file tree
Hide file tree
Showing 3 changed files with 132 additions and 8 deletions.

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

0 comments on commit 981933b

Please sign in to comment.