* fix SA1505 and SA1508 * fix SA1116 * fix SA1009 * fix SA1019 * fix SA1127 * fix SA1128 * fix SA1134 * fix indent * allow CA2227 * fix CA1810 * using clean up * fix naming * fix CA1806 * fix await * Revert "fix CA1806" This reverts commit a3b465087fdaf26ec461272373ee9810a90de2cc. * fix dotnet format * allow SA1009
29 lines
959 B
C#
29 lines
959 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 = OperatingSystem.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");
|
|
}
|
|
}
|
|
}
|