示例#1
0
        public async Task ShouldCreateOAuth2ClientCredentialsTokenRequest()
        {
            var httpTest = new HttpTest(new Uri(ServiceUrls.AirtimeAuth))
                           .ExpectMethod(HttpMethod.Post)
                           .ExpectHeader(HeaderNames.Accept, MediaTypeNames.Application.Json)
                           .ExpectRequestBodyField("client_id", CLIENT_ID)
                           .ExpectRequestBodyField("client_secret", CLIENT_SECRET)
                           .ExpectUriPath("oauth/token")
                           .ExpectRequestBodyField("grant_type", GrantType.ClientCredentials)
                           .ResponseBodyFromFile("auth/success_token_response.json");

            var expected = httpTest.ResponseBody <OAuthTokenResponse>();

            var oAuth2Operation = new OAuth2Operation(
                httpTest.HttpClient, AuthenticationApi.BaseUri, CLIENT_ID, CLIENT_SECRET, ReloadlyService.AirtimeSandbox);

            var actual = await oAuth2Operation.GetAccessTokenAsync();

            Verify(expected, actual);
        }