Migrate to new HttpHeaders API

See gh-45487

Co-authored-by: Phillip Webb <phil.webb@broadcom.com>
This commit is contained in:
Stéphane Nicoll
2025-05-07 13:09:53 -07:00
committed by Phillip Webb
parent 6fceab2c90
commit 5ea0674bad
17 changed files with 73 additions and 64 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2023 the original author or authors.
* Copyright 2012-2025 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -46,7 +46,7 @@ abstract class AbstractSampleActuatorCustomSecurityTests {
@SuppressWarnings("rawtypes")
ResponseEntity<Map> entity = restTemplate().getForEntity(getPath() + "/", Map.class);
assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.UNAUTHORIZED);
assertThat(entity.getHeaders()).doesNotContainKey("Set-Cookie");
assertThat(entity.getHeaders().headerNames()).doesNotContain("Set-Cookie");
}
@Test

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2023 the original author or authors.
* Copyright 2012-2025 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -53,7 +53,7 @@ class ManagementPathSampleActuatorApplicationTests {
void testHomeIsSecure() {
ResponseEntity<Map<String, Object>> entity = asMapEntity(this.restTemplate.getForEntity("/", Map.class));
assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.UNAUTHORIZED);
assertThat(entity.getHeaders()).doesNotContainKey("Set-Cookie");
assertThat(entity.getHeaders().headerNames()).doesNotContain("Set-Cookie");
}
@SuppressWarnings({ "unchecked", "rawtypes" })

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2024 the original author or authors.
* Copyright 2012-2025 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -57,7 +57,7 @@ class SampleActuatorApplicationTests {
void testHomeIsSecure() {
ResponseEntity<Map<String, Object>> entity = asMapEntity(this.restTemplate.getForEntity("/", Map.class));
assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.UNAUTHORIZED);
assertThat(entity.getHeaders()).doesNotContainKey("Set-Cookie");
assertThat(entity.getHeaders().headerNames()).doesNotContain("Set-Cookie");
}
@Test

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2023 the original author or authors.
* Copyright 2012-2025 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -61,7 +61,7 @@ class ServletPathSampleActuatorApplicationTests {
void testHomeIsSecure() {
ResponseEntity<Map<String, Object>> entity = asMapEntity(this.restTemplate.getForEntity("/spring/", Map.class));
assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.UNAUTHORIZED);
assertThat(entity.getHeaders()).doesNotContainKey("Set-Cookie");
assertThat(entity.getHeaders().headerNames()).doesNotContain("Set-Cookie");
}
@SuppressWarnings({ "unchecked", "rawtypes" })

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2024 the original author or authors.
* Copyright 2012-2025 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -54,7 +54,7 @@ class MessageControllerWebTests {
assertThat(this.mvc.post().uri("/").param("text", "FOO text").param("summary", "FOO"))
.hasStatus(HttpStatus.FOUND)
.headers()
.hasEntrySatisfying("Location",
.hasHeaderSatisfying("Location",
(values) -> assertThat(values).hasSize(1)
.element(0)
.satisfies(HamcrestCondition.matching(RegexMatcher.matches("/[0-9]+"))));

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2024 the original author or authors.
* Copyright 2012-2025 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -54,7 +54,7 @@ class MessageControllerWebTests {
assertThat(this.mvc.post().uri("/").param("text", "FOO text").param("summary", "FOO"))
.hasStatus(HttpStatus.FOUND)
.headers()
.hasEntrySatisfying("Location",
.hasHeaderSatisfying("Location",
(values) -> assertThat(values).hasSize(1)
.element(0)
.satisfies(HamcrestCondition.matching(RegexMatcher.matches("/[0-9]+"))));