public PrivateApiResponse <T> LoginAndSendRequestWithOtherAccount <T>(string companyLoginId, string username, string password, string endpoint, IEnumerable <KeyValuePair <string, string> > request, HttpMethod httpMethod = null) { var connection = new PrivateApiConnection(); connection.Authenticate(companyLoginId, username, password); return(ProcessResponseWithContent <T>(connection.SendAsync(endpoint, request, httpMethod).Result)); }
public void TestResetUserPasswordByLockedUser() { var parameterRequest = new Dictionary <string, object>(Common.ResetUserPasswordParameters); var connection = new PrivateApiConnection(); //Login with wrong password for targeting to be locked user do { connection.Authenticate( TestContext.CurrentContext.Test.Properties.Get("companyName").ToString(), TestContext.CurrentContext.Test.Properties.Get("adminUserLogin").ToString(), "WrongPassword"); } while (connection.IsAuthenticated); //Reset user password and verify that reset not successful Common common = new Common(); parameterRequest["userId"] = TestContext.CurrentContext.Test.Properties.Get("adminUserId"); var response = common.LoginAndSendRequestWithOtherAccount <ResetUserPasswordResponse>( TestContext.CurrentContext.Test.Properties.Get("companyName").ToString(), TestContext.CurrentContext.Test.Properties.Get("adminUserLogin").ToString(), TestContext.CurrentContext.Test.Properties.Get("adminUserPassword").ToString(), "/privateapi/authentication/reset-user-password", parameterRequest); LastPassword = Common.GetResetUserPassword(response); PrAssert.That(response, PrIs.ErrorResponse().And.HttpCode(System.Net.HttpStatusCode.BadRequest)); }
public static PrivateApiConnection LoginAndSendRequestWithOtherAccount(string companyLoginId, string username, string password) { var connection = new PrivateApiConnection(); connection.Authenticate(companyLoginId, username, password); return(connection); }
private static PrivateApiConnection InitPrivateApiConnection(string companyName, string userName, string userPassword) { if (Connection == null) { Connection = new PrivateApiConnection(TestConfig.GetValueFromConfig("InternalServerURL")); Connection.Authenticate(companyName, userName, userPassword); } return(Connection); }
public PrivateApiResponse <T> LoginAndSendRequestWithOtherAccount <T>(string companyLoginId, string username, string password, string endpoint, object request, HttpMethod httpMethod = null) { var connection = new PrivateApiConnection(); connection.Authenticate(companyLoginId, username, password); var contentString = ConvertToJsonString(request); return(ProcessResponseWithContent <T>(connection.SendAsync(endpoint, contentString, httpMethod == null ? HttpMethod.Post : httpMethod).Result)); }
public PrivateApiResponse<T> ForcePasswordChangeDiffUser<T>(string companyName, string userName, string userPassword, object content, HttpMethod httpMethod, string contentType = "application/json") { connection.DeAuthenticate(); connection.Authenticate(companyName, userName, userPassword); string contentString = ConvertToJsonString(content); using (LogHelper.LoggerForCurrentTest.EnterReproStep($"Force password change with {ForceEndpoint}")) { return ProcessResponseWithContent<T>(connection.SendAsync(ForceEndpoint, contentString, httpMethod, contentType).Result); } }
private void AccessEndpointSetup(AccessState accessState) { if (accessState == AccessState.Logout) { Connection.DeAuthenticate(); } else if (accessState == AccessState.OldSessionCookies) { var info = (TestContext.CurrentContext.Test.Properties.Get(PrivateFixtureExecutorAttribute.TestAuthInfoPropertyName) as MultiItemAuthenticationInfo); var connect = new PrivateApiConnection(); connect.Authenticate(info.Companies.First().Value.Name, info.Users.First().Value.Login, info.Users.First().Value.Password); } }
public static PrivateData <PrivateApiConnection> GetOtherConnection() { return(new PrivateData <PrivateApiConnection>( (session, test) => { return Task.Run(() => { var userInfo = AuthenticationInfoProvider.Current.Manager.GetAllAvailableUsers(new UserSpecBuilder().Admin(false)).First(); var connection = new PrivateApiConnection(); connection.Authenticate(userInfo.Company.Name, userInfo.Login, userInfo.Password); return connection; }); }, (session, test, res) => Task.Run(() => { }))); }
private void PerformTestWithoutAuthorisation(bool doDeauth, Func <PrivateApiConnection, string, object> responseProvider, string recordId = null) { var connection = new PrivateApiConnection(); if (doDeauth) { connection.Authenticate(); connection.DeAuthenticate(); } else { connection = new PrivateApiConnection(); connection.SuppressAuthentication = true; } var response = responseProvider(connection, recordId); PrAssert.That(response, PrIs.ErrorResponse().And.HttpCode(401)); }
public void TestVerifyResetUserPasswordAfterExpiredTime() { var parameterRequest = new Dictionary <string, object>(Common.ResetUserPasswordParameters); var resetUserPassHandler = new ResetUserPasswordManager(); var response = resetUserPassHandler.ResetUserPassword(parameterRequest, System.Net.Http.HttpMethod.Post); LastPassword = Common.GetResetUserPassword(response); //Verify Thread.Sleep(60000 * 2); //sleep in 2 mins var connection = new PrivateApiConnection(); connection.Authenticate( TestContext.CurrentContext.Test.Properties.Get("companyName").ToString(), TestContext.CurrentContext.Test.Properties.Get("adminUserLogin").ToString(), TestContext.CurrentContext.Test.Properties.Get("adminUserPassword").ToString()); PrAssert.That(connection.IsAuthenticated, PrIs.True); }
public void LoginNormalUserAndSendRequestWithHeaderContainsAdminUserIdTest() { var creds = AuthenticationInfoProvider.GetAuthSpecForCurrentTest(); var adminUserPassword = creds.Companies.First().Value.Users.First().Password; var adminUserLogin = creds.Companies.First().Value.Users.First().Login; var adminUserId = creds.Companies.First().Value.Users.First().Metadata["userId"].ToString(); var companyId = creds.Companies.First().Value.Id; var companyName = creds.Companies.First().Value.Name; creds.Dispose(); var headerValue = GetFormatIdentityHeader(companyId, adminUserId, DefaultService); //Login by normal user Connection = new PrivateApiConnection(TestConfig.GetValueFromConfig("InternalServerURL")); Connection.Authenticate(companyName, NormalUserLogin, NormalUserPassword); var internalHandler = new InternalApiManager(Connection); var response = internalHandler.SendRequestWithIdentityHeader(InternalAuthRequest, "X-IDENTITY", headerValue, HttpMethod.Post); PrAssert.That(response, PrIs.ErrorResponse().And.HttpCode(System.Net.HttpStatusCode.Unauthorized)); }
private void Login(PrivateApiConnection connection, string company, string login, string password) { connection.DeAuthenticate(); connection.Authenticate(company, login, password); }