-
Notifications
You must be signed in to change notification settings - Fork 643
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
Set SendCertificateChain
option in KeyVaultReader to enable SN+I authentication
#10179
Merged
joelverhagen
merged 5 commits into
NuGet:dev
from
adityapatwardhan:AddSendX5cToKeyVaultReader
Sep 12, 2024
Merged
Changes from 3 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
152d89d
Set `SendCertificateChain` option in KeyVaultReader to enable SN+I au…
adityapatwardhan f3003b2
Add unit test for Sendx5c
adityapatwardhan 177bb99
Add tests
adityapatwardhan 113dcfe
Fix test
adityapatwardhan 3e520d6
Add a mock SecretClient and internal constructor
adityapatwardhan File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
// Copyright (c) .NET Foundation. All rights reserved. | ||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. | ||
|
||
using System.Runtime.CompilerServices; | ||
|
||
#if SIGNED_BUILD | ||
[assembly: InternalsVisibleTo("NuGet.Services.KeyVault.Tests,PublicKey=0024000004800000940000000602000000240000525341310004000001000100b5fc90e7027f67871e773a8fde8938c81dd402ba65b9201d60593e96c492651e889cc13f1415ebb53fac1131ae0bd333c5ee6021672d9718ea31a8aebd0da0072f25d87dba6fc90ffd598ed4da35e44c398c454307e8e33b8426143daec9f596836f97c8f74750e5975c64e2189f45def46b2a2b1247adc3652bf5c308055da9")] | ||
#else | ||
[assembly: InternalsVisibleTo("NuGet.Services.KeyVault.Tests")] | ||
#endif |
34 changes: 34 additions & 0 deletions
34
tests/NuGet.Services.KeyVault.Tests/KeyVaultReaderFacts.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
// Copyright (c) .NET Foundation. All rights reserved. | ||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. | ||
|
||
using System; | ||
using System.Threading.Tasks; | ||
using Azure.Security.KeyVault.Secrets | ||
using Moq; | ||
using Xunit; | ||
|
||
namespace NuGet.Services.KeyVault.Tests | ||
{ | ||
public class SecretReaderFacts | ||
{ | ||
[Fact] | ||
public void GetSecretObjectWithSendX5c() | ||
{ | ||
// Arrange | ||
const string vaultName = "vaultName"; | ||
const string tenantId = "tenantId"; | ||
const string clientId = "clientId"; | ||
const string secret = "secretvalue"; | ||
|
||
X509Certificate2 certificate = new X509Certificate2(); | ||
|
||
KeyVaultConfiguration keyVaultConfiguration = new KeyVaultConfiguration("vaultName", "tenantId", "clientId", certificate, sendX5c:true); | ||
|
||
// Act | ||
var keyvaultReader = new KeyVaultReader(keyVaultConfiguration); | ||
|
||
// Assert | ||
Assert.True(keyvaultReader.isUsingSendX5c); | ||
} | ||
} | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@adityapatwardhan
Do you have a use case for this scenario? Otherwise, we're moving to Managed identity. KV reader is less of a priority for us.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PowerShell Gallery is planning to use SN+I. We cannot use Managed Identity for now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see. Could you be able to add unit tests covering the new code path?