use of com.seleniumtests.connectors.selenium.SeleniumRobotVariableServerConnector in project seleniumRobot by bhecquet.
the class TestSeleniumRobotVariableServerConnector method testServerActiveAliveAndSecured.
/**
* test exception is raised if no token is provided whereas server is secured
* @throws UnirestException
*/
@Test(groups = { "ut" }, expectedExceptions = ConfigurationException.class)
public void testServerActiveAliveAndSecured() throws UnirestException {
configureMockedVariableServerConnection();
when(responseAliveString.getStatus()).thenReturn(401);
SeleniumRobotVariableServerConnector connector = new SeleniumRobotVariableServerConnector(true, SERVER_URL, "Test1", null);
}
use of com.seleniumtests.connectors.selenium.SeleniumRobotVariableServerConnector in project seleniumRobot by bhecquet.
the class TestSeleniumRobotVariableServerConnector method testCreateEnvironmentWithToken.
/**
* Check tokens are not added to request when not provided
* @throws UnirestException
*/
@Test(groups = { "ut" })
public void testCreateEnvironmentWithToken() throws UnirestException {
configureMockedVariableServerConnection();
SeleniumRobotVariableServerConnector connector = new SeleniumRobotVariableServerConnector(true, SERVER_URL, "Test1", "123");
connector.createEnvironment();
verify(createEnvironmentRequest, times(1)).header("Authorization", "Token 123");
}
use of com.seleniumtests.connectors.selenium.SeleniumRobotVariableServerConnector in project seleniumRobot by bhecquet.
the class TestSeleniumRobotVariableServerConnector method testVariableUpdateExistingVariableThatDisappeard.
/**
* issue #429: if variable has been deleted, recreate one
* @throws UnirestException
*/
@Test(groups = { "ut" })
public void testVariableUpdateExistingVariableThatDisappeard() throws UnirestException {
configureMockedVariableServerConnection();
createServerMock(SERVER_URL, "PATCH", String.format(SeleniumRobotVariableServerConnector.EXISTING_VARIABLE_API_URL, 12), 404, "{}");
SeleniumRobotVariableServerConnector connector = new SeleniumRobotVariableServerConnector(true, SERVER_URL, "Test1", null);
TestVariable existingVariable = new TestVariable(12, "key", "value", false, TestVariable.TEST_VARIABLE_PREFIX + "key");
TestVariable variable = connector.upsertVariable(existingVariable, true);
// check we tried a PATCH and then create the variable with a POST
PowerMockito.verifyStatic(Unirest.class);
Unirest.patch(ArgumentMatchers.contains(SeleniumRobotVariableServerConnector.VARIABLE_API_URL));
PowerMockito.verifyStatic(Unirest.class);
Unirest.post(ArgumentMatchers.contains(SeleniumRobotVariableServerConnector.VARIABLE_API_URL));
Assert.assertEquals(variable.getValue(), "value");
}
use of com.seleniumtests.connectors.selenium.SeleniumRobotVariableServerConnector in project seleniumRobot by bhecquet.
the class TestSeleniumRobotVariableServerConnector method testVariableDereservationNullId.
@Test(groups = { "ut" })
public void testVariableDereservationNullId() throws UnirestException {
configureMockedVariableServerConnection();
SeleniumRobotVariableServerConnector connector = new SeleniumRobotVariableServerConnector(true, SERVER_URL, "Test1", null);
List<TestVariable> variables = Arrays.asList(new TestVariable("key", "value"));
connector.unreserveVariables(variables);
// only one dereservation should be called
PowerMockito.verifyStatic(Unirest.class, times(0));
Unirest.patch(ArgumentMatchers.contains(String.format(SeleniumRobotVariableServerConnector.EXISTING_VARIABLE_API_URL, 2)));
}
use of com.seleniumtests.connectors.selenium.SeleniumRobotVariableServerConnector in project seleniumRobot by bhecquet.
the class TestSeleniumRobotVariableServerConnector method testServerWithRedirect301.
/**
* Issue #356: check we change URL if redirect 301 is encountered
*/
@Test(groups = { "ut" })
public void testServerWithRedirect301() {
// connection for HTTP
configureMockedVariableServerConnection();
// connection for HTTPS
configureMockedVariableServerConnection("https://localhost:2345");
HttpResponse<String> response = mock(HttpResponse.class);
when(response.getBody()).thenReturn("Moved Permanently");
when(response.getHeaders()).thenReturn(headers);
when(response.getStatus()).thenReturn(301);
when(responseHttps.getBody()).thenReturn("OK");
when(responseHttps.getStatus()).thenReturn(200);
when(headers.getFirst("Location")).thenReturn("https://localhost:2345");
when(getAliveRequest.asString()).thenReturn(response);
when(getAliveRequestHttps.asString()).thenReturn(responseHttps);
when(unirestInstance.get(SERVER_URL + "/variable/api/")).thenReturn(getAliveRequest);
when(Unirest.get("https://localhost:2345/variable/api/")).thenReturn(getAliveRequestHttps);
SeleniumRobotVariableServerConnector connector = new SeleniumRobotVariableServerConnector(true, SERVER_URL, "Test1", null);
Assert.assertEquals(connector.getUrl(), "https://localhost:2345");
}
Aggregations