Skip to content

Commit

Permalink
Clean-up
Browse files Browse the repository at this point in the history
  • Loading branch information
Ceredron committed Nov 13, 2024
1 parent ee9f71c commit e41cd7e
Showing 1 changed file with 1 addition and 15 deletions.
16 changes: 1 addition & 15 deletions tests/Altinn.Broker.Tests.LargeFile/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ static async Task Main(string[] args)
password = GetRequiredInput("Enter the test tools password");
}
Console.WriteLine($"Writing {uploadSize / (1024.0 * 1024.0 * 1024.0):N2} GiB with a buffer size of {BufferSize / (1024.0):N2} KiB");
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12; // TODO, remove?
using var httpClient = new HttpClient()
{
Timeout = TimeSpan.FromHours(48)
Expand All @@ -49,8 +48,6 @@ static async Task Main(string[] args)

var fileTransferId = await InitializeFileTransfer(httpClient, baseUrl);
await UploadFileToBroker(httpClient, fileTransferId, baseUrl, uploadSize);
await ConfirmDownload(httpClient, fileTransferId, baseUrl);

}

private static string GetRequiredInput(string prompt, string? defaultValue = null)
Expand All @@ -75,7 +72,7 @@ private static async Task<string> GetAccessToken(HttpClient httpClient, string t
{
var httpRequestMessage = new HttpRequestMessage()
{
RequestUri = new Uri($"https://altinn-testtools-token-generator.azurewebsites.net/api/GetEnterpriseToken?env=tt02&scopes=altinn:broker.write&org=ttd&orgNo={orgNumber}")
RequestUri = new Uri($"https://altinn-testtools-token-generator.azurewebsites.net/api/GetEnterpriseToken?env=tt02&scopes=altinn:broker.write altinn:broker.read&org=ttd&orgNo={orgNumber}")
};
var authenticationString = $"{testToolsUsername}:{testToolsPassword}";
var base64EncodedAuthenticationString = Convert.ToBase64String(System.Text.Encoding.ASCII.GetBytes(authenticationString));
Expand Down Expand Up @@ -122,22 +119,11 @@ private static async Task UploadFileToBroker(HttpClient httpClient, string fileT
}
finally
{
httpClient.Dispose();
stopwatch.Stop();
Console.WriteLine($"Upload completed in {stopwatch.ElapsedMilliseconds.ToString("N0")} ms");
}
}

private static async Task ConfirmDownload(HttpClient httpClient, string fileTransferId, string baseUrl)
{
var httpRequestMessage = new HttpRequestMessage()
{
RequestUri = new Uri(baseUrl + $"/broker/api/v1/filetransfer/{fileTransferId}/confirmdownload"),
Method = HttpMethod.Post
};
await httpClient.SendAsync(httpRequestMessage);
}

private static FileTransferInitalizeExt BasicFileTransfer() => new FileTransferInitalizeExt()
{
ResourceId = testResource,
Expand Down

0 comments on commit e41cd7e

Please sign in to comment.