public async Task WhenIRequestAClientTokenWithTheFollowingValues(Table table)
        {
            table.Rows.Count.ShouldBe(1);

            String clientId     = table.Rows[0]["ClientId"];
            String clientSecret = table.Rows[0]["ClientSecret"];

            TokenResponse tokenResponse = await this.TestingContext.DockerHelper.SecurityServiceClient.GetToken(clientId, clientSecret, CancellationToken.None);

            tokenResponse.ShouldNotBeNull();

            this.TestingContext.TokenResponse = tokenResponse;
        }
Example #2
0
        void when_post_tokens()
        {
            context["given a card token request"] = () =>
            {
                context["that is valid"] = () =>
                {
                    beforeAllAsync = async() =>
                    {
                        tokenRequest = new CardTokenRequest(number: "4242424242424242", expiryMonth: 12, expiryYear: 2022);
                        result       = await controller.RequestCardToken(tokenRequest);

                        token = (result as ObjectResult).Value as TokenResponse;
                    };

                    it["should return 201 - Created"] = () =>
                    {
                        (result as CreatedAtActionResult).StatusCode.ShouldBe(StatusCodes.Status201Created);
                    };

                    context["with token that"] = () =>
                    {
                        it["should not be null"] = () =>
                        {
                            token.ShouldNotBeNull();
                        };

                        it["should expire in 15m"] = () =>
                        {
                            var expiration = (token as CardTokenResponse).ExpiresOn;
                            var now        = DateTime.UtcNow;
                            (expiration - now).Minutes.ShouldBeLessThanOrEqualTo(15);
                        };

                        it["should match type of request"] = () =>
                        {
                            token.Type.ShouldBe(tokenRequest.Type);
                        };

                        it["should match expiry month of request"] = () =>
                        {
                            (token as CardTokenResponse).ExpiryMonth.ShouldBe((tokenRequest as CardTokenRequest).ExpiryMonth);
                        };

                        it["should match expiry year of request"] = () =>
                        {
                            (token as CardTokenResponse).ExpiryYear.ShouldBe((tokenRequest as CardTokenRequest).ExpiryYear);
                        };

                        it["should match last4 digits of request number"] = () =>
                        {
                            (tokenRequest as CardTokenRequest).Number.ShouldEndWith((token as CardTokenResponse).Last4);
                        };

                        it["should have expires_on field"] = () =>
                        {
                            (token as CardTokenResponse).ExpiresOn.ShouldNotBeNull();
                        };
                    };
                };
            };
        }