예제 #1
0
  @Test
  public void logAllWhenBasePathAndBasePortAndBaseURIIsDefinedUsingRequestLogSpec()
      throws Exception {
    final StringWriter writer = new StringWriter();
    final PrintStream captor = new PrintStream(new WriterOutputStream(writer), true);
    RestAssured.baseURI = "http://localhost";
    RestAssured.port = 8080;
    RestAssured.basePath = "/reflect";

    try {
      given()
          .config(config().logConfig(new LogConfig(captor, true)))
          .log()
          .all()
          .body("hello")
          .when()
          .post("/");
    } finally {
      RestAssured.reset();
    }

    assertThat(
        writer.toString(),
        equalTo(
            "Request method:\tPOST\nRequest path:\thttp://localhost:8080/reflect/\nRequest params:\t<none>\nQuery params:\t<none>\nForm params:\t<none>\nPath params:\t<none>\nHeaders:\t\tContent-Type=*/*\nCookies:\t\t<none>\nBody:\nhello"
                + LINE_SEPARATOR));
  }
예제 #2
0
 @Test
 public void usingStaticallyConfiguredCertificateAuthenticationWorks() throws Exception {
   RestAssured.authentication =
       certificate("truststore_eurosport.jks", "test4321", certAuthSettings().allowAllHostnames());
   try {
     get("https://tv.eurosport.com/").then().body(containsString("eurosport"));
   } finally {
     RestAssured.reset();
   }
 }
예제 #3
0
 @Test
 public void whenEnablingAllowAllHostNamesVerifierWithoutActivatingAKeyStoreTheCallTo()
     throws Exception {
   RestAssured.config = config().sslConfig(sslConfig().allowAllHostnames());
   try {
     get("https://tv.eurosport.com/").then().body(containsString("eurosport"));
   } finally {
     RestAssured.reset();
   }
 }
예제 #4
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();
    }
  }
예제 #5
0
 @Test(expected = SSLException.class)
 public void
     usingStaticallyConfiguredCertificateAuthenticationWithIllegalHostNameInCertDoesntWork()
         throws Exception {
   RestAssured.authentication = certificate("truststore_mjvmobile.jks", "test4321");
   try {
     get("https://tv.eurosport.com/").then().body(containsString("eurosport"));
   } finally {
     RestAssured.reset();
   }
 }
예제 #6
0
 @Test
 public void
     givenKeystoreDefinedStaticallyWhenSpecifyingJksKeyStoreFileWithCorrectPasswordAllowsToUseSSL()
         throws Exception {
   RestAssured.keystore("truststore_eurosport.jks", "test4321");
   try {
     expect().body(containsString("eurosport")).get("https://tv.eurosport.com/");
   } finally {
     RestAssured.reset();
   }
 }
예제 #7
0
 @Test
 public void
     usingStaticallyConfiguredCertificateAuthenticationWithIllegalHostNameInCertWorksWhenSSLConfigIsConfiguredToAllowAllHostNames()
         throws Exception {
   RestAssured.config = newConfig().sslConfig(sslConfig().allowAllHostnames());
   RestAssured.authentication = certificate("truststore_eurosport.jks", "test4321");
   try {
     get("https://tv.eurosport.com/").then().body(containsString("eurosport"));
   } finally {
     RestAssured.reset();
   }
 }
예제 #8
0
  @Test
  public void truststrore_works_with_static_base_uri() throws Exception {
    RestAssured.baseURI = "https://bunny.cloudamqp.com/";

    InputStream keyStoreStream =
        Thread.currentThread()
            .getContextClassLoader()
            .getResourceAsStream("truststore_cloudamqp.jks");
    KeyStore keyStore = KeyStore.getInstance(KeyStore.getDefaultType());
    keyStore.load(keyStoreStream, "cloud1234".toCharArray());

    try {
      given().trustStore(keyStore).when().get("/api/").then().statusCode(200);
    } finally {
      RestAssured.reset();
    }
  }
예제 #9
0
  @Test
  public void keystore_works_with_static_base_uri() {
    RestAssured.baseURI = "https://tv.eurosport.com/";

    try {
      given()
          .keystore("/truststore_eurosport.jks", "test4321")
          .when()
          .get()
          .then()
          .statusCode(200)
          .and()
          .body(containsString("eurosport"));
    } finally {
      RestAssured.reset();
    }
  }
예제 #10
0
  @Test
  public void allows_specifying_trust_store_statically() throws Exception {

    InputStream keyStoreStream =
        Thread.currentThread()
            .getContextClassLoader()
            .getResourceAsStream("truststore_cloudamqp.jks");
    KeyStore keyStore = KeyStore.getInstance(KeyStore.getDefaultType());
    keyStore.load(keyStoreStream, "cloud1234".toCharArray());

    RestAssured.trustStore(keyStore);

    try {
      get("https://bunny.cloudamqp.com/api/").then().statusCode(200);
    } finally {
      RestAssured.reset();
    }
  }
 @AfterClass
 public static void tearDownClass(TestContext context) {
   vertx.close(context.asyncAssertSuccess());
   RestAssured.reset();
 }
 /** Sets up before each test method. */
 @Before
 public void setUp() {
   RestAssured.reset();
   RestAssured.port = RESOURCE_ENDPOINT_PORT;
   RestAssured.basePath = RESOURCES_BASE_PATH;
 }
예제 #13
0
 @After
 public void teardown() throws Exception {
   RestAssured.reset();
 }
 @AfterClass
 public static void teardown() throws Exception {
   RestAssured.reset();
 }