コード例 #1
0
        public void ReadHrbcCoreTmpCompanyInfoInvalidSpecialTest(InvalidSpecialTestCases inputType)
        {
            ApiResponse <HrbcCoreTmpCompanyInfoResponse> response = null;
            var companyInfoHandler = new HrbcCoreManager();

            var request = new Dictionary <string, string>()
            {
                ["companyId"] = CompanyId,
                ["fullMode"]  = "true",
            };

            switch (inputType)
            {
            case InvalidSpecialTestCases.NoDataInRequest:
                response = companyInfoHandler.SendHrbcCoreTmpCompanyInfo <HrbcCoreTmpCompanyInfoResponse>(_testConnection, System.Net.Http.HttpMethod.Get);
                break;

            case InvalidSpecialTestCases.LoginAdminUserSendRequestOtherCompany:
                request["companyId"] = OtherCompanyId;
                response             = companyInfoHandler.SendHrbcCoreTmpCompanyInfo <HrbcCoreTmpCompanyInfoResponse>(_testConnection, request, System.Net.Http.HttpMethod.Get);
                break;

            case InvalidSpecialTestCases.IncludeCompanyIdIntoParameter:
                response = companyInfoHandler.SendHrbcCoreIncludeCompanyIdIntoParamerter <HrbcCoreTmpCompanyInfoResponse>(_testConnection, request);
                break;
            }
            PrAssert.That(response, PrIs.ErrorResponse().And.HttpCode(HttpStatusCode.BadRequest));
        }
コード例 #2
0
        public void ReadHrbcCoreTmpCompanyInfoByOtherHttpMethod(HttpMethod inputType)
        {
            var companyInfoHandler = new HrbcCoreManager();
            var request            = new Dictionary <string, string>()
            {
                ["companyId"] = CompanyId,
                ["fullMode"]  = "true",
            };

            var response = companyInfoHandler.SendHrbcCoreTmpCompanyInfo <HrbcCoreTmpCompanyInfoResponse>(_testConnection, request, inputType.ToNetHttpMethod());

            PrAssert.That(response, PrIs.ErrorResponse().And.HttpCode(HttpStatusCode.BadRequest));
        }
コード例 #3
0
        public void ReadHrbcCoreTmpCompanyInfoInjection(Fields field, InjectionInput inputType)
        {
            var fieldName          = Char.ToLowerInvariant(field.ToString()[0]) + field.ToString().Substring(1);
            var companyInfoHandler = new HrbcCoreManager();
            var request            = new Dictionary <string, string>()
            {
                ["companyId"] = CompanyId,
                ["fullMode"]  = "true",
            };

            request[fieldName] = InjectionInputData.InjectionInputMapper[inputType];

            var response = companyInfoHandler.SendHrbcCoreTmpCompanyInfo <HrbcCoreTmpCompanyInfoResponse>(_testConnection, request, System.Net.Http.HttpMethod.Get, string.Empty);

            PrAssert.That(response, PrIs.ErrorResponse().And.HttpCode(HttpStatusCode.BadRequest));
        }
コード例 #4
0
        public void ReadHrbcCoreTmpCompanyInfoInvalidTest(Fields field, InvalidTestCases inputType)
        {
            var fieldName          = Char.ToLowerInvariant(field.ToString()[0]) + field.ToString().Substring(1);
            var companyInfoHandler = new HrbcCoreManager();

            var request = new Dictionary <string, string>()
            {
                ["companyId"] = CompanyId,
                ["fullMode"]  = "true",
            };

            InvalidMapperValues[inputType](fieldName, CompanyName, request);

            var response = (inputType == InvalidTestCases.Missing && field == Fields.CompanyId) ? companyInfoHandler.SendHrbcCoreTmpCompanyInfoWithMissingCompanyId <HrbcCoreTmpCompanyInfoResponse>(_testConnection, request, System.Net.Http.HttpMethod.Get) :
                           companyInfoHandler.SendHrbcCoreTmpCompanyInfo <HrbcCoreTmpCompanyInfoResponse>(_testConnection, request, System.Net.Http.HttpMethod.Get);

            PrAssert.That(response, PrIs.ErrorResponse().And.HttpCode(HttpStatusCode.BadRequest));
        }
コード例 #5
0
        public void DuplicateParametersTest(Fields field, Values value)
        {
            var companyInfoHandler = new HrbcCoreManager();

            var parametersSameValue = new Dictionary <Fields, string>
            {
                [Fields.CompanyId] = $"/{CompanyId}/{CompanyId}?fullMode=true",
                [Fields.FullMode]  = $"/{CompanyId}?fullMode=true&fullMode=true",
            };

            var parametersNotSameValue = new Dictionary <Fields, string>
            {
                [Fields.CompanyId] = $"/{CompanyId}/{SecondCompanyId}?fullMode=true",
                [Fields.FullMode]  = $"/{CompanyId}?fullMode=true&fullMode=false",
            };

            var response = companyInfoHandler.SendHrbcCoreTmpCompanyInfo <HrbcCoreTmpCompanyInfoResponse>(_testConnection, value == Values.Same ? parametersSameValue[field] : parametersNotSameValue[field]);

            PrAssert.That(response, PrIs.ErrorResponse().And.HttpCode(HttpStatusCode.BadRequest));
        }
コード例 #6
0
        public void ReadHrbcCoreTmpCompanyInfoValidTest(UserType userType, ValidTestCases inputType)
        {
            ApiResponse <HrbcCoreTmpCompanyInfoResponse> response = null;
            var creds              = AuthenticationInfoProvider.GetAuthSpecForCurrentTest();
            var companyName        = creds.Companies.First().Value.Metadata["companyName"].ToString();
            var companyLoginId     = creds.Companies.First().Value.Name;
            var adminLogin         = creds.Companies.First().Value.Users.First().Login;
            var adminPassword      = creds.Companies.First().Value.Users.First().Password;
            var dbInfoHost         = creds.Companies.First().Value.Metadata["dbInfoHost"].ToString();
            var dbInfoPort         = creds.Companies.First().Value.Metadata["dbInfoPort"].ToString();
            var dbInfoUserName     = creds.Companies.First().Value.Metadata["dbInfoUserName"].ToString();
            var dbInfoPassword     = creds.Companies.First().Value.Metadata["dbInfoPassword"].ToString();
            var companyInfoHandler = new HrbcCoreManager();

            var requestDefault = new Dictionary <string, string>()
            {
                ["companyId"] = CompanyId
            };

            if (inputType != ValidTestCases.Default)
            {
                requestDefault["fullMode"] = ValidMapperValues[inputType].ToString().ToLower();
            }

            if (UserType.User == userType)
            {
                var request = new Dictionary <string, string>(requestDefault);
                response = companyInfoHandler.LoginAndSendRequestWithOtherAccount <HrbcCoreTmpCompanyInfoResponse>(CompanyName, NormalUserLogin, NormalUserPassword, HrbcCoreManager.GetTmpCompanyInfoEndpoint, request);
                companyInfoHandler.ReAuthenticate(CompanyName, adminLogin, adminPassword);
            }
            else
            {
                response = companyInfoHandler.SendHrbcCoreTmpCompanyInfo <HrbcCoreTmpCompanyInfoResponse>(_testConnection, requestDefault, System.Net.Http.HttpMethod.Get);
            }
            creds.Dispose();

            PrAssert.That(response, PrIs.SuccessfulResponse().And.HttpCode(HttpStatusCode.OK));
            //Verify data
            VerifyData(response, inputType, new CompanyInfo(CompanyId, companyName, companyLoginId, $"PRC{CompanyId}", dbInfoHost, dbInfoPort, dbInfoUserName, dbInfoPassword));
        }