public SearchServiceFixture() { SearchManagementClient client = TestBase.GetServiceClient <SearchManagementClient>(new CSMTestEnvironmentFactory()); SearchServiceName = SearchTestUtilities.GenerateServiceName(); var createServiceParameters = new SearchServiceCreateOrUpdateParameters() { Location = Location, Properties = new SearchServiceProperties() { Sku = new Sku(SkuType.Free) } }; SearchServiceCreateOrUpdateResponse createServiceResponse = client.Services.CreateOrUpdate(ResourceGroupName, SearchServiceName, createServiceParameters); Assert.Equal(HttpStatusCode.Created, createServiceResponse.StatusCode); AdminKeyResponse adminKeyResponse = client.AdminKeys.List(ResourceGroupName, SearchServiceName); Assert.Equal(HttpStatusCode.OK, adminKeyResponse.StatusCode); PrimaryApiKey = adminKeyResponse.PrimaryKey; ListQueryKeysResponse queryKeyResponse = client.QueryKeys.List(ResourceGroupName, SearchServiceName); Assert.Equal(HttpStatusCode.OK, queryKeyResponse.StatusCode); Assert.Equal(1, queryKeyResponse.QueryKeys.Count); QueryApiKey = queryKeyResponse.QueryKeys[0].Key; }
public void CanListAdminKeys() { Run(() => { SearchManagementClient searchMgmt = GetSearchManagementClient(); // List admin keys AdminKeyResponse adminKeyResponse = searchMgmt.AdminKeys.List(Data.ResourceGroupName, Data.SearchServiceName); Assert.Equal(HttpStatusCode.OK, adminKeyResponse.StatusCode); Assert.NotNull(adminKeyResponse.PrimaryKey); Assert.NotNull(adminKeyResponse.SecondaryKey); Assert.NotEmpty(adminKeyResponse.PrimaryKey); Assert.NotEmpty(adminKeyResponse.SecondaryKey); }); }