Example #1
0
        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);
        }
Example #3
0
        /// <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));
        }
Example #4
0
        /// <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);
        }