Guest User

Untitled

a guest
Feb 2nd, 2018
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.00 KB | None | 0 0
  1. public class QueryEndpoint {
  2.  
  3. @BeforeClass
  4. public static void setup() {
  5.  
  6. String username = "username111";
  7. String password = "password222";
  8. StringBuilder authorization = new StringBuilder();
  9. authorization.append(username).append(":").append(password);
  10. String authHeader = "Basic " + Base64.getEncoder().encodeToString(authorization.toString().getBytes());
  11. }
  12.  
  13. package com.example.tests;
  14.  
  15. import com.jayway.restassured.authentication.PreemptiveBasicAuthScheme;
  16. import com.example.misc.QueryEndpoint;
  17.  
  18. public class ApiTest extends QueryEndpoint {
  19.  
  20. @Test
  21. public void verifyTopLevelURL() {
  22. given()
  23. .header("Authorization", authScheme) // <--HERE
  24. .contentType("application/json")
  25. .when().get("/22222222").then()
  26. .body("fruit",equalTo("22222222"))
  27. .body("fruit.apple",equalTo(37))
  28. .body("fruit.banana",equalTo("111"))
  29. .statusCode(200);
  30. }
  31. }
Add Comment
Please, Sign In to add comment