public async Task FailsWhenNotAuthenticated() { var github = new GitHubClient(new ProductHeaderValue("OctokitTests")); var userUpdate = new UserUpdate { Name = Helper.Credentials.Login, Bio = "UPDATED BIO" }; var e = await AssertEx.Throws<AuthorizationException>(async () => await github.User.Update(userUpdate)); Assert.Equal(HttpStatusCode.Unauthorized, e.StatusCode); }
public async Task FailsWhenNotAuthenticated() { var github = Helper.GetAnonymousClient(); var userUpdate = new UserUpdate { Name = Helper.Credentials.Login, Bio = "UPDATED BIO" }; var e = await Assert.ThrowsAsync<AuthorizationException>(() => github.User.Update(userUpdate)); Assert.Equal(HttpStatusCode.Unauthorized, e.StatusCode); }
/// <summary> /// Update the specified <see cref="UserUpdate"/>. /// </summary> /// <param name="user">The login for the user</param> /// <exception cref="AuthorizationException">Thrown if the client is not authenticated.</exception> /// <returns>A <see cref="User"/></returns> public Task <User> Update(UserUpdate user) { Ensure.ArgumentNotNull(user, "user"); return(ApiConnection.Patch <User>(_userEndpoint, user)); }
/// <summary> /// Update the specified <see cref="UserUpdate"/>. /// </summary> /// <param name="user">The login for the user</param> /// <exception cref="AuthorizationException">Thrown if the client is not authenticated.</exception> /// <returns>A <see cref="User"/></returns> public Task<User> Update(UserUpdate user) { Ensure.ArgumentNotNull(user, "user"); return ApiConnection.Patch<User>(_userEndpoint, user); }
public async Task FailsWhenAuthenticatedWithBadCredentials() { var github = Helper.GetBadCredentialsClient(); var userUpdate = new UserUpdate { Name = Helper.Credentials.Login, Bio = "UPDATED BIO" }; var e = await AssertEx.Throws<AuthorizationException>(async () => await github.User.Update(userUpdate)); Assert.Equal(HttpStatusCode.Unauthorized, e.StatusCode); }