Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update bastion tests #23917

Merged
merged 1 commit into from
Sep 9, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ internal class BastionHostContainerTests : NetworkServiceClientTestBase
private ResourceGroup _resourceGroup;
private Subnet _subnet;
private PublicIPAddress _publicIPAddress;
private string _bastionName;

private ResourceIdentifier _resourceGroupIdentifier;
private ResourceIdentifier _subnetIdentifier;
Expand Down Expand Up @@ -50,6 +51,7 @@ public async Task GlobalSetUp()
ipData.Sku.Name = PublicIPAddressSkuName.Standard;
var ipLro = await rg.GetPublicIPAddresses().CreateOrUpdateAsync(SessionRecording.GenerateAssetName("ip-"), ipData);
_publicIPAddressIdentifier = ipLro.Value.Id;
_bastionName = SessionRecording.GenerateAssetName("bastion-");
StopSessionRecording();
}

Expand All @@ -66,9 +68,9 @@ public async Task TestSetUp()
[TearDown]
public async Task TestTearDown()
{
List<BastionHost> bastionList = await _resourceGroup.GetBastionHosts().GetAllAsync().ToEnumerableAsync();
foreach (var bastion in bastionList)
if (_resourceGroup.GetBastionHosts().CheckIfExists(_bastionName))
{
BastionHost bastion = await _resourceGroup.GetBastionHosts().GetAsync(_bastionName);
await bastion.DeleteAsync();
}
}
Expand All @@ -92,10 +94,9 @@ private async Task<BastionHost> CreateBastionHost(string bastionName)
[RecordedTest]
public async Task CreateOrUpdate()
{
string bastionName = SessionRecording.GenerateAssetName("bastion-");
BastionHost bastionHost = await CreateBastionHost(bastionName);
BastionHost bastionHost = await CreateBastionHost(_bastionName);
Assert.IsNotNull(bastionHost.Data);
Assert.AreEqual(bastionName, bastionHost.Data.Name);
Assert.AreEqual(_bastionName, bastionHost.Data.Name);
Assert.AreEqual(Location.WestUS2.ToString(), bastionHost.Data.Location);
Assert.AreEqual(0, bastionHost.Data.Tags.Count);
}
Expand All @@ -104,11 +105,10 @@ public async Task CreateOrUpdate()
[RecordedTest]
public async Task Get()
{
string bastionName = SessionRecording.GenerateAssetName("bastion-");
BastionHost bastionHost = await CreateBastionHost(bastionName);
var bastion = await _resourceGroup.GetBastionHosts().GetAsync(bastionName);
BastionHost bastionHost = await CreateBastionHost(_bastionName);
var bastion = await _resourceGroup.GetBastionHosts().GetAsync(_bastionName);
Assert.IsNotNull(bastion.Value.Data);
Assert.AreEqual(bastionName, bastion.Value.Data.Name);
Assert.AreEqual(_bastionName, bastion.Value.Data.Name);
Assert.AreEqual(Location.WestUS2.ToString(), bastion.Value.Data.Location);
Assert.AreEqual(0, bastion.Value.Data.Tags.Count);
}
Expand All @@ -117,29 +117,26 @@ public async Task Get()
[RecordedTest]
public async Task GetAll()
{
string bastionName = SessionRecording.GenerateAssetName("bastion-");
BastionHost bastionHost = await CreateBastionHost(bastionName);
BastionHost bastionHost = await CreateBastionHost(_bastionName);
List<BastionHost> BastionList = await _resourceGroup.GetBastionHosts().GetAllAsync().ToEnumerableAsync();
Has.One.EqualTo(BastionList);
Assert.AreEqual(bastionName, BastionList[0].Data.Name);
Assert.AreEqual(_bastionName, BastionList[0].Data.Name);
}

[Test]
[RecordedTest]
public async Task CheckIfExists()
{
string bastionName = SessionRecording.GenerateAssetName("bastion-");
BastionHost bastionHost = await CreateBastionHost(bastionName);
Assert.IsTrue(_resourceGroup.GetBastionHosts().CheckIfExists(bastionName));
Assert.IsFalse(_resourceGroup.GetBastionHosts().CheckIfExists(bastionName + "1"));
BastionHost bastionHost = await CreateBastionHost(_bastionName);
Assert.IsTrue(_resourceGroup.GetBastionHosts().CheckIfExists(_bastionName));
Assert.IsFalse(_resourceGroup.GetBastionHosts().CheckIfExists(_bastionName + "1"));
}

[Test]
[RecordedTest]
public async Task Delete()
{
string bastionName = SessionRecording.GenerateAssetName("bastion-");
BastionHost bastionHost = await CreateBastionHost(bastionName);
BastionHost bastionHost = await CreateBastionHost(_bastionName);
await bastionHost.DeleteAsync();
List<BastionHost> bastionList = await _resourceGroup.GetBastionHosts().GetAllAsync().ToEnumerableAsync();
Assert.IsEmpty(bastionList);
Expand Down