|
| 1 | +/* |
| 2 | + * Copyright (c) 2025 Oracle and/or its affiliates. |
| 3 | + * |
| 4 | + * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | + * you may not use this file except in compliance with the License. |
| 6 | + * You may obtain a copy of the License at |
| 7 | + * |
| 8 | + * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | + * |
| 10 | + * Unless required by applicable law or agreed to in writing, software |
| 11 | + * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | + * See the License for the specific language governing permissions and |
| 14 | + * limitations under the License. |
| 15 | + */ |
| 16 | +package io.helidon.webserver.observe.health; |
| 17 | + |
| 18 | +import io.helidon.common.testing.http.junit5.HttpHeaderMatcher; |
| 19 | +import io.helidon.http.HeaderNames; |
| 20 | +import io.helidon.webclient.http1.Http1Client; |
| 21 | +import io.helidon.webclient.http1.Http1ClientResponse; |
| 22 | +import io.helidon.webserver.testing.junit5.ServerTest; |
| 23 | + |
| 24 | +import org.junit.jupiter.api.Test; |
| 25 | + |
| 26 | +import static org.hamcrest.MatcherAssert.assertThat; |
| 27 | +import static org.hamcrest.Matchers.allOf; |
| 28 | + |
| 29 | +@ServerTest |
| 30 | +class TestNoCacheHeaders { |
| 31 | + |
| 32 | + private final Http1Client client; |
| 33 | + |
| 34 | + TestNoCacheHeaders(Http1Client client) { |
| 35 | + this.client = client; |
| 36 | + } |
| 37 | + |
| 38 | + @Test |
| 39 | + void testNoCacheHeaders() { |
| 40 | + try (Http1ClientResponse response = client |
| 41 | + .get("/observe/health") |
| 42 | + .request()) { |
| 43 | + |
| 44 | + assertThat("No-cache headers", |
| 45 | + response.headers(), |
| 46 | + allOf(HttpHeaderMatcher.hasHeader(HeaderNames.CACHE_CONTROL, |
| 47 | + "no-cache", |
| 48 | + "no-store", |
| 49 | + "must-revalidate", |
| 50 | + "no-transform"))); |
| 51 | + } |
| 52 | + } |
| 53 | +} |
0 commit comments