Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
it("call the container service to get SAS for container", () => {
expect(blobServiceSpy.list).toHaveBeenCalledOnce();
expect(blobServiceSpy.list).toHaveBeenCalledWith("new-storage-acc-1", "foobar", {
folder: "path/to/folder",
limit: 1,
}, true);
expect(containerServiceSpy.generateSharedAccessUrl).toHaveBeenCalled();
expect(containerServiceSpy.generateSharedAccessUrl).toHaveBeenCalledWith(
"new-storage-acc-1", "foobar", {
AccessPolicy: jasmine.objectContaining({
Permissions: BlobUtilities.SharedAccessPermissions.READ,
}),
});
});
it("calls the blob service to generate SAS ", () => {
expect(blobServiceSpy.list).toHaveBeenCalledOnce();
expect(blobServiceSpy.list).toHaveBeenCalledWith("auto-storage-id", "foobar", {
folder: "path/to/file.sh",
limit: 1,
}, true);
expect(blobServiceSpy.generateSharedAccessBlobUrl).toHaveBeenCalledOnce();
expect(blobServiceSpy.generateSharedAccessBlobUrl).toHaveBeenCalledWith(
"auto-storage-id", "foobar", "path/to/file.sh", {
AccessPolicy: jasmine.objectContaining({
Permissions: BlobUtilities.SharedAccessPermissions.READ,
}),
});
});
private _createResourceFileFromBlob(
storageAccountId: string,
containerName: string,
file: string): Observable {
const sas: SharedAccessPolicy = {
AccessPolicy: {
Permissions: BlobUtilities.SharedAccessPermissions.READ,
Start: new Date(),
Expiry: DateTime.local().plus({ weeks: 1 }).toJSDate(),
},
};
return this.blobService.generateSharedAccessBlobUrl(
storageAccountId,
containerName,
file,
sas).pipe(
map((httpUrl) => {
return { httpUrl, filePath: "" };
}),
);
}
flatMap((result) => {
this.uploadingFiles = this.uploadingFiles.filter(x => x !== nodeFilePath);
this.changeDetector.detectChanges();
const sas: SharedAccessPolicy = {
AccessPolicy: {
Permissions: BlobUtilities.SharedAccessPermissions.READ,
Start: new Date(),
Expiry: moment().add(1, "week").toDate(),
},
};
return this.storageBlobService.generateSharedAccessBlobUrl(storageAccountId,
this._containerId,
blobName,
sas).pipe(tap((url) => {
this._addResourceFile(url, nodeFilePath);
}));
}),
);
flatMap((result) => {
this.uploadingFiles = this.uploadingFiles.filter(x => x !== nodeFilePath);
this.changeDetector.detectChanges();
const sas: SharedAccessPolicy = {
AccessPolicy: {
Permissions: BlobUtilities.SharedAccessPermissions.READ,
Start: new Date(),
Expiry: DateTime.local().plus({ weeks: 1 }).toJSDate(),
},
};
return this.storageBlobService.generateSharedAccessBlobUrl(storageAccountId,
this._containerId,
blobName,
sas).pipe(tap((url) => {
this._addResourceFile(url, nodeFilePath);
}));
}),
);