mirror of
https://github.com/microsoft/onefuzz.git
synced 2025-06-13 02:28:10 +00:00
* 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>
65 lines
2.2 KiB
C#
65 lines
2.2 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Threading.Tasks;
|
|
using Microsoft.OneFuzz.Service;
|
|
|
|
using Async = System.Threading.Tasks;
|
|
|
|
namespace Tests.Integration;
|
|
|
|
// This exists solely to allow use of a fixed storage account in integration tests
|
|
// against live Azure Storage.
|
|
sealed class AzureStorage : IStorage {
|
|
public static IStorage FromEnvironment() {
|
|
var accountName = Environment.GetEnvironmentVariable("AZURE_ACCOUNT_NAME");
|
|
var accountKey = Environment.GetEnvironmentVariable("AZURE_ACCOUNT_KEY");
|
|
|
|
if (accountName is null) {
|
|
throw new Exception("AZURE_ACCOUNT_NAME must be set in environment to run integration tests (use --filter 'Category!=Integration' to skip them)");
|
|
}
|
|
|
|
if (accountKey is null) {
|
|
throw new Exception("AZURE_ACCOUNT_KEY must be set in environment to run integration tests (use --filter 'Category!=Integration' to skip them)");
|
|
}
|
|
|
|
return new AzureStorage(accountName, accountKey);
|
|
}
|
|
|
|
public string AccountName { get; }
|
|
public string AccountKey { get; }
|
|
|
|
public AzureStorage(string accountName, string accountKey) {
|
|
AccountName = accountName;
|
|
AccountKey = accountKey;
|
|
}
|
|
|
|
public IEnumerable<string> CorpusAccounts() {
|
|
throw new System.NotImplementedException();
|
|
}
|
|
|
|
public IEnumerable<string> GetAccounts(StorageType storageType) {
|
|
yield return AccountName;
|
|
}
|
|
|
|
public string GetPrimaryAccount(StorageType storageType) {
|
|
throw new System.NotImplementedException();
|
|
}
|
|
|
|
public Task<(string, string)> GetStorageAccountNameAndKey(string accountId)
|
|
=> Async.Task.FromResult((AccountName, AccountKey));
|
|
|
|
public Task<string?> GetStorageAccountNameKeyByName(string accountName) {
|
|
return Async.Task.FromResult(AccountName)!;
|
|
}
|
|
|
|
public Uri GetTableEndpoint(string accountId)
|
|
=> new($"https://{AccountName}.table.core.windows.net/");
|
|
|
|
public Uri GetQueueEndpoint(string accountId)
|
|
=> new($"https://{AccountName}.queue.core.windows.net/");
|
|
|
|
public Uri GetBlobEndpoint(string accountId)
|
|
=> new($"https://{AccountName}.blob.core.windows.net/");
|
|
|
|
}
|