本文整理汇总了Java中io.restassured.http.Header类的典型用法代码示例。如果您正苦于以下问题:Java Header类的具体用法?Java Header怎么用?Java Header使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Header类属于io.restassured.http包,在下文中一共展示了Header类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testLogout
import io.restassured.http.Header; //导入依赖的package包/类
@Test
public void testLogout() {
User user = createUser();
//@formatter:off
Header xAuthTokenHeaderForUser = getXAuthTokenHeaderForUser(user);
given().
header(xAuthTokenHeaderForUser).
when().
post("/logout").
then().
statusCode(HttpStatus.SC_OK);
//@formatter:on
//@formatter:off
given().
header(xAuthTokenHeaderForUser).
when().
get("/token/verify").
then().
statusCode(HttpStatus.SC_UNAUTHORIZED);
//@formatter:on
}
示例2: logHeaders
import io.restassured.http.Header; //导入依赖的package包/类
/**
* @author wasiq.bhamla
* @since Sep 18, 2017 8:11:09 PM
*/
private void logHeaders () {
final LoggingSetting logging = this.setting.getLogging ();
if (logging.isLogHeaders ()) {
final Headers headers = this.response.headers ();
LOG.info (LINE);
LOG.info ("Response Headers:");
LOG.info (LINE);
for (final Header header : headers.asList ()) {
LOG.info (format ("%s: %s", header.getName (), header.getValue ()));
}
}
}
示例3: TracksResponse
import io.restassured.http.Header; //导入依赖的package包/类
public TracksResponse(Response response) {
this.statusCode = response.getStatusCode();
this.responseHeaders = new HashMap<>();
Headers headers = response.getHeaders();
for(Header header: headers){
responseHeaders.put(header.getName(), header.getValue());
}
this.body = response.body().asString();
}
示例4: testVerifyInvalidToken
import io.restassured.http.Header; //导入依赖的package包/类
@Test
public void testVerifyInvalidToken() {
Header header = new Header(AUTH_HEADER, "invalid");
//@formatter:off
given().
header(header).
when().
get("/token/verify").
then().
statusCode(HttpStatus.SC_UNAUTHORIZED);
//@formatter:on
}
示例5: testVerifyMissingToken
import io.restassured.http.Header; //导入依赖的package包/类
@Test
public void testVerifyMissingToken() {
Header header = new Header(AUTH_HEADER, "");
//@formatter:off
given().
header(header).
when().
get("/token/verify").
then().
statusCode(HttpStatus.SC_FORBIDDEN);
//@formatter:on
}
示例6: testAddMemberAsAdmin
import io.restassured.http.Header; //导入依赖的package包/类
@Test
public void testAddMemberAsAdmin() {
User captain = createUser();
User admin = createAdmin();
User member = createUser();
Team team = createTeamWithCaptain(captain);
//@formatter:off
Header header = getXAuthTokenHeaderForUser(admin);
given().
header(header).
when().
body(member.getEmail()).
post(TEAM_ENDPOINT + team.getId()).
then().
statusCode(HttpStatus.SC_OK);
given().
header(header).
when().
get(TEAM_ENDPOINT + team.getId()).
then().
statusCode(HttpStatus.SC_OK).
body("members.profile.displayName", hasItems(
captain.getProfile().getDisplayName(),
member.getProfile().getDisplayName())).
body("size", equalTo(2));
//@formatter:on
}
示例7: testInviteMemberTwiceAsCaptain
import io.restassured.http.Header; //导入依赖的package包/类
@Test
public void testInviteMemberTwiceAsCaptain() {
User captain = createUser();
User user = createUser();
Team team = createTeamWithCaptain(captain);
//@formatter:off
Header header = getXAuthTokenHeaderForUser(captain);
given().
header(header).
when().
body(user.getEmail()).
post(TEAM_ENDPOINT + team.getId() + "/invites").
then().
statusCode(HttpStatus.SC_OK);
given().
header(header).
when().
body(user.getEmail()).
post(TEAM_ENDPOINT + team.getId() + "/invites").
then().
statusCode(HttpStatus.SC_CONFLICT);
//@formatter:on
Collection<TeamInviteToken> tokens = teamInviteTokenRepository.findByUserEmailIgnoreCase(user.getEmail());
Assert.assertEquals(1, tokens.size());
}
示例8: testChangePassword
import io.restassured.http.Header; //导入依赖的package包/类
@Test
public void testChangePassword() {
//TODO: Move to new AuthenticationTest
User user = createUser();
String newPassword = "newPassword";
Map<String, String> passwordDTO = new HashMap<>();
passwordDTO.put("oldPassword", cleartextPassword);
passwordDTO.put("newPassword", newPassword);
//@formatter:off
Header xAuthTokenHeader = getXAuthTokenHeaderForUser(user);
given().
header(xAuthTokenHeader).
when().
body(passwordDTO).
contentType(ContentType.JSON).
post("/users/current/password").
then().
statusCode(HttpStatus.SC_OK);
//@formatter:on
removeXAuthToken(xAuthTokenHeader);
Map<String, String> userDTO = new HashMap<>();
userDTO.put("email", user.getEmail());
userDTO.put("password", newPassword);
//@formatter:off
given().
body(userDTO).
when().
post("/login").
then().
statusCode(HttpStatus.SC_OK).
header("X-Auth-Token", not(isEmptyOrNullString()));
//@formatter:on
}
示例9: testChangePasswordEmptyPassword
import io.restassured.http.Header; //导入依赖的package包/类
@Test
public void testChangePasswordEmptyPassword() {
//TODO: Move to new AuthenticationTest
User user = createUser();
String newPassword = "";
Map<String, String> passwordDTO = new HashMap<>();
passwordDTO.put("oldPassword", cleartextPassword);
passwordDTO.put("newPassword", newPassword);
//@formatter:off
Header xAuthTokenHeader = getXAuthTokenHeaderForUser(user);
given().
header(xAuthTokenHeader).
when().
body(passwordDTO).
contentType(ContentType.JSON).
post("/users/current/password").
then().
statusCode(HttpStatus.SC_BAD_REQUEST);
//@formatter:on
removeXAuthToken(xAuthTokenHeader);
Map<String, String> userDTO = new HashMap<>();
userDTO.put("email", user.getEmail());
userDTO.put("password", cleartextPassword);
//@formatter:off
given().
body(userDTO).
when().
post("/login").
then().
statusCode(HttpStatus.SC_OK).
header("X-Auth-Token", not(isEmptyOrNullString()));
//@formatter:on
}
示例10: cacheHeaders
import io.restassured.http.Header; //导入依赖的package包/类
private void cacheHeaders(Response response) {
clearOldHeaders();
Headers headers = response.getHeaders();
for (Header header : headers) {
String headerName = CukesOptions.HEADER_PREFIX + header.getName();
world.put(headerName, header.getValue());
}
}
示例11: map
import io.restassured.http.Header; //导入依赖的package包/类
public WebAddHeader map(Header header) {
WebAddHeader result = new WebAddHeader();
result.setName(header.getName());
result.setValue(header.getValue());
return result;
}
示例12: map
import io.restassured.http.Header; //导入依赖的package包/类
public WebCustomRequest map(FilterableRequestSpecification requestSpec) {
try {
URL url = new URL(requestSpec.getURI());
String method = String.valueOf(requestSpec.getMethod());
WebCustomRequest request = new WebCustomRequest();
request.setName(method + " to " + url.toString());
//Don't URL encode LR parameter boundaries (curly braces)
request.setUrl(url.toString().replace("%7B", "{").replace("%7D", "}"));
request.setMethod(method);
request.setResource("0");
request.setSnapshot(String.format("t%d.inf", (long) (System.currentTimeMillis() % Math.pow(10, 10))));
request.setMode(url.getProtocol());
request.setBody(requestSpec.getBody());
request.getBeforeFunctions().add(new WebRequestSaveParam());
request.getBeforeFunctions().add(new WebRequestSaveResponseBody());
request.getBeforeFunctions().add(new WebRequestSaveResponseHeaders());
for (Header header : requestSpec.getHeaders()) {
request.getBeforeFunctions().add(headerMapper.map(header));
}
return request;
} catch (MalformedURLException e) {
throw new RuntimeException(e);
}
}
示例13: addResponseHeaders
import io.restassured.http.Header; //导入依赖的package包/类
private void addResponseHeaders(ResponseDefinitionBuilder definition,
Response input) {
for (Header header : input.getHeaders().asList()) {
String name = header.getName();
definition.withHeader(name, input.getHeader(name));
}
}
示例14: getHeaders
import io.restassured.http.Header; //导入依赖的package包/类
@Override
public HttpHeaders getHeaders() {
List<HttpHeader> headers = new ArrayList<>();
for (Header header : request.getHeaders()) {
String value = header.getValue();
if ("accept".equals(header.getName().toLowerCase()) && "*/*".equals(value)) {
continue;
}
headers.add(new HttpHeader(header.getName(), header.getValue()));
}
return new HttpHeaders(headers);
}
示例15: getAllHeaderKeys
import io.restassured.http.Header; //导入依赖的package包/类
@Override
public Set<String> getAllHeaderKeys() {
Set<String> headers = new LinkedHashSet<>();
for (Header header : request.getHeaders()) {
String value = header.getValue();
if ("accept".equals(header.getName().toLowerCase()) && "*/*".equals(value)) {
continue;
}
headers.add(header.getName());
}
return headers;
}