コード例 #1
0
        public void WritingPasswordSettingsInvalidSpecialContent(Common.InvalidSpecialCondition invalidSpecialCondition)
        {
            var handler  = new WebPasswordManager();
            var response = handler.Password <object>(Common.InvalidEntrySpecialTestCasesMapper[invalidSpecialCondition], System.Net.Http.HttpMethod.Put);

            PrAssert.That(response.HttpStatusCode, PrIs.EqualTo(HttpStatusCode.BadRequest));
        }
コード例 #2
0
        public void ReadingPasswordSettings(Common.InvalidValue invalidCompany)
        {
            var request  = Common.InvalidReadingMapper[invalidCompany](new Dictionary <string, string>(), "id");
            var handler  = new WebPasswordManager();
            var response = handler.Password <PasswordSettingsResponse>(request, System.Net.Http.HttpMethod.Get);

            PrAssert.That(response.HttpStatusCode, PrIs.EqualTo(HttpStatusCode.BadRequest));
        }
コード例 #3
0
        public void ReadingPasswordSettingsInvalidMethod(HttpMethod httpMethod)
        {
            var request = new Dictionary <string, string>()
            {
                ["id"] = Common.OldCompanyId.ToString(),
            };
            var handler  = new WebPasswordManager();
            var response = handler.Password <PasswordSettingsResponse>(request, Common.HttpMethodMapper[httpMethod]);

            PrAssert.That(response.HttpStatusCode, PrIs.EqualTo(HttpStatusCode.MethodNotAllowed));
        }
コード例 #4
0
        public void ReadingPasswordSettingsInjection(Common.InjectionInput injectionInput)
        {
            var request = new Dictionary <string, string>()
            {
                ["id"] = Common.InjectionInputMapper[injectionInput],
            };
            var handler  = new WebPasswordManager();
            var response = handler.Password <PasswordSettingsResponse>(request, System.Net.Http.HttpMethod.Get);

            PrAssert.That(response.HttpStatusCode, PrIs.EqualTo(HttpStatusCode.BadRequest));
        }
コード例 #5
0
        public void TestReadWebPasswordAccessEndpoint(AccessState accessState, HttpStatusCode httpStatusCode, ResultCode resultCode)
        {
            var request = new Dictionary <string, string>()
            {
                ["id"] = Common.OldCompanyId.ToString(),
            };
            var handler  = new WebPasswordManager();
            var response = handler.Password <PasswordSettingsResponse>(Common.OldCompanyId, System.Net.Http.HttpMethod.Get);

            PrAssert.That(response, PrIs.ErrorResponse());
            PrAssert.That(response, PrIs.ErrorResponse().And.HttpCode(httpStatusCode).And.ContainsError(((int)resultCode).ToString()), "Still able to access merge api.");
        }
コード例 #6
0
        public void WritingPasswordSettingsInvalidMethod(HttpMethod httpMethod)
        {
            var request = new Dictionary <string, object>()
            {
                ["companyId"]       = Common.OldCompanyId.ToString(),
                ["minLength"]       = Common.DefaultMinLength,
                ["checkComplexity"] = false,
            };
            var handler  = new WebPasswordManager();
            var response = handler.Password <object>(request, Common.HttpMethodMapper[httpMethod]);

            PrAssert.That(response.HttpStatusCode, PrIs.EqualTo(HttpStatusCode.MethodNotAllowed));
        }
コード例 #7
0
        public void WritingPasswordSettingsInvalidMinLength(Common.InvalidValue invalidMinlength)
        {
            var validRequest = new Dictionary <string, object>()
            {
                ["companyId"]       = Common.OldCompanyId.ToString(),
                ["minLength"]       = Common.DefaultMinLength,
                ["checkComplexity"] = false,
            };
            var request  = Common.InvalidNumberMapper[invalidMinlength](validRequest, "minLength");
            var handler  = new WebPasswordManager();
            var response = handler.Password <object>(request, System.Net.Http.HttpMethod.Put);

            PrAssert.That(response.HttpStatusCode, PrIs.EqualTo(HttpStatusCode.BadRequest));
        }
コード例 #8
0
        public void TestWriteWebPasswordAccessEndpoint(AccessState accessState, HttpStatusCode httpStatusCode, ResultCode resultCode)
        {
            var request = new Dictionary <string, object>()
            {
                ["companyId"]       = Common.OldCompanyId,
                ["minLength"]       = 8,
                ["checkComplexity"] = true,
            };
            var handler  = new WebPasswordManager();
            var response = handler.Password <object>(request, System.Net.Http.HttpMethod.Put);

            PrAssert.That(response, PrIs.ErrorResponse());
            PrAssert.That(response, PrIs.ErrorResponse().And.HttpCode(httpStatusCode).And.ContainsError(((int)resultCode).ToString()), "Still able to access merge api.");
        }
コード例 #9
0
        public void WritingPasswordSettingsInvalidFieldInjection(string field, Common.InjectionInput injectionInput)
        {
            var request = new Dictionary <string, object>()
            {
                ["companyId"]       = Common.OldCompanyId.ToString(),
                ["minLength"]       = Common.DefaultMinLength,
                ["checkComplexity"] = false,
            };

            request[field] = Common.InjectionInputMapper[injectionInput];
            var handler  = new WebPasswordManager();
            var response = handler.Password <object>(request, System.Net.Http.HttpMethod.Put);

            PrAssert.That(response.HttpStatusCode, PrIs.EqualTo(HttpStatusCode.BadRequest));
        }
コード例 #10
0
        public void WritingPasswordSettings(int companyId, Common.ValidNumber validNumberMinLength, bool validCheckComplexity, Common.OptionalParam optionalParam, Common.ValidNumber validNumberOption)
        {
            var request = new Dictionary <string, object>()
            {
                ["companyId"]       = companyId,
                ["minLength"]       = Common.mapNumber[validNumberMinLength],
                ["checkComplexity"] = validCheckComplexity,
            };

            Common.ValidNumberMapper[optionalParam](request, Common.mapNumber[validNumberOption]);
            var handler  = new WebPasswordManager();
            var response = handler.Password <object>(request, System.Net.Http.HttpMethod.Put);

            PrAssert.That(response, PrIs.SuccessfulResponse());
            PrAssert.That(response.HttpStatusCode, PrIs.EqualTo(System.Net.HttpStatusCode.NoContent), "The status code is not as expected!");
        }
コード例 #11
0
        public void ReadingPasswordSettings(int companyId)
        {
            var request = new Dictionary <string, string>()
            {
                ["id"] = companyId.ToString(),
            };
            var handler  = new WebPasswordManager();
            var response = handler.Password <PasswordSettingsResponse>(request, System.Net.Http.HttpMethod.Get);

            PrAssert.That(response, PrIs.SuccessfulResponse());
            if (companyId == Common.OldCompanyId)
            {
                PrAssert.That(response.Result.CheckComplexity, PrIs.EqualTo(false), "The check complexity is not as expected");
            }
            else
            {
                PrAssert.That(response.Result.CheckComplexity, PrIs.EqualTo(true), "The check complexity is not as expected");
                PrAssert.That(response.Result.AccountLockOut.MaxFails, PrIs.EqualTo(5), "The max fails is not as expected");
                PrAssert.That(response.Result.History.Count, PrIs.EqualTo(3), "The count is not as expected");
                PrAssert.That(response.Result.Expiration.Days, PrIs.EqualTo(90), "The days is not as expected");
            }
        }