* all net5 * var * SA1310 * SA1310 * allow 1031 * SA1805 * fix SA1642 * remove unused code * allow sa1405 * isempty * fix CA1714 * fix CA1806 * remove always false if * fix format * fix CA1062 * allow SA0001 * fix CA1062 * allow ca1034 and temp allow ca1835 * fix 16XX doc related warnings * elm SA16XX * elm SA16XX * fix CA2213 * revert to pass all test * move unclear rule to ruleset * follow up of moving ruleset * remove this * fix test flaky
29 lines
960 B
C#
29 lines
960 B
C#
using System;
|
|
using System.IO;
|
|
using System.Threading;
|
|
using System.Threading.Tasks;
|
|
using FluentAssertions;
|
|
using k8s.Authentication;
|
|
|
|
namespace k8s.Tests
|
|
{
|
|
public class GcpTokenProviderTests
|
|
{
|
|
[OperatingSystemDependentFact(Exclude = OperatingSystems.OSX)]
|
|
public async Task GetToken()
|
|
{
|
|
var isWindows = Environment.OSVersion.Platform == PlatformID.Win32NT;
|
|
var cmd = Path.Combine(Directory.GetCurrentDirectory(), "assets", isWindows ? "mock-gcloud.cmd" : "mock-gcloud.sh");
|
|
if (!isWindows)
|
|
{
|
|
System.Diagnostics.Process.Start("chmod", $"+x {cmd}").WaitForExit();
|
|
}
|
|
|
|
var sut = new GcpTokenProvider(cmd);
|
|
var result = await sut.GetAuthenticationHeaderAsync(CancellationToken.None).ConfigureAwait(false);
|
|
result.Scheme.Should().Be("Bearer");
|
|
result.Parameter.Should().Be("ACCESS-TOKEN");
|
|
}
|
|
}
|
|
}
|