Skip to content

Commit 6de551a

Browse files
author
Maddie Clayton
authored
Merge pull request Azure#6198 from maddieclayton/recordAks
Fix and rerecord Aks test
2 parents 87df5ff + f52a3fd commit 6de551a

File tree

3 files changed

+1154
-3309
lines changed

3 files changed

+1154
-3309
lines changed

src/ResourceManager/Aks/Commands.Aks.Test/ScenarioTests/KubernetesTests.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,8 @@ public KubernetesTests(ITestOutputHelper output)
1515
TestExecutionHelpers.SetUpSessionAndProfile();
1616
}
1717

18-
[Fact(Skip = "Need service team to re-record test after changes to the ClientRuntime.")]
18+
[Fact]
1919
[Trait(Category.AcceptanceType, Category.CheckIn)]
20-
[Trait("Re-record", "ClientRuntime changes")]
2120
public void TestAzureKubernetes()
2221
{
2322
TestController.NewInstance.RunPowerShellTest("Test-AzureRmKubernetes");

src/ResourceManager/Aks/Commands.Aks.Test/ScenarioTests/TestController.cs

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,27 @@ public void RunPowerShellTest(params string[] scripts)
7474
string jsonOutput = @"{""" + subscription + @""":{ ""service_principal"":""foo"",""client_secret"":""bar""}}";
7575
AzureSession.Instance.DataStore.WriteFile(Path.Combine(home, ".azure", "acsServicePrincipal.json"), jsonOutput);
7676
}
77+
else if (HttpMockServer.GetCurrentMode() == HttpRecorderMode.Record)
78+
{
79+
AzureSession.Instance.DataStore = new MemoryDataStore();
80+
var home = Environment.GetFolderPath(Environment.SpecialFolder.UserProfile);
81+
var dir = Path.GetDirectoryName(new Uri(Assembly.GetExecutingAssembly().CodeBase).AbsolutePath);
82+
var subscription = HttpMockServer.Variables["SubscriptionId"];
83+
var currentEnvironment = TestEnvironmentFactory.GetTestEnvironment();
84+
string spn = null;
85+
string spnSecret = null;
86+
if (currentEnvironment.ConnectionString.KeyValuePairs.ContainsKey("ServicePrincipal"))
87+
{
88+
spn = currentEnvironment.ConnectionString.KeyValuePairs["ServicePrincipal"];
89+
}
90+
if (currentEnvironment.ConnectionString.KeyValuePairs.ContainsKey("ServicePrincipalSecret"))
91+
{
92+
spnSecret = currentEnvironment.ConnectionString.KeyValuePairs["ServicePrincipalSecret"];
93+
}
94+
AzureSession.Instance.DataStore.WriteFile(Path.Combine(home, ".ssh", "id_rsa.pub"), File.ReadAllText(dir + "/Fixtures/id_rsa.pub"));
95+
string jsonOutput = @"{""" + subscription + @""":{ ""service_principal"":""" + spn + @""",""client_secret"":"""+ spnSecret + @"""}}";
96+
AzureSession.Instance.DataStore.WriteFile(Path.Combine(home, ".azure", "acsServicePrincipal.json"), jsonOutput);
97+
}
7798

7899
helper.RunPowerShellTest(scripts);
79100
}

src/ResourceManager/Aks/Commands.Aks.Test/SessionRecords/Commands.Aks.Test.ScenarioTests.KubernetesTests/TestAzureKubernetes.json

Lines changed: 1132 additions & 3307 deletions
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)