| | 1 | | // Copyright (c) Microsoft Corporation. All rights reserved. |
| | 2 | | // Licensed under the MIT License. See License.txt in the project root for |
| | 3 | | // license information. |
| | 4 | |
|
| | 5 | | namespace Microsoft.Azure.Management.Search.Tests |
| | 6 | | { |
| | 7 | | using Microsoft.Azure.Management.Search.Models; |
| | 8 | | using Microsoft.Azure.Search.Tests.Utilities; |
| | 9 | | using Xunit; |
| | 10 | |
|
| | 11 | | public sealed class AdminKeyTests : SearchTestBase<SearchServiceFixture> |
| | 12 | | { |
| | 13 | | [Fact] |
| | 14 | | public void CanGetAdminKeys() |
| | 15 | | { |
| 0 | 16 | | Run(() => |
| 0 | 17 | | { |
| 0 | 18 | | SearchManagementClient searchMgmt = GetSearchManagementClient(); |
| 0 | 19 | |
|
| 0 | 20 | | // List admin keys |
| 0 | 21 | | AdminKeyResult adminKeyResult = |
| 0 | 22 | | searchMgmt.AdminKeys.Get(Data.ResourceGroupName, Data.SearchServiceName); |
| 0 | 23 | |
|
| 0 | 24 | | Assert.NotNull(adminKeyResult); |
| 0 | 25 | | Assert.NotNull(adminKeyResult.PrimaryKey); |
| 0 | 26 | | Assert.NotNull(adminKeyResult.SecondaryKey); |
| 0 | 27 | | Assert.NotEmpty(adminKeyResult.PrimaryKey); |
| 0 | 28 | | Assert.NotEmpty(adminKeyResult.SecondaryKey); |
| 0 | 29 | | }); |
| 0 | 30 | | } |
| | 31 | |
|
| | 32 | | [Fact] |
| | 33 | | public void CanRegenerateAdminKeys() |
| | 34 | | { |
| 0 | 35 | | Run(() => |
| 0 | 36 | | { |
| 0 | 37 | | SearchManagementClient searchMgmt = GetSearchManagementClient(); |
| 0 | 38 | |
|
| 0 | 39 | | AdminKeyResult originalAdminKeys = |
| 0 | 40 | | searchMgmt.AdminKeys.Get(Data.ResourceGroupName, Data.SearchServiceName); |
| 0 | 41 | |
|
| 0 | 42 | | AdminKeyResult keysWithNewPrimary = |
| 0 | 43 | | searchMgmt.AdminKeys.Regenerate(Data.ResourceGroupName, Data.SearchServiceName, AdminKeyKind.Primary |
| 0 | 44 | |
|
| 0 | 45 | | Assert.False(string.IsNullOrEmpty(keysWithNewPrimary.PrimaryKey)); |
| 0 | 46 | | Assert.NotEqual(originalAdminKeys.PrimaryKey, keysWithNewPrimary.PrimaryKey); |
| 0 | 47 | | Assert.Equal(originalAdminKeys.SecondaryKey, keysWithNewPrimary.SecondaryKey); |
| 0 | 48 | |
|
| 0 | 49 | | AdminKeyResult keysWithNewSecondary = |
| 0 | 50 | | searchMgmt.AdminKeys.Regenerate(Data.ResourceGroupName, Data.SearchServiceName, AdminKeyKind.Seconda |
| 0 | 51 | |
|
| 0 | 52 | | Assert.False(string.IsNullOrEmpty(keysWithNewSecondary.SecondaryKey)); |
| 0 | 53 | | Assert.Equal(keysWithNewPrimary.PrimaryKey, keysWithNewSecondary.PrimaryKey); |
| 0 | 54 | | Assert.NotEqual(keysWithNewPrimary.SecondaryKey, keysWithNewSecondary.SecondaryKey); |
| 0 | 55 | | }); |
| 0 | 56 | | } |
| | 57 | | } |
| | 58 | | } |