public async Task GET_taxinfo_by_cuit_with_a_valid_CUIT_should_return_200_OK_when_JWT_token_is_a_valid_Doppler_PROD_one(string host, string expectedUserName, string expectedPassword)
        {
            // Arrange
            var cuit        = "20-31111111-7";
            var expectedUrl = $"http://{host}:33333/api/TaxInfo?ID=20311111117+CardData=Y";

            _httpTest.RespondWithJson(DemoResult);

            using var appFactory = _factory.WithDisabledLifeTimeValidation()
                                   .AddConfiguration(new Dictionary <string, string>()
            {
                ["TaxInfoProvider:UseDummyData"] = "false",
                ["TaxInfoProvider:Host"]         = host,
                ["TaxInfoProvider:UserName"]     = expectedUserName,
                ["TaxInfoProvider:Password"]     = expectedPassword
            });
            appFactory.Server.PreserveExecutionContext = true;
            var client = appFactory.CreateClient();

            var request = new HttpRequestMessage(HttpMethod.Get, $"https://custom.domain.com/taxinfo/by-cuit/{cuit}");

            request.Headers.Authorization = new AuthenticationHeaderValue("Bearer", "eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.eyJuYW1laWQiOjg4NDY5LCJ1bmlxdWVfbmFtZSI6ImFtb3NjaGluaUBtYWtpbmdzZW5zZS5jb20iLCJpc1N1IjpmYWxzZSwic3ViIjoiYW1vc2NoaW5pQG1ha2luZ3NlbnNlLmNvbSIsImN1c3RvbWVySWQiOiIxMzY3IiwiY2RoX2N1c3RvbWVySWQiOiIxMzY3Iiwicm9sZSI6IlVTRVIiLCJpYXQiOjE1OTQxNTUwMjYsImV4cCI6MTU5NDE1NjgyNn0.a4eVqSBptPJk0y9V5Id1yXEzkSroX7j9712W6HOYzb-9irc3pVFQrdWboHcZPLlbpHUdsuoHmFOU-l14N_CjVF9mwjz0Qp9x88JP2KD1x8YtlxUl4BkIneX6ODQ5q_hDeQX-yIUGoU2-cIXzle-JzRssg-XIbaf34fXnUSiUGnQRAuWg3IkmpeLu9fVSbYrY-qW1os1gBSq4NEESz4T87hJblJv3HWNQFJxAtvhG4MLX2ITm8vYNtX39pwI5gdkLY7bNzWmJ1Uphz1hR-sdCdM2oUWKmRmL7txsoD04w5ca7YbdHQGwCI92We4muOs0-N7a4JHYjuDM9lL_TbJGw2w");

            // Act
            var response = await client.SendAsync(request);

            // Assert
            var httpCallAssertion = _httpTest.ShouldHaveMadeACall();

            httpCallAssertion.WithVerb(HttpMethod.Get);
            httpCallAssertion.WithUrlPattern(expectedUrl);
            httpCallAssertion.WithHeader("UserName", expectedUserName);
            httpCallAssertion.WithHeader("Password", expectedPassword);
            Assert.Equal(HttpStatusCode.OK, response.StatusCode);
        }
Exemplo n.º 2
0
        public async Task GET_taxinfo_by_cuit_with_a_valid_CUIT_should_return_200_OK_when_JWT_token_is_a_valid_Doppler_PROD_one(string host, string expectedUserName, string expectedPassword)
        {
            // Arrange
            var cuit        = "20-31111111-7";
            var expectedUrl = $"http://{host}:33333/api/TaxInfo?ID=20311111117+CardData=Y";

            _httpTest.RespondWithJson(DemoResult);

            using var appFactory = _factory.WithDisabledLifeTimeValidation()
                                   .AddConfiguration(new Dictionary <string, string>()
            {
                ["TaxInfoProvider:UseDummyData"] = "false",
                ["TaxInfoProvider:Host"]         = host,
                ["TaxInfoProvider:UserName"]     = expectedUserName,
                ["TaxInfoProvider:Password"]     = expectedPassword
            });
            appFactory.Server.PreserveExecutionContext = true;
            var client = appFactory.CreateClient();

            var request = new HttpRequestMessage(HttpMethod.Get, $"https://custom.domain.com/taxinfo/by-cuit/{cuit}");

            request.Headers.Authorization = new AuthenticationHeaderValue("Bearer", "eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.eyJuYW1laWQiOjg4NDY5LCJ1bmlxdWVfbmFtZSI6ImFtb3NjaGluaUBtYWtpbmdzZW5zZS5jb20iLCJpc1N1IjpmYWxzZSwic3ViIjoiYW1vc2NoaW5pQG1ha2luZ3NlbnNlLmNvbSIsImN1c3RvbWVySWQiOiIxMzY3IiwiY2RoX2N1c3RvbWVySWQiOiIxMzY3Iiwicm9sZSI6IlVTRVIiLCJpYXQiOjE1OTQxNTUwMjYsImV4cCI6MTU5NDE1NjgyNn0.bv-ZHKulKMhBjcftiS-G_xa6MqPd8vmTJLCkitkSzz_lH6OblXnlLSjGAtoViT0yQun_IVqUggdfgY-Qv6cS_YeiYT-EqVLI1KFsFoWtZ7E1Yp5LZuVW70GskwZ7YbV7qlPrOOVBUbt6bD4LtwxudJmIenNBIgIVV-dCTl6vQNXRY65af7Ak1BG8IJxBaPhiFPniMIfNi_6my7NiHtL7Db2eeYgIxXf5_R-8BZFQ0CxWzNDTpdfaB48SnC7n6aEg9FQdOxcu8XX4qPBjGfnvCui2J9s8XgLfRtVQ27WwletL9XnGq79Dyp2PdNUsCcR2d4CMRxvzK1rO2jXSJ9Rf7w");

            // Act
            var response = await client.SendAsync(request);

            // Assert
            var httpCallAssertion = _httpTest.ShouldHaveMadeACall();

            httpCallAssertion.WithVerb(HttpMethod.Get);
            httpCallAssertion.WithUrlPattern(expectedUrl);
            httpCallAssertion.WithHeader("UserName", expectedUserName);
            httpCallAssertion.WithHeader("Password", expectedPassword);
            Assert.Equal(HttpStatusCode.OK, response.StatusCode);
        }
Exemplo n.º 3
0
        public async Task GetInvoices_WhenToken_ReturnsResponse(HttpStatusCode httpStatusCode, string token)
        {
            // Arrange
            const int clientId = 222541;

            _httpTest.RespondWithJson(string.Empty);

            using (var appFactory = _factory.WithDisabledLifeTimeValidation())
            {
                appFactory.AddConfiguration(new Dictionary <string, string>
                {
                    ["Invoice:UseDummyData"] = "true",
                    ["Invoice:Host"]         = "localhost",
                    ["Invoice:UserName"]     = "******",
                    ["Invoice:Password"]     = "******"
                });

                var client = appFactory.CreateClient();

                var request = new HttpRequestMessage(HttpMethod.Get, $"https://localhost/accounts/doppler/{clientId}/invoices");
                request.Headers.Authorization = new AuthenticationHeaderValue("Bearer", token);

                // Act
                var response = await client.SendAsync(request);

                // Assert
                Assert.Equal(httpStatusCode, response.StatusCode);
            }
        }
Exemplo n.º 4
0
        public async Task CreateOrUpdateBusinessPartner_WhenToken_ReturnsResponse(HttpStatusCode httpStatusCode, string token)
        {
            using var appFactory = _factory.WithDisabledLifeTimeValidation();
            var client          = appFactory.CreateClient();
            var businessPartner = new
            {
                BillingCountryCode = "AR",
                FederalTaxID       = "27111111115",
                PlanType           = 1,
                BillingSystemId    = 9,
                FirstName          = "FirstNameTest"
            };

            var requestContent = new StringContent(JsonConvert.SerializeObject(businessPartner), Encoding.UTF8, "application/json");

            var request = new HttpRequestMessage(HttpMethod.Post, $"https://localhost:5001/BusinessPartner/CreateOrUpdateBusinessPartner");

            request.Headers.Authorization = new AuthenticationHeaderValue("Bearer", token);
            request.Content = requestContent;

            // Act
            var response = await client.SendAsync(request);

            // Assert
            Assert.Equal(httpStatusCode, response.StatusCode);
        }
Exemplo n.º 5
0
        public async Task Create_custom_domain_should_response_depending_on_the_authorization_token(HttpStatusCode httpStatusCode, string token)
        {
            // Arrange
            var fixture = new Fixture();

            var domainName          = fixture.Create <string>();
            var domainConfiguration = new
            {
                service  = "relay-tracking",
                ruleType = "HttpsOnly"
            };

            var consulHttpClientMock = new Mock <IConsulHttpClient>();

            consulHttpClientMock.Setup(x => x.PutStringAsync(It.IsAny <string>(), It.IsAny <string>()))
            .Returns(Task.CompletedTask);

            using var appFactory = _factory.WithDisabledLifeTimeValidation();

            var client = appFactory.WithWebHostBuilder((e) => e.ConfigureTestServices(services =>
            {
                services.RemoveAll <IConsulHttpClient>();
                services.AddSingleton(consulHttpClientMock.Object);
            })).CreateClient();

            var request = new HttpRequestMessage(HttpMethod.Put, $"http://localhost/{domainName}");

            request.Content = new StringContent(JsonSerializer.Serialize(domainConfiguration), Encoding.UTF8, "application/json");
            request.Headers.Authorization = new AuthenticationHeaderValue("Bearer", token);

            var response = await client.SendAsync(request);

            Assert.NotNull(response);
            Assert.Equal(httpStatusCode, response.StatusCode);
        }