Files
csharp/tests/KubernetesClient.Tests/GcpTokenProviderTests.cs
Boshi Lian 5be3cff425 Style fix final (#523)
* 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
2020-11-22 14:52:09 -08:00

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");
}
}
}