Skip to content
Open
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
11 changes: 5 additions & 6 deletions .github/workflows/keyfactor-starter-workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,9 @@ on:

jobs:
call-starter-workflow:
uses: keyfactor/actions/.github/workflows/starter.yml@3.2.0
uses: keyfactor/actions/.github/workflows/starter.yml@v5
secrets:
token: ${{ secrets.V2BUILDTOKEN}}
APPROVE_README_PUSH: ${{ secrets.APPROVE_README_PUSH}}
gpg_key: ${{ secrets.KF_GPG_PRIVATE_KEY }}
gpg_pass: ${{ secrets.KF_GPG_PASSPHRASE }}
scan_token: ${{ secrets.SAST_TOKEN }}
token: ${{ secrets.V2BUILDTOKEN}} # REQUIRED
gpg_key: ${{ secrets.KF_GPG_PRIVATE_KEY }} # Only required for golang builds
gpg_pass: ${{ secrets.KF_GPG_PASSPHRASE }} # Only required for golang builds
scan_token: ${{ secrets.SAST_TOKEN }} # REQUIRED
20 changes: 7 additions & 13 deletions AzureAppGatewayOrchestrator.Tests/AzureAppGW.cs
Original file line number Diff line number Diff line change
@@ -1,16 +1,10 @@
// Copyright 2024 Keyfactor
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

// Copyright 2026 Keyfactor
// Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License.
// You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
// Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions
// and limitations under the License.

using System.Security.Cryptography.X509Certificates;
using Azure.ResourceManager.Network.Models;
Expand Down Expand Up @@ -103,7 +97,7 @@
JobResult result = inventory.ProcessJob(config, (inventoryItems) =>
{
// Assert
Assert.Equal(1, inventoryItems.Count());

Check warning on line 100 in AzureAppGatewayOrchestrator.Tests/AzureAppGW.cs

View workflow job for this annotation

GitHub Actions / Build and Test dotnet project

Do not use Assert.Equal() to check for collection size. Use Assert.Single instead. (https://xunit.net/xunit.analyzers/rules/xUnit2013)

Check warning on line 100 in AzureAppGatewayOrchestrator.Tests/AzureAppGW.cs

View workflow job for this annotation

GitHub Actions / Build and Test dotnet project

Do not use Assert.Equal() to check for collection size. Use Assert.Single instead. (https://xunit.net/xunit.analyzers/rules/xUnit2013)

Check warning on line 100 in AzureAppGatewayOrchestrator.Tests/AzureAppGW.cs

View workflow job for this annotation

GitHub Actions / call-starter-workflow / call-dotnet-build-and-release-workflow / dotnet-build-and-release

Do not use Assert.Equal() to check for collection size. Use Assert.Single instead. (https://xunit.net/xunit.analyzers/rules/xUnit2013)

Check warning on line 100 in AzureAppGatewayOrchestrator.Tests/AzureAppGW.cs

View workflow job for this annotation

GitHub Actions / call-starter-workflow / call-dotnet-build-and-release-workflow / dotnet-build-and-release

Do not use Assert.Equal() to check for collection size. Use Assert.Single instead. (https://xunit.net/xunit.analyzers/rules/xUnit2013)
Assert.Equal("test", inventoryItems.First().Alias);

_logger.LogInformation("AzureAppGw_Inventory_ProcessJob_ValidClient_ReturnSuccess - Success");
Expand Down Expand Up @@ -146,7 +140,7 @@
callbackCalled = true;

// Assert
Assert.True(false, "Callback should not be called");

Check warning on line 143 in AzureAppGatewayOrchestrator.Tests/AzureAppGW.cs

View workflow job for this annotation

GitHub Actions / Build and Test dotnet project

Do not use Assert.True(false, message) to fail a test. Use Assert.Fail(message) instead. (https://xunit.net/xunit.analyzers/rules/xUnit2020)

Check warning on line 143 in AzureAppGatewayOrchestrator.Tests/AzureAppGW.cs

View workflow job for this annotation

GitHub Actions / Build and Test dotnet project

Do not use Assert.True(false, message) to fail a test. Use Assert.Fail(message) instead. (https://xunit.net/xunit.analyzers/rules/xUnit2020)

Check warning on line 143 in AzureAppGatewayOrchestrator.Tests/AzureAppGW.cs

View workflow job for this annotation

GitHub Actions / call-starter-workflow / call-dotnet-build-and-release-workflow / dotnet-build-and-release

Do not use Assert.True(false, message) to fail a test. Use Assert.Fail(message) instead. (https://xunit.net/xunit.analyzers/rules/xUnit2020)

Check warning on line 143 in AzureAppGatewayOrchestrator.Tests/AzureAppGW.cs

View workflow job for this annotation

GitHub Actions / call-starter-workflow / call-dotnet-build-and-release-workflow / dotnet-build-and-release

Do not use Assert.True(false, message) to fail a test. Use Assert.Fail(message) instead. (https://xunit.net/xunit.analyzers/rules/xUnit2020)
return true;
});

Expand Down Expand Up @@ -223,7 +217,7 @@
JobResult result = discovery.ProcessJob(config, (discoveredAppGateways) =>
{
// Assert
Assert.Equal(1, discoveredAppGateways.Count());

Check warning on line 220 in AzureAppGatewayOrchestrator.Tests/AzureAppGW.cs

View workflow job for this annotation

GitHub Actions / Build and Test dotnet project

Do not use Assert.Equal() to check for collection size. Use Assert.Single instead. (https://xunit.net/xunit.analyzers/rules/xUnit2013)

Check warning on line 220 in AzureAppGatewayOrchestrator.Tests/AzureAppGW.cs

View workflow job for this annotation

GitHub Actions / Build and Test dotnet project

Do not use Assert.Equal() to check for collection size. Use Assert.Single instead. (https://xunit.net/xunit.analyzers/rules/xUnit2013)

Check warning on line 220 in AzureAppGatewayOrchestrator.Tests/AzureAppGW.cs

View workflow job for this annotation

GitHub Actions / call-starter-workflow / call-dotnet-build-and-release-workflow / dotnet-build-and-release

Do not use Assert.Equal() to check for collection size. Use Assert.Single instead. (https://xunit.net/xunit.analyzers/rules/xUnit2013)

Check warning on line 220 in AzureAppGatewayOrchestrator.Tests/AzureAppGW.cs

View workflow job for this annotation

GitHub Actions / call-starter-workflow / call-dotnet-build-and-release-workflow / dotnet-build-and-release

Do not use Assert.Equal() to check for collection size. Use Assert.Single instead. (https://xunit.net/xunit.analyzers/rules/xUnit2013)
Assert.Equal("test", discoveredAppGateways.First());

_logger.LogInformation("Discovery_ProcessJob_ValidClient_ReturnSuccess - Success");
Expand Down Expand Up @@ -268,7 +262,7 @@
callbackCalled = true;

// Assert
Assert.True(false, "Callback should not be called");

Check warning on line 265 in AzureAppGatewayOrchestrator.Tests/AzureAppGW.cs

View workflow job for this annotation

GitHub Actions / Build and Test dotnet project

Do not use Assert.True(false, message) to fail a test. Use Assert.Fail(message) instead. (https://xunit.net/xunit.analyzers/rules/xUnit2020)
return true;
});

Expand Down
Original file line number Diff line number Diff line change
@@ -1,35 +1,36 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>

<IsPackable>false</IsPackable>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Azure.ResourceManager.Network" Version="1.7.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.1.0" />
<PackageReference Include="Moq" Version="4.20.70" />
<PackageReference Include="NLog.Extensions.Logging" Version="5.3.8" />
<PackageReference Include="xunit" Version="2.4.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.3">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="coverlet.collector" Version="3.1.2">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
</ItemGroup>

<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>

<IsPackable>false</IsPackable>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Azure.ResourceManager.Network" Version="1.9.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="18.6.0" />
<PackageReference Include="Moq" Version="4.20.70" />
<PackageReference Include="NLog.Extensions.Logging" Version="6.1.3" />
<PackageReference Include="FluentAssertions" Version="7.2.0" />
<PackageReference Include="xunit" Version="2.7.0" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.8.0">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="coverlet.collector" Version="3.1.2">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\AzureAppGatewayOrchestrator\AzureAppGatewayOrchestrator.csproj" />
</ItemGroup>
</ItemGroup>

<ItemGroup>
<Content Include="xunit.runner.json" CopyToOutputDirectory="PreserveNewest" />
</ItemGroup>
</Project>

</Project>
20 changes: 7 additions & 13 deletions AzureAppGatewayOrchestrator.Tests/AzureAppGwBin.cs
Original file line number Diff line number Diff line change
@@ -1,16 +1,10 @@
// Copyright 2024 Keyfactor
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

// Copyright 2026 Keyfactor
// Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License.
// You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
// Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions
// and limitations under the License.

using System.Security.Cryptography.X509Certificates;
using Azure.ResourceManager.Network.Models;
Expand Down Expand Up @@ -104,7 +98,7 @@
JobResult result = inventory.ProcessJob(config, (inventoryItems) =>
{
// Assert
Assert.Equal(1, inventoryItems.Count());

Check warning on line 101 in AzureAppGatewayOrchestrator.Tests/AzureAppGwBin.cs

View workflow job for this annotation

GitHub Actions / Build and Test dotnet project

Do not use Assert.Equal() to check for collection size. Use Assert.Single instead. (https://xunit.net/xunit.analyzers/rules/xUnit2013)

Check warning on line 101 in AzureAppGatewayOrchestrator.Tests/AzureAppGwBin.cs

View workflow job for this annotation

GitHub Actions / Build and Test dotnet project

Do not use Assert.Equal() to check for collection size. Use Assert.Single instead. (https://xunit.net/xunit.analyzers/rules/xUnit2013)

Check warning on line 101 in AzureAppGatewayOrchestrator.Tests/AzureAppGwBin.cs

View workflow job for this annotation

GitHub Actions / call-starter-workflow / call-dotnet-build-and-release-workflow / dotnet-build-and-release

Do not use Assert.Equal() to check for collection size. Use Assert.Single instead. (https://xunit.net/xunit.analyzers/rules/xUnit2013)

Check warning on line 101 in AzureAppGatewayOrchestrator.Tests/AzureAppGwBin.cs

View workflow job for this annotation

GitHub Actions / call-starter-workflow / call-dotnet-build-and-release-workflow / dotnet-build-and-release

Do not use Assert.Equal() to check for collection size. Use Assert.Single instead. (https://xunit.net/xunit.analyzers/rules/xUnit2013)
Assert.Equal("fake-http-listener", inventoryItems.First().Alias);

_logger.LogInformation("AzureAppGwBin_Inventory_ProcessJob_ValidClientOneBoundHttpsListener_ReturnSuccess - Success");
Expand Down Expand Up @@ -146,7 +140,7 @@
JobResult result = discovery.ProcessJob(config, (discoveredAppGateways) =>
{
// Assert
Assert.Equal(1, discoveredAppGateways.Count());

Check warning on line 143 in AzureAppGatewayOrchestrator.Tests/AzureAppGwBin.cs

View workflow job for this annotation

GitHub Actions / Build and Test dotnet project

Do not use Assert.Equal() to check for collection size. Use Assert.Single instead. (https://xunit.net/xunit.analyzers/rules/xUnit2013)

Check warning on line 143 in AzureAppGatewayOrchestrator.Tests/AzureAppGwBin.cs

View workflow job for this annotation

GitHub Actions / Build and Test dotnet project

Do not use Assert.Equal() to check for collection size. Use Assert.Single instead. (https://xunit.net/xunit.analyzers/rules/xUnit2013)

Check warning on line 143 in AzureAppGatewayOrchestrator.Tests/AzureAppGwBin.cs

View workflow job for this annotation

GitHub Actions / call-starter-workflow / call-dotnet-build-and-release-workflow / dotnet-build-and-release

Do not use Assert.Equal() to check for collection size. Use Assert.Single instead. (https://xunit.net/xunit.analyzers/rules/xUnit2013)

Check warning on line 143 in AzureAppGatewayOrchestrator.Tests/AzureAppGwBin.cs

View workflow job for this annotation

GitHub Actions / call-starter-workflow / call-dotnet-build-and-release-workflow / dotnet-build-and-release

Do not use Assert.Equal() to check for collection size. Use Assert.Single instead. (https://xunit.net/xunit.analyzers/rules/xUnit2013)
Assert.Equal("test", discoveredAppGateways.First());

_logger.LogInformation("Discovery_ProcessJob_ValidClient_ReturnSuccess - Success");
Expand Down Expand Up @@ -191,7 +185,7 @@
callbackCalled = true;

// Assert
Assert.True(false, "Callback should not be called");

Check warning on line 188 in AzureAppGatewayOrchestrator.Tests/AzureAppGwBin.cs

View workflow job for this annotation

GitHub Actions / Build and Test dotnet project

Do not use Assert.True(false, message) to fail a test. Use Assert.Fail(message) instead. (https://xunit.net/xunit.analyzers/rules/xUnit2020)

Check warning on line 188 in AzureAppGatewayOrchestrator.Tests/AzureAppGwBin.cs

View workflow job for this annotation

GitHub Actions / call-starter-workflow / call-dotnet-build-and-release-workflow / dotnet-build-and-release

Do not use Assert.True(false, message) to fail a test. Use Assert.Fail(message) instead. (https://xunit.net/xunit.analyzers/rules/xUnit2020)

Check warning on line 188 in AzureAppGatewayOrchestrator.Tests/AzureAppGwBin.cs

View workflow job for this annotation

GitHub Actions / call-starter-workflow / call-dotnet-build-and-release-workflow / dotnet-build-and-release

Do not use Assert.True(false, message) to fail a test. Use Assert.Fail(message) instead. (https://xunit.net/xunit.analyzers/rules/xUnit2020)
return true;
});

Expand Down
20 changes: 7 additions & 13 deletions AzureAppGatewayOrchestrator.Tests/Client.cs
Original file line number Diff line number Diff line change
@@ -1,16 +1,10 @@
// Copyright 2024 Keyfactor
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

// Copyright 2026 Keyfactor
// Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License.
// You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
// Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions
// and limitations under the License.

using System.Security.Cryptography;
using System.Security.Cryptography.X509Certificates;
Expand Down
20 changes: 7 additions & 13 deletions AzureAppGatewayOrchestrator.Tests/FakeClient.cs
Original file line number Diff line number Diff line change
@@ -1,16 +1,10 @@
// Copyright 2024 Keyfactor
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

// Copyright 2026 Keyfactor
// Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License.
// You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
// Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions
// and limitations under the License.

using System.Security.Cryptography.X509Certificates;
using Azure.ResourceManager.Network.Models;
Expand Down
20 changes: 7 additions & 13 deletions AzureAppGatewayOrchestrator.Tests/IntegrationTestingFact.cs
Original file line number Diff line number Diff line change
@@ -1,16 +1,10 @@
// Copyright 2024 Keyfactor
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

// Copyright 2026 Keyfactor
// Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License.
// You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
// Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions
// and limitations under the License.

namespace AzureAppGatewayOrchestrator.Tests;

Expand Down
86 changes: 73 additions & 13 deletions AzureAppGatewayOrchestrator.Tests/JobClientBuilder.cs
Original file line number Diff line number Diff line change
@@ -1,16 +1,10 @@
// Copyright 2024 Keyfactor
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

// Copyright 2026 Keyfactor
// Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License.
// You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
// Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions
// and limitations under the License.

using System.Security.Cryptography;
using System.Security.Cryptography.X509Certificates;
Expand All @@ -20,7 +14,9 @@
using AzureApplicationGatewayOrchestratorExtension.Client;
using Keyfactor.Logging;
using Keyfactor.Orchestrators.Extensions;
using Keyfactor.Orchestrators.Extensions.Interfaces;
using Microsoft.Extensions.Logging;
using Moq;
using NLog.Extensions.Logging;

public class JobClientBuilder
Expand Down Expand Up @@ -142,6 +138,70 @@ public void AppGatewayJobClientBuilder_ValidCertificateStoreConfigClientCertific
_logger.LogInformation("AppGatewayJobClientBuilder_ValidCertificateStoreConfigClientCertificate_BuildValidClient - Success");
}

[Fact]
public void AppGatewayJobClientBuilder_WithPAMResolver_CertificateStoreDetails_ResolvesCredentials()
{
// Arrange
var mockResolver = new Mock<IPAMSecretResolver>();
mockResolver.Setup(r => r.Resolve("pam-key-for-username")).Returns("resolved-azure-application-id");
mockResolver.Setup(r => r.Resolve("pam-key-for-password")).Returns("resolved-azure-client-secret");

AppGatewayJobClientBuilder<FakeClient.FakeBuilder> jobClientBuilderWithFakeBuilder = new();
jobClientBuilderWithFakeBuilder.resolver = mockResolver.Object;

CertificateStore fakeCertificateStoreDetails = new()
{
ClientMachine = "fake-tenant-id",
StorePath = "fake-azure-resource-id",
Properties = "{\"ServerUsername\":\"pam-key-for-username\",\"ServerPassword\":\"pam-key-for-password\",\"AzureCloud\":\"fake-azure-cloud\"}"
};

// Act
jobClientBuilderWithFakeBuilder
.WithCertificateStoreDetails(fakeCertificateStoreDetails)
.Build();

// Assert
Assert.Equal("resolved-azure-application-id", jobClientBuilderWithFakeBuilder._builder._applicationId);
Assert.Equal("resolved-azure-client-secret", jobClientBuilderWithFakeBuilder._builder._clientSecret);
mockResolver.Verify(r => r.Resolve("pam-key-for-username"), Times.Once);
mockResolver.Verify(r => r.Resolve("pam-key-for-password"), Times.Once);

_logger.LogInformation("AppGatewayJobClientBuilder_WithPAMResolver_CertificateStoreDetails_ResolvesCredentials - Success");
}

[Fact]
public void AppGatewayJobClientBuilder_WithPAMResolver_DiscoveryJobConfiguration_ResolvesCredentials()
{
// Arrange
var mockResolver = new Mock<IPAMSecretResolver>();
mockResolver.Setup(r => r.Resolve("pam-key-for-username")).Returns("resolved-azure-application-id");
mockResolver.Setup(r => r.Resolve("pam-key-for-password")).Returns("resolved-azure-client-secret");

AppGatewayJobClientBuilder<FakeClient.FakeBuilder> jobClientBuilderWithFakeBuilder = new();
jobClientBuilderWithFakeBuilder.resolver = mockResolver.Object;

DiscoveryJobConfiguration config = new()
{
ClientMachine = "fake-tenant-id",
ServerUsername = "pam-key-for-username",
ServerPassword = "pam-key-for-password"
};

// Act
jobClientBuilderWithFakeBuilder
.WithDiscoveryJobConfiguration(config, "fake-tenant-id")
.Build();

// Assert
Assert.Equal("resolved-azure-application-id", jobClientBuilderWithFakeBuilder._builder._applicationId);
Assert.Equal("resolved-azure-client-secret", jobClientBuilderWithFakeBuilder._builder._clientSecret);
mockResolver.Verify(r => r.Resolve("pam-key-for-username"), Times.Once);
mockResolver.Verify(r => r.Resolve("pam-key-for-password"), Times.Once);

_logger.LogInformation("AppGatewayJobClientBuilder_WithPAMResolver_DiscoveryJobConfiguration_ResolvesCredentials - Success");
}

static void ConfigureLogging()
{
var config = new NLog.Config.LoggingConfiguration();
Expand Down
Loading
Loading