private void subscribeToAddressBookNotifications(String userID, int i) {
    String test = "Subscribing User 1 to Address Book Notifications";
    startTest(test);

    String clientCorrelator = Long.toString(System.currentTimeMillis());
    String callback = callbackURL[i];
    String requestData = requestDataClean(addressBookRequestData, clientCorrelator, callback);
    String url = replace(addressBookSubscriptionURL, apiVersion, userID);

    RestAssured.authentication = RestAssured.basic(userID, applicationPassword);

    Response response =
        RestAssured.given()
            .contentType("application/json")
            .body(requestData)
            .expect()
            .log()
            .ifError()
            .statusCode(201)
            .post(url);

    JsonPath jsonData = response.jsonPath();
    subscriptionURL[i] = jsonData.getString("abChangesSubscription.resourceURL");
    LOGGER.info("Response received = " + response.getStatusCode());
    LOGGER.info("Body = " + response.asString());

    endTest(test);
  }
  /**
   * 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);
    }
  }
  @Test
  public void adhocIMChat6() throws JsonGenerationException, JsonMappingException, IOException {
    Setup.startTest("Checking that User 1 has received a chat message");

    receiveMessageStatusURL = INVALID;
    String url = (Setup.channelURL[1].split("username\\=")[0]) + "username="******"notificationList.messageNotification.chatMessage.text",
                    Matchers.hasItem("how are you"),
                "notificationList.messageNotification.sessionId", Matchers.hasItem("adhoc"),
                "notificationList.messageNotification.messageId", Matchers.notNullValue(),
                "notificationList.messageNotification.senderAddress",
                    Matchers.hasItem(Setup.TestUser2Contact),
                "notificationList.messageNotification.link", Matchers.notNullValue())
            .post(url);
    System.out.println("Response = " + response.getStatusCode() + " / " + response.asString());

    receiveMessageStatusURL =
        response.jsonPath().getString("notificationList.messageNotification[0].link[0].href");
    System.out.println("message status URL = " + receiveMessageStatusURL);
    Setup.endTest();
  }
  @Test
  public void sessionIMChatAccept13()
      throws JsonGenerationException, JsonMappingException, IOException {
    Setup.majorTest("Chat/IM", "isComposing functionality between users 3 and 4");

    Setup.startTest("Send isComposing from User 3");
    IsComposing isComposing = new IsComposing("active", new java.util.Date(), "text/plain", 60);
    ObjectMapper mapper = new ObjectMapper();
    String jsonRequestData = "{\"isComposing\":" + mapper.writeValueAsString(isComposing) + "}";

    System.out.println("Sending " + jsonRequestData);
    RestAssured.authentication = RestAssured.basic(Setup.TestUser3, Setup.applicationPassword);
    Response resp =
        RestAssured.given()
            .contentType("application/json")
            .body(jsonRequestData)
            .expect()
            .log()
            .ifError()
            .statusCode(204)
            .post(Setup.sendIMURL(Setup.TestUser3, Setup.TestUser4Contact, sessionID));

    System.out.println("Response = " + resp.getStatusCode() + " / " + resp.asString());
    Setup.endTest();
  }
Beispiel #5
0
  @Test
  public void logAllWhenBaseURIIsDefinedUsingRequestLogSpec() throws Exception {
    final StringWriter writer = new StringWriter();
    final PrintStream captor = new PrintStream(new WriterOutputStream(writer), true);
    RestAssured.baseURI = "http://localhost:8080/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/\nProxy:\t\t\t<none>\nRequest params:\t<none>\nQuery params:\t<none>\nForm params:\t<none>\nPath params:\t<none>\nMultiparts:\t\t<none>\nHeaders:\t\tAccept=*/*\n\t\t\t\tContent-Type=text/plain; charset="
                + RestAssured.config().getEncoderConfig().defaultContentCharset()
                + "\nCookies:\t\t<none>\nBody:\nhello"
                + LINE_SEPARATOR));
  }
  /**
   * Test the creation of a single entity with generated UUID and given name. This method also tests
   * the contents of the JSON response and reasonable query and serialization time.
   */
  public void test020CreateNamedTestObject() {

    // create named object
    String location =
        RestAssured.given()
            .contentType("application/json; charset=UTF-8")
            .body(" { \"name\" : \"test\" } ")
            .expect()
            .statusCode(201)
            .when()
            .post("/test_objects")
            .getHeader("Location");

    // POST must return a Location header
    assertNotNull(location);

    String uuid = getUuidFromLocation(location);

    // POST must create a UUID
    assertNotNull(uuid);
    assertFalse(uuid.isEmpty());
    assertTrue(uuid.matches("[a-f0-9]{32}"));

    // check for exactly one object
    RestAssured.given()
        .contentType("application/json; charset=UTF-8")
        .expect()
        .statusCode(200)
        .body("result_count", equalTo(1))
        .body("query_time", lessThan("0.5"))
        .body("serialization_time", lessThan("0.05"))
        .body("result", isEntity(TestObject.class))
        .when()
        .get("/test_objects/" + uuid);
  }
  @Test
  public void sessionIMChatAccept21()
      throws JsonGenerationException, JsonMappingException, IOException {
    Setup.startTest("Send invalid isComposing from User 4");
    IsComposing isComposing = new IsComposing("rubbish", new java.util.Date(), "text/plain", 60);
    ObjectMapper mapper = new ObjectMapper();
    String jsonRequestData = "{\"isComposing\":" + mapper.writeValueAsString(isComposing) + "}";

    System.out.println("Sending " + jsonRequestData);
    RestAssured.authentication = RestAssured.basic(Setup.TestUser4, Setup.applicationPassword);
    Response resp =
        RestAssured.given()
            .contentType("application/json")
            .body(jsonRequestData)
            .expect()
            .log()
            .ifError()
            .statusCode(400)
            .post(Setup.sendIMURL(Setup.TestUser4, Setup.TestUser3Contact, receiveSessionID));
    /*
     * 400 / {"requestError": {"serviceException": {
     * "messageId":"SVC002","variables": ["State is not valid. Received 'rubbish'"],"text":"Invalid input value for message. Part %0"}}}
     */
    System.out.println("Response = " + resp.getStatusCode() + " / " + resp.asString());
    Setup.endTest();
  }
  @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();
    }
  }
 @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();
   }
 }
  @Test
  public void adhocIMChat8() {
    Setup.startTest("Checking IM notifications for user 2");
    RestAssured.authentication = RestAssured.basic(Setup.TestUser2, Setup.applicationPassword);
    String url = (Setup.channelURL[2].split("username\\=")[0]) + "username="******"notificationList.chatEventNotification.eventType", Matchers.hasItem("Accepted"),
				"notificationList.chatEventNotification.sessionId", Matchers.hasItem("adhoc")
				).*/ post(url);
    System.out.println(
        "Response = " + notifications2.getStatusCode() + " / " + notifications2.asString());
    Setup.endTest();
  }
 @Test
 public void sessionIMChatAccept10() {
   Setup.startTest("Checking the receiver status");
   RestAssured.authentication = RestAssured.basic(Setup.TestUser4, Setup.applicationPassword);
   Response status =
       RestAssured.given()
           .expect()
           .log()
           .ifError()
           .statusCode(200)
           .body("messageStatusReport.status", Matchers.equalTo("DISPLAYED"))
           .get(Setup.prepareForTest(receiveMessageStatusURL));
   System.out.println("Response = " + status.getStatusCode() + " / " + status.asString());
   Setup.endTest();
 }
 @Test
 public void adhocIMChat2() {
   Setup.startTest("Checking the sender status");
   RestAssured.authentication = RestAssured.basic(Setup.TestUser1, Setup.applicationPassword);
   Response status =
       RestAssured.given()
           .expect()
           .log()
           .ifError()
           .statusCode(200)
           .body("messageStatusReport.status", Matchers.is("DISPLAYED"))
           .get(sendMessageStatusURL);
   System.out.println("Response = " + status.getStatusCode() + " / " + status.asString());
   Setup.endTest();
 }
Beispiel #13
0
  @Test
  @RunAsClient
  public void testResourceOwnerPasswordFlowWithFormClientCredentials() throws Exception {
    RestAssured.enableLoggingOfRequestAndResponseIfValidationFails();

    Response response =
        given()
            .redirects()
            .follow(false)
            .contentType("application/x-www-form-urlencoded")
            .formParam("grant_type", "password")
            .formParam("username", "jduke")
            .formParam("password", "1234")
            .formParam("client_id", "sample")
            .formParam("client_secret", "password")
            .when()
            .post(SampleRequest.TOKEN_ENDPOINT)
            .then()
            .statusCode(200)
            .body("access_token", Matchers.not(Matchers.isEmptyOrNullString()))
            .body("refresh_token", Matchers.not(Matchers.isEmptyOrNullString()))
            .body("expires_in", Matchers.not(Matchers.isEmptyOrNullString()))
            .body("token_type", Matchers.is("Bearer"))
            .header("Pragma", "no-cache")
            .header("Cache-Control", "no-store")
            .extract()
            .response();
    System.out.println(response.asString());
    String accessToken = response.jsonPath().getString("access_token");

    SampleRequest.verify(accessToken);
  }
  @Test
  public void sessionIMChatAccept2() {
    Setup.startTest("Checking IM notifications for user 3");
    RestAssured.authentication = RestAssured.DEFAULT_AUTH;
    String url = (Setup.channelURL[3].split("username\\=")[0]) + "username="******"notificationList", Matchers.notNullValue())
            .post(url);
    System.out.println(
        "Response = " + notifications3.getStatusCode() + " / " + notifications3.asString());

    /*
    * {"notificationList":[{"messageStatusNotification": {"callbackData":"GSMA3","link": [{"rel":"ChatMessage","href":"http://api.oneapi-gw.gsma.com/chat/0.1/%2B15554000003/oneToOne/tel%3A%2B15554000004//messages/1352666437776-470267184"}],
    * "status":"Delivered","messageId":"1352666437776-470267184"}},
    * {"messageStatusNotification": {"callbackData":"GSMA3","link": [{"rel":"ChatMessage","href":"http://api.oneapi-gw.gsma.com/chat/0.1/%2B15554000003/oneToOne/tel%3A%2B15554000004//messages/1352666437776-470267184"}],
    * "status":"Displayed","messageId":"1352666437776-470267184"}},
    * {"chatEventNotification": {"callbackData":"GSMA3","link": [{"rel":"ChatSessionInformation","href":"http://api.oneapi-gw.gsma.com/chat/0.1/%2B15554000003/oneToOne/tel%3A%2B15554000004/373305033"}],
    * "eventType":"Accepted","sessionId":"373305033"}}]}

    */
    JsonPath jsonData = notifications3.jsonPath();
    sentMessageID = jsonData.getString("notificationList.messageStatusNotification[0].messageId");
    System.out.println("Extracted messageId=" + sentMessageID);
    sendSessionURL = jsonData.getString("notificationList.chatEventNotification.link[0].href[0]");
    System.out.println("Extracted sendSessionURL=" + sendSessionURL);
    sessionID = jsonData.getString("notificationList.chatEventNotification.sessionId[0]");
    System.out.println("Extracted sessionId=" + sessionID);

    Setup.endTest();
  }
 @Test
 public void sessionIMChatAccept5() {
   Setup.startTest("Checking IM notifications for user 4");
   String url = (Setup.channelURL[4].split("username\\=")[0]) + "username="******"notificationList.messageNotification[0].senderAddress",
                   Matchers.containsString(Setup.cleanPrefix(Setup.TestUser3Contact)),
               "notificationList.messageNotification[0].chatMessage.text",
                   Matchers.equalTo("hello user4"))
           .post(url);
   System.out.println(
       "Response = " + notifications4.getStatusCode() + " / " + notifications4.asString());
   /*
    * {"notificationList":[{"messageNotification":
    * {"callbackData":"GSMA3","link":
    * [{"rel":"MessageStatusReport","href":"http://api.oneapi-gw.gsma.com/chat/0.1/%2B15554000004/oneToOne/tel%3A%2B15554000003/-797939895/messages/1352475373833-1790113032/status"}],
    * "dateTime":"2012-11-09T15:36:13Z","chatMessage":{"text":"hello user4"},"sessionId":"-797939895","messageId":"1352475373833-1790113032",
    * "senderAddress":"tel:+15554000003"}}]}
    */
   try {
     Thread.sleep(1000);
   } catch (InterruptedException e) {
   }
   Setup.endTest();
 }
Beispiel #16
0
  @Test
  public void loggingRequestAndResponseAtTheSameTimeWhenResponseFilterIsAddedBeforeRequestFilter()
      throws Exception {
    final StringWriter writer = new StringWriter();
    final PrintStream captor = new PrintStream(new WriterOutputStream(writer), true);

    final ScalatraObject object = new ScalatraObject();
    object.setHello("Hello world");
    given()
        .filters(new ResponseLoggingFilter(captor), new RequestLoggingFilter(captor))
        .body(object)
        .expect()
        .defaultParser(JSON)
        .when()
        .post("/reflect");

    assertThat(
        writer.toString(),
        equalTo(
            "Request method:\tPOST\nRequest path:\thttp://localhost:8080/reflect\nProxy:\t\t\t<none>\nRequest params:\t<none>\nQuery params:\t<none>\nForm params:\t<none>\nPath params:\t<none>\nMultiparts:\t\t<none>\nHeaders:\t\tAccept=*/*\n\t\t\t\tContent-Type=text/plain; charset="
                + RestAssured.config().getEncoderConfig().defaultContentCharset()
                + "\nCookies:\t\t<none>\nBody:\n{\"hello\":\"Hello world\"}"
                + LINE_SEPARATOR
                + "HTTP/1.1 200 OK\nContent-Type: text/plain; charset=iso-8859-1\nContent-Length: 23\nServer: Jetty(6.1.14)\n\n{\"hello\":\"Hello world\"}"
                + LINE_SEPARATOR));
  }
Beispiel #17
0
  @Test
  public void loggingRequestFilterWithParamsCookiesAndHeaders() throws Exception {
    final StringWriter writer = new StringWriter();
    final PrintStream captor = new PrintStream(new WriterOutputStream(writer), true);
    given()
        .filter(new RequestLoggingFilter(captor))
        .formParam("firstName", "John")
        .formParam("lastName", "Doe")
        .queryParam("something1", "else1")
        .queryParam("something2", "else2")
        .queryParam("something3", "else3")
        .param("hello1", "world1")
        .param("hello2", "world2")
        .param("multiParam", "multi1", "multi2")
        .cookie("multiCookie", "value1", "value2")
        .cookie("standardCookie", "standard value")
        .header("multiHeader", "headerValue1", "headerValue2")
        .header("standardHeader", "standard header value")
        .expect()
        .body("greeting", equalTo("Greetings John Doe"))
        .when()
        .post("/greet");

    assertThat(
        writer.toString(),
        equalTo(
            "Request method:\tPOST\nRequest path:\thttp://localhost:8080/greet?something1=else1&something2=else2&something3=else3\nProxy:\t\t\t<none>\nRequest params:\thello1=world1\n\t\t\t\thello2=world2\n\t\t\t\tmultiParam=[multi1, multi2]\nQuery params:\tsomething1=else1\n\t\t\t\tsomething2=else2\n\t\t\t\tsomething3=else3\nForm params:\tfirstName=John\n\t\t\t\tlastName=Doe\nPath params:\t<none>\nMultiparts:\t\t<none>\nHeaders:\t\tmultiHeader=headerValue1\n\t\t\t\tmultiHeader=headerValue2\n\t\t\t\tstandardHeader=standard header value\n\t\t\t\tAccept=*/*\n"
                + "\t\t\t\tContent-Type=application/x-www-form-urlencoded; charset="
                + RestAssured.config().getEncoderConfig().defaultContentCharset()
                + "\nCookies:\t\tmultiCookie=value1\n\t\t\t\tmultiCookie=value2\n\t\t\t\tstandardCookie=standard value\nBody:\t\t\t<none>"
                + LINE_SEPARATOR));
  }
Beispiel #18
0
  @Test
  public void
      doesnt_include_default_charset_in_request_log_when_it_is_configured_not_to_be_added() {
    final StringWriter writer = new StringWriter();
    final PrintStream captor = new PrintStream(new WriterOutputStream(writer), true);

    given()
        .filter(logRequestTo(captor))
        .config(
            RestAssured.config()
                .encoderConfig(
                    encoderConfig().appendDefaultContentCharsetToContentTypeIfUndefined(false)))
        .param("foo", "bar")
        .contentType(ContentType.XML)
        .when()
        .post("/contentTypeAsBody")
        .then()
        .statusCode(200);

    assertThat(
        writer.toString(),
        equalTo(
            "Request method:\tPOST\nRequest path:\thttp://localhost:8080/contentTypeAsBody\nProxy:\t\t\t<none>\nRequest params:\tfoo=bar\nQuery params:\t<none>\nForm params:\t<none>\nPath params:\t<none>\nMultiparts:\t\t<none>\nHeaders:\t\tAccept=*/*\n\t\t\t\tContent-Type=application/xml\nCookies:\t\t<none>\nBody:\t\t\t<none>"
                + LINE_SEPARATOR));
  }
 @Before
 public void setUp() {
   RestAssured.baseURI = TestUtils.HTTPBaseUrl;
   RestAssured.port = 6060;
   RestAssured.basePath = "";
   RestAssured.enableLoggingOfRequestAndResponseIfValidationFails();
 }
  @Test
  public void sessionIMChatAccept1A() {
    Setup.startTest("Checking IM notifications for user 4");
    String url = (Setup.channelURL[4].split("username\\=")[0]) + "username="******"notificationList.chatSessionInvitationNotification", Matchers.notNullValue(),
                "notificationList.messageNotification.dateTime", Matchers.notNullValue(),
                "notificationList.messageNotification.messageId", Matchers.notNullValue(),
                "notificationList.messageNotification.senderAddress[0]",
                    Matchers.containsString(Setup.cleanPrefix(Setup.TestUser3Contact)))
            .post(url);
    System.out.println(
        "Response = " + notifications4.getStatusCode() + " / " + notifications4.asString());

    JsonPath jsonData = notifications4.jsonPath();

    receiveSessionURL =
        jsonData.getString("notificationList.chatSessionInvitationNotification[0].link[0].href");
    System.out.println("Extracted receiveSessionURL=" + receiveSessionURL);

    receiveSessionID = jsonData.getString("notificationList.messageNotification.sessionId[0]");
    System.out.println("Extracted receiveSessionID=" + receiveSessionID);

    receiveMessageID = jsonData.getString("notificationList.messageNotification.messageId[0]");
    System.out.println("Extracted receiveMessageID=" + receiveMessageID);

    Setup.endTest();
  }
  @Test
  public void sessionIMChatAccept8()
      throws JsonGenerationException, JsonMappingException, IOException {
    Setup.startTest("Checking that User 3 has received a chat message");

    receiveMessageStatusURL = INVALID;

    RestAssured.authentication = RestAssured.DEFAULT_AUTH;
    String url = (Setup.channelURL[3].split("username\\=")[0]) + "username="******"notificationList.messageNotification.chatMessage.text",
                    Matchers.hasItem("I am good"),
                "notificationList.messageNotification.sessionId", Matchers.hasItem(sessionID),
                "notificationList.messageNotification.messageId", Matchers.notNullValue(),
                "notificationList.messageNotification.senderAddress",
                    Matchers.hasItem(Setup.TestUser4Contact),
                "notificationList.messageNotification.link", Matchers.notNullValue())
            .post(url);
    System.out.println("Response = " + response.getStatusCode() + " / " + response.asString());

    receiveMessageStatusURL =
        response.jsonPath().getString("notificationList.messageNotification[0].link[0].href");
    System.out.println("message status URL = " + receiveMessageStatusURL);
    try {
      Thread.sleep(1000);
    } catch (InterruptedException e) {
    }
    Setup.endTest();
  }
  @Test
  public void sessionIMChatAccept23()
      throws JsonGenerationException, JsonMappingException, IOException {
    Setup.startTest("Checking that User 3 has received chat closed notification");

    System.out.println("sessionID=" + sessionID);
    System.out.println("receiveSessionID=" + receiveSessionID);

    RestAssured.authentication = RestAssured.DEFAULT_AUTH;
    String url = (Setup.channelURL[3].split("username\\=")[0]) + "username="******"notificationList.chatEventNotification.eventType",
                    Matchers.hasItem("SessionEnded"),
                "notificationList.chatEventNotification.sessionId", Matchers.hasItem(sessionID),
                "notificationList.chatEventNotification.link[0].rel",
                    Matchers.hasItem("ChatSessionInformation"))
            .post(url);
    System.out.println("Response = " + response.getStatusCode() + " / " + response.asString());
    Setup.endTest();
  }
 @Test
 public void sessionIMChatAccept22()
     throws JsonGenerationException, JsonMappingException, IOException {
   Setup.startTest("Close chat by User 4");
   RestAssured.authentication = RestAssured.basic(Setup.TestUser4, Setup.applicationPassword);
   Response resp =
       RestAssured.given()
           .expect()
           .log()
           .ifError()
           .statusCode(204)
           .delete(
               Setup.chatSessionIMURL(Setup.TestUser4, Setup.TestUser3Contact, receiveSessionID));
   System.out.println("Response = " + resp.getStatusCode() + " / " + resp.asString());
   Setup.endTest();
 }
  @Test
  public void sessionIMChatAccept18()
      throws JsonGenerationException, JsonMappingException, IOException {
    Setup.startTest("Checking that User 4 has received composing notification");

    RestAssured.authentication = RestAssured.DEFAULT_AUTH;
    String url = (Setup.channelURL[4].split("username\\=")[0]) + "username="******"notificationList.messageNotification[0].isComposing.refresh", Matchers.equalTo(60),
                "notificationList.messageNotification[0].isComposing.status",
                    Matchers.equalTo("idle"),
                "notificationList.messageNotification[0].sessionId",
                    Matchers.equalTo(receiveSessionID),
                "notificationList.messageNotification[0].senderAddress",
                    Matchers.containsString(Setup.cleanPrefix(Setup.TestUser3Contact)))
            .post(url);
    System.out.println("Response = " + response.getStatusCode() + " / " + response.asString());
    Setup.endTest();
  }
Beispiel #25
0
 @Test
 public void ListAllPatients() {
   com.jayway.restassured.RestAssured.expect()
       .log()
       .all()
       .when()
       .get("http://opmfrontend21.cloudfoundry.com/patient/index/");
 }
 @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");
 }
Beispiel #27
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();
    }
  }
  @Test
  public void updateSubscriptionForUser1() {
    String userID = user1;
    int i = 1;

    startNotificationChannel(userID, i);
    subscribeToAddressBookNotifications(userID, i);

    String test = "Updating/Extending the Subscription to Address Book Notifications for User 1";
    startTest(test);

    String clientCorrelator = Long.toString(System.currentTimeMillis());
    String callback = callbackURL[i];
    String requestData = requestDataClean(updateAddressBookRequestData, clientCorrelator, callback);
    String cleanUserID = cleanPrefix(userID);
    String url = subscriptionURL[i];
    url = prepare(url);

    RestAssured.authentication = RestAssured.basic(userID, applicationPassword);

    Response response =
        RestAssured.given()
            .contentType("application/json")
            .body(requestData)
            .expect()
            .log()
            .ifError()
            .statusCode(200)
            .body(
                "abChangesSubscription.resourceURL",
                StringContains.containsString(cleanUserID),
                "abChangesSubscription.callbackReference.callbackData",
                IsEqual.equalTo("GSMA1"),
                "abChangesSubscription.callbackReference.notifyURL",
                IsEqual.equalTo(callbackURL[i]),
                "abChangesSubscription.callbackReference.notificationFormat",
                IsEqual.equalTo("JSON"))
            .put(url);

    LOGGER.info("Response Received = " + response.getStatusCode());
    LOGGER.info("Body = " + response.asString());

    endTest(test);
  }
 /**
  * Junit test method for topology nodes Tests if /rest/topo returns status code OK (200) Tests if
  * the returned JSON contains a field "nodes"
  */
 @Test
 public void testTopologyNodes() {
   RestAssured.registerParser("text/plain", Parser.JSON);
   expect()
       .get("/rest/topo")
       .then()
       .statusCode(200)
       .assertThat()
       .body("nodes", Matchers.notNullValue());
 }
Beispiel #30
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();
   }
 }