|
1 | 1 | package datadog.communication.http |
2 | 2 |
|
3 | | -import com.google.common.truth.Truth |
4 | 3 | import okhttp3.Request |
5 | | -import org.junit.jupiter.api.Assertions |
6 | 4 | import org.junit.jupiter.api.Test |
7 | 5 |
|
| 6 | +import static org.junit.jupiter.api.Assertions.assertFalse |
| 7 | +import static org.junit.jupiter.api.Assertions.assertThrows |
| 8 | +import static org.junit.jupiter.api.Assertions.assertTrue |
| 9 | + |
8 | 10 | class SafeRequestBuilderTest { |
9 | 11 | Request.Builder testBuilder = new Request.Builder() |
10 | 12 |
|
11 | 13 | @Test |
12 | 14 | void "test adding bad header"() { |
13 | 15 | def name = 'bad' |
14 | 16 | def password = 'very-secret-password' |
15 | | - IllegalArgumentException ex = Assertions.assertThrows(IllegalArgumentException, { |
| 17 | + IllegalArgumentException ex = assertThrows(IllegalArgumentException, { |
16 | 18 | testBuilder.url("http:localhost").addHeader(name, "$password\n") |
17 | 19 | }) |
18 | | - Truth.assertThat(ex).hasMessageThat().contains(name) |
19 | | - Truth.assertThat(ex).hasMessageThat().doesNotContain(password) |
| 20 | + assertTrue(ex.getMessage().contains(name)) |
| 21 | + assertFalse(ex.getMessage().contains(password)) |
20 | 22 | } |
| 23 | + |
21 | 24 | @Test |
22 | 25 | void "test adding bad header2"(){ |
23 | 26 | def name = '\u0019' |
24 | 27 | def password = 'very-secret-password' |
25 | | - IllegalArgumentException ex = Assertions.assertThrows(IllegalArgumentException, { |
| 28 | + IllegalArgumentException ex = assertThrows(IllegalArgumentException, { |
26 | 29 | testBuilder.url("http:localhost").addHeader(name, "\u0080$password") |
27 | 30 | }) |
28 | | - Truth.assertThat(ex).hasMessageThat().contains(name) |
29 | | - Truth.assertThat(ex).hasMessageThat().doesNotContain(password) |
| 31 | + assertTrue(ex.getMessage().contains(name)) |
| 32 | + assertFalse(ex.getMessage().contains(password)) |
30 | 33 | } |
31 | 34 | } |
0 commit comments