public void Validate_GivenAllPropertiesAreValid_ExpectValidationSuccess()
        {
            var request = new CompleteAuthDeviceRegistrationRequest
            {
                Name = "name",
            };
            var validator = new CompleteAuthDeviceRegistrationRequest.CompleteAuthDeviceRegistrationRequestValidator();
            var result    = validator.Validate(request);

            Assert.True(result.IsValid);
        }
        public void Validate_GivenPasswordIsNull_ExpectValidationFailure()
        {
            var request = new CompleteAuthDeviceRegistrationRequest
            {
                Name = null,
            };
            var validator = new CompleteAuthDeviceRegistrationRequest.CompleteAuthDeviceRegistrationRequestValidator();
            var result    = validator.Validate(request);

            Assert.False(result.IsValid);
            Assert.Contains(
                result.Errors,
                failure => failure.PropertyName == "Name");
        }
Example #3
0
        public async Task <IActionResult> CompleteAuthDeviceRegistration(
            [FromBody] CompleteAuthDeviceRegistrationRequest model)
        {
            var jsonOptions = this.TempData["CredentialData"] as string;
            var options     = CredentialCreateOptions.FromJson(jsonOptions);

            var result = await this._mediator.Send(new EnrollAuthenticatorDeviceCommand(
                                                       model.Name,
                                                       model.AttestationResponse,
                                                       options));

            return(this.Json(result.IsFailure
                ? new CompleteAuthDeviceRegistrationResponse()
                : new CompleteAuthDeviceRegistrationResponse(result.Value.CredentialMakeResult, result.Value.DeviceId, model.Name)));
        }