public void GetByIdentifier_Null()
        {
            // Init
            var repo = new AuthorizationRepository();

            #region Prepare records

            // Record #1
            repo.Add(new MemoryAuthorization
            {
                Identifier = new MemoryIdentifier
                {
                    Type  = "dns",
                    Value = "some.test.com",
                },
                Status = AuthorizationStatus.Invalid,
            });

            // Record #3
            repo.Add(new MemoryAuthorization
            {
                Identifier = new MemoryIdentifier
                {
                    Type  = "dns",
                    Value = "some.test2.com",
                },
                Status = AuthorizationStatus.Pending,
            });

            // Record #3
            repo.Add(new MemoryAuthorization
            {
                Identifier = new MemoryIdentifier
                {
                    Type  = "dns",
                    Value = "some.test.com",
                },
                Status = AuthorizationStatus.Pending,
            });

            #endregion

            // Get authz by Id
            var identifier = new Identifier
            {
                Type  = "DNS", // check case insensitive
                Value = "Some.Test.Com"
            };
            var res = repo.GetByIdentifier(0, identifier); // wrong id
            Assert.Equal(3, res.Id);
        }
        public void GetById_Null()
        {
            // Init
            var repo = new AuthorizationRepository();

            // Create authz
            var authz = repo.Create();

            authz.Identifier.Type  = "dns";
            authz.Identifier.Value = "some.test.com";
            authz.Status           = AuthorizationStatus.Pending;
            repo.Add(authz);

            // Get authz by Id
            var authz2 = repo.GetById(9); // wrong id

            Assert.Null(authz2);
        }
        /// <inheritdoc/>
        public virtual IAuthorization Create(int accountId, Identifier identifier)
        {
            // Create Authorization
            var authz = AuthorizationRepository.Create();

            // Fill params
            OnCreateParams(authz, accountId, identifier);

            // Save authorization
            var addedAuthz = AuthorizationRepository.Add(authz);

            // Add challenges
            var http = ChallengeService.Create(addedAuthz.Id, "http-01");

            //var tls = ChallengeService.Create(addedAuthz.Id, "tls-01");
            //var dns = ChallengeService.Create(addedAuthz.Id, "dns-01");

            Logger.Info("Authorization {id} created", authz.Id);

            return(addedAuthz);
        }