示例#1
0
        public void UsernamePasswordLoginFail()
        {
            AuthInfo authInfo = forceClientFixture.AuthInfo;

            AuthenticationClient auth = new AuthenticationClient();

            ForceAuthException ex = Assert.Throws <ForceAuthException>(() =>
                                                                       auth.UsernamePassword(authInfo.ClientId, authInfo.ClientSecret, authInfo.Username, "badpassword", authInfo.TokenRequestEndpoint)
                                                                       );

            Assert.Equal("invalid_grant", ex.ErrorCode);
            Assert.Equal("authentication failure", ex.Message);
        }
示例#2
0
        public async Task UsernamePasswordLoginFail()
        {
            AuthInfo authInfo = forceClientFixture.AuthInfo;

            AuthenticationClient auth = new AuthenticationClient();

            // try
            // {
            //     await auth.UsernamePasswordAsync(authInfo.ClientId, authInfo.ClientSecret,
            //         authInfo.Username, "badpassword", authInfo.TokenRequestEndpoint);
            // }
            // catch (ForceAuthException ex)
            // {
            //     Assert.Equal("invalid_grant", ex.ErrorCode);
            //     Assert.Equal("authentication failure", ex.Message);
            // }

            ForceAuthException ex = await Assert.ThrowsAsync <ForceAuthException>(
                async() => await auth.UsernamePasswordAsync(authInfo.ClientId, authInfo.ClientSecret, authInfo.Username, "badpassword", authInfo.TokenRequestEndpoint)
                );

            Assert.Equal("invalid_grant", ex.ErrorCode);
            Assert.Equal("authentication failure", ex.Message);
        }