/// <summary> /// Creates new authorization server or updates an existing authorization /// server. /// </summary> /// <param name='operations'> /// The operations group for this extension method. /// </param> /// <param name='resourceGroupName'> /// The name of the resource group. /// </param> /// <param name='serviceName'> /// The name of the API Management service. /// </param> /// <param name='authsid'> /// Identifier of the authorization server. /// </param> /// <param name='parameters'> /// Create or update parameters. /// </param> /// <param name='ifMatch'> /// ETag of the Entity. Not required when creating an entity, but required when /// updating an entity. /// </param> /// <param name='cancellationToken'> /// The cancellation token. /// </param> public static async Task <AuthorizationServerContract> CreateOrUpdateAsync(this IAuthorizationServerOperations operations, string resourceGroupName, string serviceName, string authsid, AuthorizationServerContract parameters, string ifMatch = default(string), CancellationToken cancellationToken = default(CancellationToken)) { using (var _result = await operations.CreateOrUpdateWithHttpMessagesAsync(resourceGroupName, serviceName, authsid, parameters, ifMatch, null, cancellationToken).ConfigureAwait(false)) { return(_result.Body); } }
/// <summary> /// Creates new authorization server or updates an existing authorization /// server. /// </summary> /// <param name='operations'> /// The operations group for this extension method. /// </param> /// <param name='resourceGroupName'> /// The name of the resource group. /// </param> /// <param name='serviceName'> /// The name of the API Management service. /// </param> /// <param name='authsid'> /// Identifier of the authorization server. /// </param> /// <param name='parameters'> /// Create or update parameters. /// </param> /// <param name='ifMatch'> /// ETag of the Entity. Not required when creating an entity, but required when /// updating an entity. /// </param> public static AuthorizationServerContract CreateOrUpdate(this IAuthorizationServerOperations operations, string resourceGroupName, string serviceName, string authsid, AuthorizationServerContract parameters, string ifMatch = default(string)) { return(operations.CreateOrUpdateAsync(resourceGroupName, serviceName, authsid, parameters, ifMatch).GetAwaiter().GetResult()); }
public async Task CreateListUpdateDelete() { Environment.SetEnvironmentVariable("AZURE_TEST_MODE", "Playback"); using (MockContext context = MockContext.Start(this.GetType().FullName)) { var testBase = new ApiManagementTestBase(context); testBase.TryCreateApiManagementService(); // list all the APIs var listResponse = testBase.client.Api.ListByService( testBase.rgName, testBase.serviceName, null); Assert.NotNull(listResponse); Assert.Single(listResponse); Assert.Null(listResponse.NextPageLink); var echoApi = listResponse.First(); Assert.Equal("Echo API", echoApi.DisplayName); Assert.Null(echoApi.Description); Assert.Equal("http://echoapi.cloudapp.net/api", echoApi.ServiceUrl); Assert.Equal("echo", echoApi.Path); Assert.NotNull(echoApi.Protocols); Assert.Equal(1, echoApi.Protocols.Count); Assert.Equal(Protocol.Https, echoApi.Protocols[0]); // get the API by id var getResponse = await testBase.client.Api.GetWithHttpMessagesAsync( testBase.rgName, testBase.serviceName, echoApi.Name); Assert.NotNull(getResponse); Assert.Equal("Echo API", getResponse.Body.DisplayName); Assert.Null(getResponse.Body.Description); Assert.Equal("http://echoapi.cloudapp.net/api", getResponse.Body.ServiceUrl); Assert.Equal("echo", getResponse.Body.Path); Assert.NotNull(getResponse.Body.Protocols); Assert.Equal(1, getResponse.Body.Protocols.Count); Assert.Equal(Protocol.Https, getResponse.Body.Protocols[0]); // add new api // create autorization server string newApiAuthorizationServerId = TestUtilities.GenerateName("authorizationServerId"); string newApiId = TestUtilities.GenerateName("apiid"); string newOpenApiId = TestUtilities.GenerateName("openApiid"); string openIdNoSecret = TestUtilities.GenerateName("openId"); try { var createAuthServerParams = new AuthorizationServerContract { DisplayName = TestUtilities.GenerateName("authName"), DefaultScope = TestUtilities.GenerateName("oauth2scope"), AuthorizationEndpoint = "https://contoso.com/auth", TokenEndpoint = "https://contoso.com/token", ClientRegistrationEndpoint = "https://contoso.com/clients/reg", GrantTypes = new List <string> { GrantType.AuthorizationCode, GrantType.Implicit }, AuthorizationMethods = new List <AuthorizationMethod?> { AuthorizationMethod.POST, AuthorizationMethod.GET }, BearerTokenSendingMethods = new List <string> { BearerTokenSendingMethod.AuthorizationHeader, BearerTokenSendingMethod.Query }, ClientId = TestUtilities.GenerateName("clientid") }; testBase.client.AuthorizationServer.CreateOrUpdate( testBase.rgName, testBase.serviceName, newApiAuthorizationServerId, createAuthServerParams); string newApiName = TestUtilities.GenerateName("apiname"); string newApiDescription = TestUtilities.GenerateName("apidescription"); string newApiPath = "newapiPath"; string newApiServiceUrl = "http://newechoapi.cloudapp.net/api"; string subscriptionKeyParametersHeader = TestUtilities.GenerateName("header"); string subscriptionKeyQueryStringParamName = TestUtilities.GenerateName("query"); string newApiAuthorizationScope = TestUtilities.GenerateName("oauth2scope"); var newApiAuthenticationSettings = new AuthenticationSettingsContract { OAuth2 = new OAuth2AuthenticationSettingsContract { AuthorizationServerId = newApiAuthorizationServerId, Scope = newApiAuthorizationScope } }; var createdApiContract = testBase.client.Api.CreateOrUpdate( testBase.rgName, testBase.serviceName, newApiId, new ApiCreateOrUpdateParameter { DisplayName = newApiName, Description = newApiDescription, Path = newApiPath, ServiceUrl = newApiServiceUrl, Protocols = new List <Protocol?> { Protocol.Https, Protocol.Http }, SubscriptionKeyParameterNames = new SubscriptionKeyParameterNamesContract { Header = subscriptionKeyParametersHeader, Query = subscriptionKeyQueryStringParamName }, AuthenticationSettings = newApiAuthenticationSettings }); // get new api to check it was added var apiGetResponse = testBase.client.Api.Get(testBase.rgName, testBase.serviceName, newApiId); Assert.NotNull(apiGetResponse); Assert.Equal(newApiId, apiGetResponse.Name); Assert.Equal(newApiName, apiGetResponse.DisplayName); Assert.Equal(newApiDescription, apiGetResponse.Description); Assert.Equal(newApiPath, apiGetResponse.Path); Assert.Equal(newApiServiceUrl, apiGetResponse.ServiceUrl); Assert.Equal(subscriptionKeyParametersHeader, apiGetResponse.SubscriptionKeyParameterNames.Header); Assert.Equal(subscriptionKeyQueryStringParamName, apiGetResponse.SubscriptionKeyParameterNames.Query); Assert.Equal(2, apiGetResponse.Protocols.Count); Assert.True(apiGetResponse.Protocols.Contains(Protocol.Http)); Assert.True(apiGetResponse.Protocols.Contains(Protocol.Https)); Assert.NotNull(apiGetResponse.AuthenticationSettings); Assert.NotNull(apiGetResponse.AuthenticationSettings.OAuth2); Assert.Equal(newApiAuthorizationServerId, apiGetResponse.AuthenticationSettings.OAuth2.AuthorizationServerId); // get the API Entity Tag ApiGetEntityTagHeaders apiTag = testBase.client.Api.GetEntityTag( testBase.rgName, testBase.serviceName, newApiId); Assert.NotNull(apiTag); Assert.NotNull(apiTag.ETag); // patch added api string patchedName = TestUtilities.GenerateName("patchedname"); string patchedDescription = TestUtilities.GenerateName("patchedDescription"); string patchedPath = TestUtilities.GenerateName("patchedPath"); testBase.client.Api.Update( testBase.rgName, testBase.serviceName, newApiId, new ApiUpdateContract { DisplayName = patchedName, Description = patchedDescription, Path = patchedPath, AuthenticationSettings = new AuthenticationSettingsContract { OAuth2 = null } }, apiTag.ETag); // get patched api to check it was patched apiGetResponse = testBase.client.Api.Get(testBase.rgName, testBase.serviceName, newApiId); Assert.NotNull(apiGetResponse); Assert.Equal(newApiId, apiGetResponse.Name); Assert.Equal(patchedName, apiGetResponse.DisplayName); Assert.Equal(patchedDescription, apiGetResponse.Description); Assert.Equal(patchedPath, apiGetResponse.Path); Assert.Equal(newApiServiceUrl, apiGetResponse.ServiceUrl); Assert.Equal(subscriptionKeyParametersHeader, apiGetResponse.SubscriptionKeyParameterNames.Header); Assert.Equal(subscriptionKeyQueryStringParamName, apiGetResponse.SubscriptionKeyParameterNames.Query); Assert.Equal(2, apiGetResponse.Protocols.Count); Assert.True(apiGetResponse.Protocols.Contains(Protocol.Http)); Assert.True(apiGetResponse.Protocols.Contains(Protocol.Https)); // add an api with OpenId authentication settings // create a openId connect provider string openIdProviderName = TestUtilities.GenerateName("openIdName"); string metadataEndpoint = testBase.GetOpenIdMetadataEndpointUrl(); string clientId = TestUtilities.GenerateName("clientId"); var openIdConnectCreateParameters = new OpenidConnectProviderContract(openIdProviderName, metadataEndpoint, clientId); var openIdCreateResponse = testBase.client.OpenIdConnectProvider.CreateOrUpdate( testBase.rgName, testBase.serviceName, openIdNoSecret, openIdConnectCreateParameters); Assert.NotNull(openIdCreateResponse); Assert.Equal(openIdProviderName, openIdCreateResponse.DisplayName); Assert.Equal(openIdNoSecret, openIdCreateResponse.Name); string newOpenIdApiName = TestUtilities.GenerateName("apiname"); string newOpenIdApiDescription = TestUtilities.GenerateName("apidescription"); string newOpenIdApiPath = "newOpenapiPath"; string newOpenIdApiServiceUrl = "http://newechoapi2.cloudapp.net/api"; string newOpenIdAuthorizationScope = TestUtilities.GenerateName("oauth2scope"); var newnewOpenIdAuthenticationSettings = new AuthenticationSettingsContract { Openid = new OpenIdAuthenticationSettingsContract { OpenidProviderId = openIdCreateResponse.Name, BearerTokenSendingMethods = new[] { BearerTokenSendingMethods.AuthorizationHeader } } }; var createdOpenApiIdContract = testBase.client.Api.CreateOrUpdate( testBase.rgName, testBase.serviceName, newOpenApiId, new ApiCreateOrUpdateParameter { DisplayName = newOpenIdApiName, Description = newOpenIdApiDescription, Path = newOpenIdApiPath, ServiceUrl = newOpenIdApiServiceUrl, Protocols = new List <Protocol?> { Protocol.Https, Protocol.Http }, SubscriptionKeyParameterNames = new SubscriptionKeyParameterNamesContract { Header = subscriptionKeyParametersHeader, Query = subscriptionKeyQueryStringParamName }, AuthenticationSettings = newnewOpenIdAuthenticationSettings }); // get new api to check it was added var openApiGetResponse = testBase.client.Api.Get(testBase.rgName, testBase.serviceName, newOpenApiId); Assert.NotNull(openApiGetResponse); Assert.Equal(newOpenApiId, openApiGetResponse.Name); Assert.Equal(newOpenIdApiName, openApiGetResponse.DisplayName); Assert.Equal(newOpenIdApiDescription, openApiGetResponse.Description); Assert.Equal(newOpenIdApiPath, openApiGetResponse.Path); Assert.Equal(newOpenIdApiServiceUrl, openApiGetResponse.ServiceUrl); Assert.Equal(subscriptionKeyParametersHeader, openApiGetResponse.SubscriptionKeyParameterNames.Header); Assert.Equal(subscriptionKeyQueryStringParamName, openApiGetResponse.SubscriptionKeyParameterNames.Query); Assert.Equal(2, openApiGetResponse.Protocols.Count); Assert.True(openApiGetResponse.Protocols.Contains(Protocol.Http)); Assert.True(openApiGetResponse.Protocols.Contains(Protocol.Https)); Assert.NotNull(openApiGetResponse.AuthenticationSettings.Openid); Assert.Equal(openIdCreateResponse.Name, openApiGetResponse.AuthenticationSettings.Openid.OpenidProviderId); // list with paging listResponse = testBase.client.Api.ListByService( testBase.rgName, testBase.serviceName, new Microsoft.Rest.Azure.OData.ODataQuery <ApiContract> { Top = 1 }); Assert.NotNull(listResponse); Assert.Single(listResponse); Assert.NotNull(listResponse.NextPageLink); listResponse = testBase.client.Api.ListByServiceNext(listResponse.NextPageLink); Assert.NotNull(listResponse); Assert.Single(listResponse); Assert.NotNull(listResponse.NextPageLink); // delete the api testBase.client.Api.Delete( testBase.rgName, testBase.serviceName, newApiId, "*"); // get the deleted api to make sure it was deleted try { testBase.client.Api.Get(testBase.rgName, testBase.serviceName, newApiId); throw new Exception("This code should not have been executed."); } catch (ErrorResponseException ex) { Assert.Equal(HttpStatusCode.NotFound, ex.Response.StatusCode); } // delete the api testBase.client.Api.Delete( testBase.rgName, testBase.serviceName, newOpenApiId, "*"); // get the deleted api to make sure it was deleted try { testBase.client.Api.Get(testBase.rgName, testBase.serviceName, newOpenApiId); throw new Exception("This code should not have been executed."); } catch (ErrorResponseException ex) { Assert.Equal(HttpStatusCode.NotFound, ex.Response.StatusCode); } } finally { // delete api server testBase.client.Api.Delete( testBase.rgName, testBase.serviceName, newApiId, "*"); testBase.client.AuthorizationServer.Delete( testBase.rgName, testBase.serviceName, newApiAuthorizationServerId, "*"); // delete api server testBase.client.Api.Delete( testBase.rgName, testBase.serviceName, newOpenApiId, "*"); testBase.client.OpenIdConnectProvider.Delete( testBase.rgName, testBase.serviceName, openIdNoSecret, "*"); } } }
public async Task CloneApiUsingSourceApiId() { Environment.SetEnvironmentVariable("AZURE_TEST_MODE", "Playback"); using (MockContext context = MockContext.Start(this.GetType().FullName)) { var testBase = new ApiManagementTestBase(context); testBase.TryCreateApiManagementService(); // add new api const string swaggerPath = "./Resources/SwaggerPetStoreV2.json"; const string path = "swaggerApi"; string newApiAuthorizationServerId = TestUtilities.GenerateName("authorizationServerId"); string newApiId = TestUtilities.GenerateName("apiid"); string swaggerApiId = TestUtilities.GenerateName("swaggerApiId"); try { // import API string swaggerApiContent; using (StreamReader reader = File.OpenText(swaggerPath)) { swaggerApiContent = reader.ReadToEnd(); } var apiCreateOrUpdate = new ApiCreateOrUpdateParameter() { Path = path, Format = ContentFormat.SwaggerJson, Value = swaggerApiContent }; var swaggerApiResponse = testBase.client.Api.CreateOrUpdate( testBase.rgName, testBase.serviceName, swaggerApiId, apiCreateOrUpdate); Assert.NotNull(swaggerApiResponse); Assert.Null(swaggerApiResponse.SubscriptionRequired); Assert.Equal(path, swaggerApiResponse.Path); var swagerApiOperations = await testBase.client.ApiOperation.ListByApiAsync( testBase.rgName, testBase.serviceName, swaggerApiResponse.Name); var createAuthServerParams = new AuthorizationServerContract { DisplayName = TestUtilities.GenerateName("authName"), DefaultScope = TestUtilities.GenerateName("oauth2scope"), AuthorizationEndpoint = "https://contoso.com/auth", TokenEndpoint = "https://contoso.com/token", ClientRegistrationEndpoint = "https://contoso.com/clients/reg", GrantTypes = new List <string> { GrantType.AuthorizationCode, GrantType.Implicit }, AuthorizationMethods = new List <AuthorizationMethod?> { AuthorizationMethod.POST, AuthorizationMethod.GET }, BearerTokenSendingMethods = new List <string> { BearerTokenSendingMethod.AuthorizationHeader, BearerTokenSendingMethod.Query }, ClientId = TestUtilities.GenerateName("clientid") }; await testBase.client.AuthorizationServer.CreateOrUpdateAsync( testBase.rgName, testBase.serviceName, newApiAuthorizationServerId, createAuthServerParams); string newApiName = TestUtilities.GenerateName("apiname"); string newApiDescription = TestUtilities.GenerateName("apidescription"); string newApiPath = "newapiPath"; string newApiServiceUrl = "http://newechoapi.cloudapp.net/api"; string subscriptionKeyParametersHeader = TestUtilities.GenerateName("header"); string subscriptionKeyQueryStringParamName = TestUtilities.GenerateName("query"); string newApiAuthorizationScope = TestUtilities.GenerateName("oauth2scope"); var newApiAuthenticationSettings = new AuthenticationSettingsContract { OAuth2 = new OAuth2AuthenticationSettingsContract { AuthorizationServerId = newApiAuthorizationServerId, Scope = newApiAuthorizationScope } }; var createdApiContract = testBase.client.Api.CreateOrUpdate( testBase.rgName, testBase.serviceName, newApiId, new ApiCreateOrUpdateParameter { SourceApiId = swaggerApiResponse.Id, // create a clone of the Swagger API created above and override the following parameters DisplayName = newApiName, Description = newApiDescription, Path = newApiPath, ServiceUrl = newApiServiceUrl, Protocols = new List <Protocol?> { Protocol.Https, Protocol.Http }, SubscriptionKeyParameterNames = new SubscriptionKeyParameterNamesContract { Header = subscriptionKeyParametersHeader, Query = subscriptionKeyQueryStringParamName }, AuthenticationSettings = newApiAuthenticationSettings, SubscriptionRequired = true, }); // get new api to check it was added var apiGetResponse = testBase.client.Api.Get(testBase.rgName, testBase.serviceName, newApiId); Assert.NotNull(apiGetResponse); Assert.Equal(newApiId, apiGetResponse.Name); Assert.Equal(newApiName, apiGetResponse.DisplayName); Assert.Equal(newApiDescription, apiGetResponse.Description); Assert.Equal(newApiPath, apiGetResponse.Path); Assert.Equal(newApiServiceUrl, apiGetResponse.ServiceUrl); Assert.Equal(subscriptionKeyParametersHeader, apiGetResponse.SubscriptionKeyParameterNames.Header); Assert.Equal(subscriptionKeyQueryStringParamName, apiGetResponse.SubscriptionKeyParameterNames.Query); Assert.Equal(2, apiGetResponse.Protocols.Count); Assert.True(apiGetResponse.Protocols.Contains(Protocol.Http)); Assert.True(apiGetResponse.Protocols.Contains(Protocol.Https)); Assert.NotNull(apiGetResponse.AuthenticationSettings); Assert.NotNull(apiGetResponse.AuthenticationSettings.OAuth2); Assert.Equal(newApiAuthorizationServerId, apiGetResponse.AuthenticationSettings.OAuth2.AuthorizationServerId); Assert.True(apiGetResponse.SubscriptionRequired); var newApiOperations = await testBase.client.ApiOperation.ListByApiAsync( testBase.rgName, testBase.serviceName, newApiId); Assert.NotNull(newApiOperations); // make sure all operations got copied Assert.Equal(swagerApiOperations.Count(), newApiOperations.Count()); } finally { // delete api server testBase.client.Api.Delete( testBase.rgName, testBase.serviceName, swaggerApiId, "*"); // delete api server testBase.client.Api.Delete( testBase.rgName, testBase.serviceName, newApiId, "*"); testBase.client.AuthorizationServer.Delete( testBase.rgName, testBase.serviceName, newApiAuthorizationServerId, "*"); } } }
public async Task CreateListUpdateDelete() { Environment.SetEnvironmentVariable("AZURE_TEST_MODE", "Playback"); using (MockContext context = MockContext.Start(this.GetType())) { var testBase = new ApiManagementTestBase(context); testBase.TryCreateApiManagementService(); // list all server var listResponse = testBase.client.AuthorizationServer.ListByService( testBase.rgName, testBase.serviceName, null); Assert.NotNull(listResponse); Assert.Empty(listResponse); // create server string authsid = TestUtilities.GenerateName("authsid"); try { var authorizationServerContract = new AuthorizationServerContract { DisplayName = TestUtilities.GenerateName("authName"), DefaultScope = TestUtilities.GenerateName("oauth2scope"), AuthorizationEndpoint = "https://contoso.com/auth", TokenEndpoint = "https://contoso.com/token", ClientRegistrationEndpoint = "https://contoso.com/clients/reg", GrantTypes = new List <string> { GrantType.AuthorizationCode, GrantType.Implicit, GrantType.ResourceOwnerPassword }, AuthorizationMethods = new List <AuthorizationMethod?> { AuthorizationMethod.POST, AuthorizationMethod.GET }, BearerTokenSendingMethods = new List <string> { BearerTokenSendingMethod.AuthorizationHeader, BearerTokenSendingMethod.Query }, ClientId = TestUtilities.GenerateName("clientid"), Description = TestUtilities.GenerateName("authdescription"), ClientAuthenticationMethod = new List <string> { ClientAuthenticationMethod.Basic }, ClientSecret = TestUtilities.GenerateName("authclientsecret"), ResourceOwnerPassword = TestUtilities.GenerateName("authresourceownerpwd"), ResourceOwnerUsername = TestUtilities.GenerateName("authresourceownerusername"), SupportState = true, TokenBodyParameters = new[] { new TokenBodyParameterContract { Name = TestUtilities.GenerateName("tokenname"), Value = TestUtilities.GenerateName("tokenvalue") } } }; var createResponse = testBase.client.AuthorizationServer.CreateOrUpdate( testBase.rgName, testBase.serviceName, authsid, authorizationServerContract); Assert.NotNull(createResponse); // get to check is was created var getResponse = await testBase.client.AuthorizationServer.GetWithHttpMessagesAsync( testBase.rgName, testBase.serviceName, authsid); Assert.NotNull(getResponse); Assert.NotNull(getResponse.Headers.ETag); Assert.NotNull(getResponse.Body); Assert.Equal(authsid, getResponse.Body.Name); Assert.Equal(authorizationServerContract.DisplayName, getResponse.Body.DisplayName); Assert.Equal(authorizationServerContract.Description, getResponse.Body.Description); Assert.Equal(authorizationServerContract.DefaultScope, getResponse.Body.DefaultScope); Assert.Equal(authorizationServerContract.AuthorizationEndpoint, getResponse.Body.AuthorizationEndpoint); Assert.Equal(authorizationServerContract.TokenEndpoint, getResponse.Body.TokenEndpoint); Assert.Equal(authorizationServerContract.ClientId, getResponse.Body.ClientId); Assert.Equal(authorizationServerContract.ClientRegistrationEndpoint, getResponse.Body.ClientRegistrationEndpoint); Assert.Equal(authorizationServerContract.ClientSecret, getResponse.Body.ClientSecret); Assert.Equal(authorizationServerContract.ResourceOwnerPassword, getResponse.Body.ResourceOwnerPassword); Assert.Equal(authorizationServerContract.ResourceOwnerUsername, getResponse.Body.ResourceOwnerUsername); Assert.Equal(authorizationServerContract.GrantTypes.Count, getResponse.Body.GrantTypes.Count); Assert.True(getResponse.Body.GrantTypes.All(gt => authorizationServerContract.GrantTypes.Contains(gt))); Assert.Equal(authorizationServerContract.AuthorizationMethods.Count, getResponse.Body.AuthorizationMethods.Count); Assert.True(getResponse.Body.AuthorizationMethods.All(gt => authorizationServerContract.AuthorizationMethods.Contains(gt))); Assert.Equal(authorizationServerContract.ClientAuthenticationMethod.Count, getResponse.Body.ClientAuthenticationMethod.Count); Assert.True(getResponse.Body.ClientAuthenticationMethod.All(gt => authorizationServerContract.ClientAuthenticationMethod.Contains(gt))); Assert.Equal(authorizationServerContract.SupportState, getResponse.Body.SupportState); Assert.Equal(authorizationServerContract.TokenBodyParameters.Count, getResponse.Body.TokenBodyParameters.Count); Assert.True(getResponse.Body.TokenBodyParameters.All(p => authorizationServerContract.TokenBodyParameters.Any(p1 => p1.Name.Equals(p.Name, StringComparison.OrdinalIgnoreCase) && p1.Value.Equals(p.Value, StringComparison.OrdinalIgnoreCase)))); // list again listResponse = testBase.client.AuthorizationServer.ListByService( testBase.rgName, testBase.serviceName, null); Assert.NotNull(listResponse); Assert.Single(listResponse); // update var updateParameters = new AuthorizationServerUpdateContract { GrantTypes = new List <string> { GrantType.AuthorizationCode, GrantType.ResourceOwnerPassword } }; testBase.client.AuthorizationServer.Update( testBase.rgName, testBase.serviceName, authsid, updateParameters, getResponse.Headers.ETag); // get to check is was updated getResponse = await testBase.client.AuthorizationServer.GetWithHttpMessagesAsync( testBase.rgName, testBase.serviceName, authsid); Assert.NotNull(getResponse); Assert.NotNull(getResponse.Headers.ETag); Assert.NotNull(getResponse.Body); Assert.Equal(authsid, getResponse.Body.Name); Assert.Equal(authorizationServerContract.DisplayName, getResponse.Body.DisplayName); Assert.Equal(authorizationServerContract.Description, getResponse.Body.Description); Assert.Equal(authorizationServerContract.DefaultScope, getResponse.Body.DefaultScope); Assert.Equal(authorizationServerContract.AuthorizationEndpoint, getResponse.Body.AuthorizationEndpoint); Assert.Equal(authorizationServerContract.TokenEndpoint, getResponse.Body.TokenEndpoint); Assert.Equal(authorizationServerContract.ClientId, getResponse.Body.ClientId); Assert.Equal(authorizationServerContract.ClientRegistrationEndpoint, getResponse.Body.ClientRegistrationEndpoint); Assert.Equal(authorizationServerContract.ClientSecret, getResponse.Body.ClientSecret); Assert.Equal(authorizationServerContract.ResourceOwnerPassword, getResponse.Body.ResourceOwnerPassword); Assert.Equal(authorizationServerContract.ResourceOwnerUsername, getResponse.Body.ResourceOwnerUsername); Assert.Equal(updateParameters.GrantTypes.Count, getResponse.Body.GrantTypes.Count); Assert.True(getResponse.Body.GrantTypes.All(gt => updateParameters.GrantTypes.Contains(gt))); Assert.Equal(authorizationServerContract.AuthorizationMethods.Count, getResponse.Body.AuthorizationMethods.Count); Assert.True(getResponse.Body.AuthorizationMethods.All(gt => authorizationServerContract.AuthorizationMethods.Contains(gt))); Assert.Equal(authorizationServerContract.ClientAuthenticationMethod.Count, getResponse.Body.ClientAuthenticationMethod.Count); Assert.True(getResponse.Body.ClientAuthenticationMethod.All(gt => authorizationServerContract.ClientAuthenticationMethod.Contains(gt))); Assert.Equal(authorizationServerContract.SupportState, getResponse.Body.SupportState); Assert.Equal(authorizationServerContract.TokenBodyParameters.Count, getResponse.Body.TokenBodyParameters.Count); Assert.True(getResponse.Body.TokenBodyParameters.All(p => authorizationServerContract.TokenBodyParameters.Any(p1 => p1.Name.Equals(p.Name, StringComparison.OrdinalIgnoreCase) && p1.Value.Equals(p.Value, StringComparison.OrdinalIgnoreCase)))); // delete testBase.client.AuthorizationServer.Delete( testBase.rgName, testBase.serviceName, authsid, getResponse.Headers.ETag); // get to check is was deleted try { testBase.client.AuthorizationServer.Get( testBase.rgName, testBase.serviceName, authsid); throw new Exception("This code should not have been executed."); } catch (ErrorResponseException ex) { Assert.Equal((int)HttpStatusCode.NotFound, (int)ex.Response.StatusCode); } } finally { // delete testBase.client.AuthorizationServer.Delete( testBase.rgName, testBase.serviceName, authsid, "*"); } } }