Ejemplo n.º 1
0
        public void Good_request_should_not_throw(TokenCreate.Request request)
        {
            var         subject = new TokenCreate.Validator();
            Func <Task> action  = async() => await subject.Process(request, default);

            action.Should().NotThrow <ValidationException>();
        }
Ejemplo n.º 2
0
        public async Task Should_write_valid_token()
        {
            var playerId = new Guid("58527a83-e920-44c2-8dac-9221f0c9cf09");

            this.jwtWriter
            .Setup(x => x.Write(It.IsAny <SecurityToken>()))
            .Verifiable();

            var request = new TokenCreate.Request
            {
                PlayerId = playerId
            };
            var actual = await this.subject.Handle(request, default);

            this.jwtWriter.Verify(
                x => x.Write(It.Is <JwtSecurityToken>(
                                 t => t.Audiences.Contains(Constants.TripleTriad) &&
                                 t.Issuer == Constants.TripleTriad &&
                                 t.Claims.Any(
                                     c => c.Type == Constants.Claims.PlayerId &&
                                     c.Value == playerId.ToString()) &&
                                 t.SigningCredentials.Key == securityKey)));
        }