-
Notifications
You must be signed in to change notification settings - Fork 98
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Key Vault convenience for data plane (V3) (#520)
* Add access to data plane key vault client * Secrets collection * Key collection * Key & Secret fluent * Support authenticating to Key Vault * Code Cleanup * fixed build * Fixed runtime issues * Fixed KV source file formatting. * Removed code comment. * Support getting by name & version in key vault * Support auth files without key vault endpoint
- Loading branch information
Showing
58 changed files
with
4,930 additions
and
504 deletions.
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
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,102 @@ | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
// Licensed under the MIT License. See License.txt in the project root for license information. | ||
|
||
using Fluent.Tests.Common; | ||
using Microsoft.Azure.Management.KeyVault.Fluent; | ||
using Microsoft.Azure.Management.ResourceManager.Fluent.Authentication; | ||
using Microsoft.Azure.Management.ResourceManager.Fluent.Core; | ||
using Microsoft.Azure.Management.KeyVault.Fluent.Models; | ||
using System.Linq; | ||
using Xunit; | ||
using System; | ||
using Microsoft.Rest.ClientRuntime.Azure.TestFramework; | ||
using Azure.Tests; | ||
using Microsoft.Azure.Test.HttpRecorder; | ||
using Microsoft.Azure.Management.ResourceManager.Fluent; | ||
using Microsoft.Azure.Management.Graph.RBAC.Fluent; | ||
using System.Collections.Generic; | ||
|
||
namespace Fluent.Tests | ||
{ | ||
|
||
public class Secrets | ||
{ | ||
|
||
/** | ||
* Main entry point. | ||
* @param args the parameters | ||
*/ | ||
[Fact] | ||
public void CanCRUDSecret() | ||
{ | ||
using (var context = FluentMockContext.Start(GetType().FullName)) | ||
{ | ||
IGraphRbacManager graphManager = TestHelper.CreateGraphRbacManager(); | ||
string vaultName1 = TestUtilities.GenerateName("vault1"); | ||
string secretName = TestUtilities.GenerateName("secret1"); | ||
string rgName = TestUtilities.GenerateName("rgNEMV"); | ||
|
||
IKeyVaultManager manager = TestHelper.CreateKeyVaultManager(); | ||
|
||
var spnCredentialsClientId = HttpMockServer.Variables[ConnectionStringKeys.ServicePrincipalKey]; | ||
|
||
try | ||
{ | ||
IVault vault = manager.Vaults | ||
.Define(vaultName1) | ||
.WithRegion(Region.USWest) | ||
.WithNewResourceGroup(rgName) | ||
.DefineAccessPolicy() | ||
.ForServicePrincipal(spnCredentialsClientId) | ||
.AllowKeyAllPermissions() | ||
.AllowSecretAllPermissions() | ||
.Attach() | ||
.Create(); | ||
Assert.NotNull(vault); | ||
|
||
SdkContext.DelayProvider.Delay(10000); | ||
|
||
var secret = vault.Secrets.Define(secretName) | ||
.WithValue("Some secret value") | ||
.Create(); | ||
|
||
Assert.NotNull(secret); | ||
Assert.NotNull(secret.Id); | ||
Assert.Equal("Some secret value", secret.Value); | ||
|
||
secret = secret.Update() | ||
.WithValue("Some updated value") | ||
.Apply(); | ||
|
||
Assert.Equal("Some updated value", secret.Value); | ||
|
||
var versions = secret.ListVersions(); | ||
|
||
int count = 2; | ||
foreach (var version in versions) | ||
{ | ||
if ("Some secret value" == version.Value) | ||
{ | ||
count--; | ||
} | ||
if ("Some updated value" == version.Value) | ||
{ | ||
count--; | ||
} | ||
} | ||
Assert.Equal(0, count); | ||
|
||
} | ||
finally | ||
{ | ||
try | ||
{ | ||
TestHelper.CreateResourceManager().ResourceGroups.DeleteByName(rgName); | ||
} | ||
catch { } | ||
} | ||
} | ||
} | ||
|
||
} | ||
} |
Oops, something went wrong.