public void DuplicateParametersTest(Fields field, Values value) { var creds = AuthenticationInfoProvider.GetAuthSpecForCurrentTest(); var adminUserId = creds.Companies.First().Value.Users.First().Metadata["userId"].ToString(); var readSessionHandler = new HrbcCoreManager(); var firstSessionId = readSessionHandler.GetDefaultSessionId(_testConnection); var secondSessionId = readSessionHandler.GetDefaultSessionId(_testConnection); var parametersSameValue = new Dictionary <Fields, string> { [Fields.CompanyId] = $"companyId={CompanyId}&companyId={CompanyId}&userId={adminUserId}&sessionId={firstSessionId}", [Fields.UserId] = $"companyId={CompanyId}&userId={adminUserId}&userId={adminUserId}&sessionId={firstSessionId}", [Fields.SessionId] = $"companyId={CompanyId}&userId={adminUserId}&sessionId={firstSessionId}&sessionId={firstSessionId}" }; var parametersNotSameValue = new Dictionary <Fields, string> { [Fields.CompanyId] = $"companyId={CompanyId}&companyId={SecondCompanyId}&userId={adminUserId}&sessionId={firstSessionId}", [Fields.UserId] = $"companyId={CompanyId}&userId={NormalUserId}&userId={adminUserId}&sessionId={firstSessionId}", [Fields.SessionId] = $"companyId={CompanyId}&userId={adminUserId}&sessionId={firstSessionId}&sessionId={secondSessionId}" }; creds.Dispose(); var response = readSessionHandler.SendHrbcCoreSession <HrbcCoreSessionResponse>(_testConnection, value == Values.Same ? parametersSameValue[field] : parametersNotSameValue[field]); PrAssert.That(response, PrIs.ErrorResponse().And.HttpCode(HttpStatusCode.BadRequest)); }
public void ReadHrbcCoreSessionByOtherHttpMethod(HttpMethod inputType) { var creds = AuthenticationInfoProvider.GetAuthSpecForCurrentTest(); var adminUserId = creds.Companies.First().Value.Users.First().Metadata["userId"].ToString(); var readSessionHandler = new HrbcCoreManager(); var request = new Dictionary <string, string>() { ["companyId"] = CompanyId, ["userId"] = adminUserId, ["sessionId"] = readSessionHandler.GetDefaultSessionId(_testConnection), }; creds.Dispose(); var response = readSessionHandler.SendHrbcCoreSession <HrbcCoreSessionResponse>(_testConnection, request, inputType.ToNetHttpMethod()); PrAssert.That(response, PrIs.ErrorResponse().And.HttpCode(HttpStatusCode.BadRequest)); }
public void ReadHrbcCoreSessionValidTest() { var creds = AuthenticationInfoProvider.GetAuthSpecForCurrentTest(); var adminUserId = creds.Companies.First().Value.Users.First().Metadata["userId"].ToString(); var readSessionHandler = new HrbcCoreManager(); var request = new Dictionary <string, string>() { ["companyId"] = CompanyId, ["userId"] = adminUserId, ["sessionId"] = readSessionHandler.GetDefaultSessionId(_testConnection), }; creds.Dispose(); var response = readSessionHandler.SendHrbcCoreSession <HrbcCoreSessionResponse>(_testConnection, request, System.Net.Http.HttpMethod.Get, null); PrAssert.That(response, PrIs.SuccessfulResponse().And.HttpCode(HttpStatusCode.OK)); PrAssert.That(response.Result.Status, PrIs.EqualTo("OK")); }
public void ReadHrbcCoreSessionInvalidSpecialTest(InvalidSpecialTestCases inputType) { ApiResponse <HrbcCoreSessionResponse> response = null; var creds = AuthenticationInfoProvider.GetAuthSpecForCurrentTest(); var adminUserId = creds.Companies.First().Value.Users.First().Metadata["userId"].ToString(); var adminLogin = creds.Companies.First().Value.Users.First().Login; var adminPassword = creds.Companies.First().Value.Users.First().Password; var readSessionHandler = new HrbcCoreManager(); var request = new Dictionary <string, string>() { ["companyId"] = CompanyId, ["userId"] = adminUserId, ["sessionId"] = readSessionHandler.GetDefaultSessionId(_testConnection), }; creds.Dispose(); switch (inputType) { case InvalidSpecialTestCases.ExpiredSessionId: Thread.Sleep(10800 * 1000); //Sleep in 10800 seconds response = readSessionHandler.SendHrbcCoreSession <HrbcCoreSessionResponse>(_testConnection, request, System.Net.Http.HttpMethod.Get); break; case InvalidSpecialTestCases.NoDataInRequest: response = readSessionHandler.SendHrbcCoreSession <HrbcCoreSessionResponse>(_testConnection, System.Net.Http.HttpMethod.Get); break; case InvalidSpecialTestCases.LoginNormalUserSendRequestAdminUserId: response = readSessionHandler.LoginAndSendRequestWithOtherAccount <HrbcCoreSessionResponse>(CompanyName, NormalUserLogin, NormalUserPassword, HrbcCoreManager.GetSessionEndpoint, request); break; case InvalidSpecialTestCases.LoginAdminUserSendRequestOtherCompany: var userInfo = GetAllAvailableUsers(OtherCompanyId); request["companyId"] = OtherCompanyId; request["userId"] = userInfo.Company.Users.First().Metadata["userId"].ToString(); userInfo.Dispose(); response = readSessionHandler.SendHrbcCoreSession <HrbcCoreSessionResponse>(_testConnection, request, System.Net.Http.HttpMethod.Get); break; } PrAssert.That(response, PrIs.ErrorResponse().And.HttpCode(HttpStatusCode.BadRequest)); }
public void ReadHrbcCoreSessionInjection(Fields field, InjectionInput inputType) { var creds = AuthenticationInfoProvider.GetAuthSpecForCurrentTest(); var adminUserId = creds.Companies.First().Value.Users.First().Metadata["userId"].ToString(); var fieldName = Char.ToLowerInvariant(field.ToString()[0]) + field.ToString().Substring(1); var readSessionHandler = new HrbcCoreManager(); var request = new Dictionary <string, string>() { ["companyId"] = CompanyId, ["userId"] = adminUserId, ["sessionId"] = readSessionHandler.GetDefaultSessionId(_testConnection), }; creds.Dispose(); request[fieldName] = InjectionInputData.InjectionInputMapper[inputType]; var response = readSessionHandler.SendHrbcCoreSession <HrbcCoreSessionResponse>(_testConnection, request, System.Net.Http.HttpMethod.Get, null); PrAssert.That(response, PrIs.ErrorResponse().And.HttpCode(HttpStatusCode.BadRequest)); }
public void ReadHrbcCoreSessionAccessEndpointTest(AccessState accessState, HttpStatusCode httpStatusCode, ResultCode resultCode) { var creds = AuthenticationInfoProvider.GetAuthSpecForCurrentTest(); var adminUserId = creds.Companies.First().Value.Users.First().Metadata["userId"].ToString(); var companyId = creds.Companies.First().Value.Id; var readSessionHandler = new HrbcCoreManager(); var accessEndpointHandler = new AccessEndpointManager(); var request = new Dictionary <string, string>() { ["companyId"] = companyId, ["userId"] = adminUserId, ["sessionId"] = readSessionHandler.GetDefaultSessionId(), }; creds.Dispose(); var response = accessEndpointHandler.AccessEndpoint <HrbcCoreSessionResponse>(accessState, HrbcCoreManager.GetSessionEndpoint, request, System.Net.Http.HttpMethod.Get); PrAssert.That(response, PrIs.ErrorResponse().And.HttpCode(httpStatusCode), "Still able to access entry api."); }
public void ReadHrbcCoreSessionByLoginValidTest(ValidTestCases inputType) { ApiResponse <HrbcCoreSessionResponse> response = null; var creds = AuthenticationInfoProvider.GetAuthSpecForCurrentTest(); var adminUserId = creds.Companies.First().Value.Users.First().Metadata["userId"].ToString(); var adminLogin = creds.Companies.First().Value.Users.First().Login; var adminPassword = creds.Companies.First().Value.Users.First().Password; var readSessionHandler = new HrbcCoreManager(); var requestDefault = new Dictionary <string, string>() { ["companyId"] = CompanyId, ["userId"] = NormalUserId, ["sessionId"] = readSessionHandler.GetDefaultSessionId(_testConnection), }; if (ValidTestCases.LoginNormalUserSendRequestNormalUserId == inputType) { var request = new Dictionary <string, string>(requestDefault); response = readSessionHandler.LoginAndSendRequestWithOtherAccount <HrbcCoreSessionResponse>(CompanyName, NormalUserLogin, NormalUserPassword, HrbcCoreManager.GetSessionEndpoint, request); readSessionHandler.ReAuthenticate(CompanyName, adminLogin, adminPassword); } else { Dictionary <string, string> request = new Dictionary <string, string>(); if (ValidTestCases.LoginAdminUserSendRequestNormalUserId == inputType) { request = requestDefault; } else { request = new Dictionary <string, string>(requestDefault); request["userId"] = adminUserId; } response = readSessionHandler.SendHrbcCoreSession <HrbcCoreSessionResponse>(_testConnection, request, System.Net.Http.HttpMethod.Get); } creds.Dispose(); PrAssert.That(response, PrIs.SuccessfulResponse().And.HttpCode(HttpStatusCode.OK)); PrAssert.That(response.Result.Status, PrIs.EqualTo("OK")); }