Beispiel #1
0
        public void WHEN_token_is_null_SHOULD_throw_ArgumentNullException()
        {
            //Arrange
            OrderToken param = null;

            //Act
            var ex = Assert.Throws <ArgumentNullException>(() => GuestOrderTokenizer.GenerateOrderToken(param));

            //Assert
            ex.Should().NotBeNull();
            ex.ParamName.Should().NotBeNullOrWhiteSpace();
        }
Beispiel #2
0
        public void WHEN_token_ok_SHOULD_return_encrypted_token()
        {
            //Arrange
            var param = new OrderToken
            {
                Email       = GetRandom.Email(),
                OrderNumber = GetRandom.String(6)
            };

            //Act
            var token = GuestOrderTokenizer.GenerateOrderToken(param);

            //Assert
            token.Should().NotBeNullOrWhiteSpace();
            token.Should().NotContainEquivalentOf(param.Email);
            token.Should().NotContainEquivalentOf(param.OrderNumber);
        }
Beispiel #3
0
        public void WHEN_orderNumber_is_invalid_SHOULD_throw_ArgumentNullException(string orderNumber)
        {
            //Arrange
            OrderToken param = new OrderToken
            {
                Email       = GetRandom.Email(),
                OrderNumber = orderNumber
            };

            //Act
            var ex = Assert.Throws <ArgumentException>(() => GuestOrderTokenizer.GenerateOrderToken(param));

            //Assert
            ex.Should().NotBeNull();
            ex.ParamName.Should().NotBeNullOrWhiteSpace();
            ex.Message.Should().NotBeNullOrWhiteSpace();
        }
Beispiel #4
0
        public virtual async Task <IHttpActionResult> GetGuestOrderDetailsUrl(GetGuestOrderViewModel request)
        {
            if (request == null)
            {
                return(BadRequest("No request body found."));
            }

            var orderDetailUrl = OrderUrlProvider.GetGuestOrderDetailsUrl(ComposerContext.CultureInfo);

            var orderDetailViewModel = await OrderHistoryViewService.GetOrderDetailViewModelForGuestAsync(new GetOrderForGuestParam
            {
                OrderNumber = request.OrderNumber,
                Email       = request.Email,
                Scope       = ComposerContext.Scope,
                CultureInfo = ComposerContext.CultureInfo,
                CountryCode = ComposerContext.CountryCode,
                BaseUrl     = RequestUtils.GetBaseUrl(Request).ToString()
            });

            if (orderDetailViewModel == null)
            {
                return(NotFound());
            }

            var token = GuestOrderTokenizer.GenerateOrderToken(new OrderToken
            {
                Email       = request.Email,
                OrderNumber = request.OrderNumber
            });

            var url = UrlFormatter.AppendQueryString(orderDetailUrl, new NameValueCollection
            {
                { "token", token }
            });

            var vm = new GuestOrderDetailsViewModel
            {
                Url = url
            };

            return(Ok(vm));
        }
        public void WHEN_token_is_valid_SHOULD_return_dto()
        {
            //Arrange
            var param = new OrderToken
            {
                Email       = GetRandom.Email(),
                OrderNumber = GetRandom.String(7)
            };

            var token = GuestOrderTokenizer.GenerateOrderToken(param);

            //Act
            var dto = GuestOrderTokenizer.DecypherOrderToken(token);

            //Assert
            dto.Should().NotBeNull();
            dto.Email.Should().NotBeNullOrWhiteSpace();
            dto.Email.Should().Be(param.Email);
            dto.OrderNumber.Should().Be(param.OrderNumber);
        }