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 CanListQueryKeys() { Run(() => { SearchManagementClient searchMgmt = GetSearchManagementClient(); ListQueryKeysResponse queryKeyResponse = searchMgmt.QueryKeys.List(Data.ResourceGroupName, Data.SearchServiceName); Assert.Equal(HttpStatusCode.OK, queryKeyResponse.StatusCode); Assert.Equal(1, queryKeyResponse.QueryKeys.Count); Assert.Null(queryKeyResponse.QueryKeys[0].Name); // Default key has no name. Assert.NotNull(queryKeyResponse.QueryKeys[0].Key); Assert.NotEmpty(queryKeyResponse.QueryKeys[0].Key); }); }