public void BadClientId()
        {
            var authenticator = new PasswordFlowAuthenticator("x", SalesforceConfig.ClientSecret,
                                                              SalesforceConfig.Username, SalesforceConfig.Password, SalesforceConfig.AuthEndpoint, _httpClient);

            var ex = Assert.Throws <AuthenticationException>(() => authenticator.GetAuthInfo());

            Assert.Equal("invalid_client_id: client identifier invalid", ex.Message);
        }
        public void BadPassword()
        {
            var authenticator = new PasswordFlowAuthenticator(SalesforceConfig.ClientId, SalesforceConfig.ClientSecret,
                                                              SalesforceConfig.Username, "x", SalesforceConfig.AuthEndpoint, _httpClient);

            var ex = Assert.Throws <AuthenticationException>(() => authenticator.GetAuthInfo());

            Assert.Equal("invalid_grant: authentication failure", ex.Message);
        }
        public void BadAuthEndpoint()
        {
            var authenticator = new PasswordFlowAuthenticator(SalesforceConfig.ClientId, SalesforceConfig.ClientSecret,
                                                              SalesforceConfig.Username, SalesforceConfig.Password, SalesforceConfig.AuthEndpoint + "x",
                                                              _httpClient);

            var ex = Assert.Throws <AuthenticationException>(() => authenticator.GetAuthInfo());

            Assert.StartsWith("An error occured authenticating, see inner exception:", ex.Message);
        }
        public void GoodLogin()
        {
            var authenticator = new PasswordFlowAuthenticator(SalesforceConfig.ClientId, SalesforceConfig.ClientSecret,
                                                              SalesforceConfig.Username, SalesforceConfig.Password, SalesforceConfig.AuthEndpoint, _httpClient);

            var authResult = authenticator.GetAuthInfo();

            Assert.True(Uri.IsWellFormedUriString(authResult.Url, UriKind.Absolute));
            Assert.False(string.IsNullOrWhiteSpace(authResult.Url));
        }
Пример #5
0
        public static void Main()
        {
            using (var httpClient = new HttpClient())
            {
                var authenticator =
                    new PasswordFlowAuthenticator(ClientId, ClientSecret, Username, Password, AuthEndpoint, httpClient);

                var dataApi    = new DataApi(authenticator, httpClient, 44);
                var toolingApi = new ToolingApi(authenticator, httpClient, 44);
                var customApi  = new CustomApi(authenticator, httpClient);

                new DataApiSample(dataApi).RunAsync().GetAwaiter().GetResult();
                new ToolingApiSample(toolingApi).RunAsync().GetAwaiter().GetResult();
                new CustomApiSample(customApi).RunAsync().GetAwaiter().GetResult();
            }
        }