Skip to content

Commit 95fc0f7

Browse files
authored
Tests that confidential options are not printed in toString() (#9154)
Signed-off-by: Tomas Langer <[email protected]>
1 parent 578f234 commit 95fc0f7

File tree

2 files changed

+68
-0
lines changed

2 files changed

+68
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
/*
2+
* Copyright (c) 2024 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+
17+
package io.helidon.builder.test.testsubjects.tostring;
18+
19+
import io.helidon.builder.api.Option;
20+
import io.helidon.builder.api.Prototype;
21+
22+
@Prototype.Blueprint
23+
interface SecretBlueprint {
24+
String name();
25+
@Option.Confidential
26+
String secret();
27+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
/*
2+
* Copyright (c) 2024 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+
17+
package io.helidon.builder.test;
18+
19+
import io.helidon.builder.test.testsubjects.tostring.Secret;
20+
21+
import org.junit.jupiter.api.Test;
22+
23+
import static org.hamcrest.CoreMatchers.containsString;
24+
import static org.hamcrest.CoreMatchers.not;
25+
import static org.hamcrest.MatcherAssert.assertThat;
26+
27+
class ToStringTest {
28+
@Test
29+
void testToStringWithConfidential() {
30+
var builder = Secret.builder()
31+
.name("public-name")
32+
.secret("secret-value");
33+
var secret = builder.build();
34+
35+
assertThat(builder.toString(), containsString("public-name"));
36+
assertThat(builder.toString(), not(containsString("secret-value")));
37+
38+
assertThat(secret.toString(), containsString("public-name"));
39+
assertThat(secret.toString(), not(containsString("secret-value")));
40+
}
41+
}

0 commit comments

Comments
 (0)