/**
   * Create a RequestSpecification object as template, with host/port, user/pass, and certificate
   * info.
   *
   * @throws Exception in case of any issue
   */
  @Override
  public void connect() throws Exception {
    String host = sysConfig.getProperty(RestCommunication.SYSPROP_HOST, "localhost");
    int port = sysConfig.getIntProperty(RestCommunication.SYSPROP_PORT, 443);
    RestAssured.useRelaxedHTTPSValidation();
    this.reqSpec = RestAssured.given();

    if (port % 1000 == 443) {
      this.reqSpec = this.reqSpec.baseUri("https://" + host + ":" + port);
    } else {
      this.reqSpec = this.reqSpec.baseUri("http://" + host + ":" + port);
    }

    String user = sysConfig.getProperty(RestCommunication.SYSPROP_USER);
    String pass = sysConfig.getProperty(RestCommunication.SYSPROP_PASS);
    if (null != user && null != pass) {
      this.reqSpec = this.reqSpec.auth().preemptive().basic(user, pass);
    }

    String clientCert = sysConfig.getProperty(RestCommunication.SYSPROP_CLIENT_CERT);
    String clientCertPass = sysConfig.getProperty(RestCommunication.SYSPROP_CLIENT_CERT_PASS);
    if (null != clientCert && null != clientCertPass) {
      this.reqSpec = this.reqSpec.auth().certificate(clientCert, clientCertPass);
    }
  }
Esempio n. 2
0
  @Test
  public void relaxed_https_validation_works_when_defined_statically() {
    RestAssured.useRelaxedHTTPSValidation();

    try {
      get("https://bunny.cloudamqp.com/api/").then().statusCode(200);
    } finally {
      RestAssured.reset();
    }
  }
 @BeforeClass
 public void setupSecurityToken() {
   // Define relaxed SSL Auth, since we use self-signed certificates
   RestAssured.useRelaxedHTTPSValidation();
   // Register JSON Parser for plain text responses
   RestAssured.registerParser("text/plain", Parser.JSON);
   // Order and extract auth-token
   //        token =
   //                given().
   //                        param("grant_type", "password").
   //                        param("client_id", "acme").
   //                        param("username", "user").
   //                        param("password", "password").
   //                        when().post("https://*****:*****@" + apiServiceBaseURL +
   // ":9999/uaa/oauth/token").then().
   //                        extract().path("access_token");
 }
Esempio n. 4
0
 @BeforeClass
 public static void setUpBeforeClass() throws Exception {
   Utils.insertTestUser();
   Utils.insertTestRoles();
   useRelaxedHTTPSValidation();
   baseURI = "https://localhost:8443/rest/tasks";
   sessionFilter = new SessionFilter();
   om = new ObjectMapper();
   ds = Utils.getDataSource();
   given()
       .auth()
       .form(
           PermanentUserData.user.getEmail(),
           PermanentUserData.user.getPassword(),
           new FormAuthConfig("/j_security_check", "j_username", "j_password"))
       .filter(sessionFilter)
       .when()
       .get("/");
   given().filter(sessionFilter).get("https://localhost:8443/rest/users/web");
 }
 protected static RequestSpecification givenConfig() {
   RestAssured.useRelaxedHTTPSValidation();
   return given().header("Accept-Language", "en").header("Content-Type", "application/json");
 }