public void GetTokenByCodeRequest_WithTokenNull_ThrowsArgumentNullException() { var requestBuilder = new OAuth2RequestBuilder(); var exception = Record.Exception(() => requestBuilder.GetTokenByCodeRequest("url", null, "clientId", "clientSecret")); Assert.NotNull(exception); Assert.IsType<ArgumentNullException>(exception); var argNullException = (ArgumentNullException) exception; Assert.Equal(argNullException.ParamName, "code"); }
public void GetTokenByCodeRequest_WithClientSecretNull_ThrowsArgumentNullException() { var requestBuilder = new OAuth2RequestBuilder(); var exception = Record.Exception( () => requestBuilder.GetTokenByCodeRequest("https://api.imgur.com/oauth2/token", "123code", "clientId", null)); Assert.NotNull(exception); Assert.IsType<ArgumentNullException>(exception); var argNullException = (ArgumentNullException) exception; Assert.Equal(argNullException.ParamName, "clientSecret"); }
public async Task GetTokenByCodeRequest_WithCodeEqual() { var requestBuilder = new OAuth2RequestBuilder(); var request = requestBuilder.GetTokenByCodeRequest("https://api.imgur.com/oauth2/token", "123code", "123", "1234"); Assert.NotNull(request); Assert.Equal("https://api.imgur.com/oauth2/token", request.RequestUri.ToString()); Assert.Equal(HttpMethod.Post, request.Method); Assert.NotNull(request.Content); var expected = await request.Content.ReadAsStringAsync().ConfigureAwait(false); Assert.Equal("client_id=123&client_secret=1234&grant_type=authorization_code&code=123code", expected); }
public async Task GetTokenByRefreshTokenRequest_WithRefreshTokenEqual() { var requestBuilder = new OAuth2RequestBuilder(); var request = requestBuilder.GetTokenByRefreshTokenRequest("https://api.imgur.com/oauth2/token", "ABChjfhjhjdhfjksdfsdfsdfs", "123", "1234"); Assert.NotNull(request); Assert.Equal("https://api.imgur.com/oauth2/token", request.RequestUri.ToString()); Assert.Equal(HttpMethod.Post, request.Method); Assert.NotNull(request.Content); var expected = await request.Content.ReadAsStringAsync().ConfigureAwait(false); Assert.Equal( "client_id=123&client_secret=1234&grant_type=refresh_token&refresh_token=ABChjfhjhjdhfjksdfsdfsdfs", expected); }
public void GetTokenByRefreshTokenRequest_WithEndpointUrlNull_ThrowsArgumentNullException() { var requestBuilder = new OAuth2RequestBuilder(); var exception = Record.Exception( () => requestBuilder.GetTokenByRefreshTokenRequest(null, "ABChjfhjhjdhfjksdfsdfsdfs", "clientId", "clientSecret")); Assert.NotNull(exception); Assert.IsType<ArgumentNullException>(exception); var argNullException = (ArgumentNullException) exception; Assert.Equal(argNullException.ParamName, "url"); }