mirror of
https://github.com/microsoft/onefuzz.git
synced 2025-06-13 10:38:08 +00:00
Migrate timer_task part 3 (#2066)
* Adding unit tests for the scheduler * formatting * fix unit test * bug fixes * proting a couple more missong functions * more bug fixes * fixing queries and serilization * fix sas url generation * fix condition * [testing] enabling timer_tasks for testing * Update src/ApiService/Tests/SchedulerTests.cs Co-authored-by: George Pollard <porges@porg.es> * address PR comments * build fix * address PR comment * removing renamed function * resolve merge * Update src/ApiService/Tests/Integration/AzuriteStorage.cs Co-authored-by: George Pollard <porges@porg.es> * - Added verification of the state transition functions - disabled validation on PoolName * Update src/deployment/deploy.py Co-authored-by: George Pollard <porges@porg.es> Co-authored-by: George Pollard <gpollard@microsoft.com>
This commit is contained in:
@ -164,14 +164,15 @@ public class Containers : IContainers {
|
||||
if (uri.Query.Contains("sig")) {
|
||||
return uri;
|
||||
}
|
||||
|
||||
var accountName = uri.Host.Split('.')[0];
|
||||
var (_, accountKey) = await _storage.GetStorageAccountNameAndKey(accountName);
|
||||
var blobUriBuilder = new BlobUriBuilder(uri);
|
||||
var accountKey = await _storage.GetStorageAccountNameKeyByName(blobUriBuilder.AccountName);
|
||||
var sasBuilder = new BlobSasBuilder(
|
||||
BlobContainerSasPermissions.Read | BlobContainerSasPermissions.Write | BlobContainerSasPermissions.Delete | BlobContainerSasPermissions.List,
|
||||
DateTimeOffset.UtcNow + TimeSpan.FromHours(1));
|
||||
DateTimeOffset.UtcNow + TimeSpan.FromHours(1)) {
|
||||
BlobContainerName = blobUriBuilder.BlobContainerName,
|
||||
};
|
||||
|
||||
var sas = sasBuilder.ToSasQueryParameters(new StorageSharedKeyCredential(accountName, accountKey)).ToString();
|
||||
var sas = sasBuilder.ToSasQueryParameters(new StorageSharedKeyCredential(blobUriBuilder.AccountName, accountKey)).ToString();
|
||||
return new UriBuilder(uri) {
|
||||
Query = sas
|
||||
}.Uri;
|
||||
@ -179,13 +180,10 @@ public class Containers : IContainers {
|
||||
|
||||
public async Async.Task<Uri> GetContainerSasUrl(Container container, StorageType storageType, BlobContainerSasPermissions permissions, TimeSpan? duration = null) {
|
||||
var client = await FindContainer(container, storageType) ?? throw new Exception($"unable to find container: {container.ContainerName} - {storageType}");
|
||||
var (accountName, accountKey) = await _storage.GetStorageAccountNameAndKey(client.AccountName);
|
||||
|
||||
var (startTime, endTime) = SasTimeWindow(duration ?? TimeSpan.FromDays(30));
|
||||
|
||||
var sasBuilder = new BlobSasBuilder(permissions, endTime) {
|
||||
StartsOn = startTime,
|
||||
BlobContainerName = container.ContainerName,
|
||||
BlobContainerName = container.ContainerName
|
||||
};
|
||||
|
||||
var sasUrl = client.GenerateSasUri(sasBuilder);
|
||||
|
Reference in New Issue
Block a user