Exemple #1
0
        public void Validate_GivenAllPropertiesAreValid_ExpectValidationSuccess()
        {
            var request = new EnrollAuthAppRequest
            {
                Code      = "code",
                SharedKey = "shared-key",
            };
            var validator = new EnrollAuthAppRequest.Validator();
            var result    = validator.Validate(request);

            Assert.True(result.IsValid);
        }
        public async Task <IActionResult> EnrollAuthApp([FromBody] EnrollAuthAppRequest model)
        {
            if (!this.ModelState.IsValid)
            {
                return(this.Json(new EnrollAuthAppResponse(false)));
            }

            var result =
                await this._mediator.Send(
                    new EnrollAuthenticatorAppCommand(model.SharedKey, model.Code));

            return(this.Json(new EnrollAuthAppResponse(result.IsSuccess)));
        }
Exemple #3
0
        public void Validate_GivenSharedKeyIsNull_ExpectValidationFailure()
        {
            var request = new EnrollAuthAppRequest
            {
                Code      = "code",
                SharedKey = null,
            };
            var validator = new EnrollAuthAppRequest.Validator();
            var result    = validator.Validate(request);

            Assert.False(result.IsValid);
            Assert.Contains(
                result.Errors,
                failure => failure.PropertyName == "SharedKey");
        }
Exemple #4
0
        public void Validate_GivenCodeIsEmpty_ExpectValidationFailure()
        {
            var request = new EnrollAuthAppRequest
            {
                Code      = string.Empty,
                SharedKey = "shared-key",
            };
            var validator = new EnrollAuthAppRequest.Validator();
            var result    = validator.Validate(request);

            Assert.False(result.IsValid);
            Assert.Contains(
                result.Errors,
                failure => failure.PropertyName == "Code");
        }