-
Notifications
You must be signed in to change notification settings - Fork 566
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Tests that confidential options are not printed in toString() (#9154)
Signed-off-by: Tomas Langer <[email protected]>
- Loading branch information
1 parent
578f234
commit 95fc0f7
Showing
2 changed files
with
68 additions
and
0 deletions.
There are no files selected for viewing
27 changes: 27 additions & 0 deletions
27
.../builder/src/main/java/io/helidon/builder/test/testsubjects/tostring/SecretBlueprint.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
/* | ||
* Copyright (c) 2024 Oracle and/or its affiliates. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package io.helidon.builder.test.testsubjects.tostring; | ||
|
||
import io.helidon.builder.api.Option; | ||
import io.helidon.builder.api.Prototype; | ||
|
||
@Prototype.Blueprint | ||
interface SecretBlueprint { | ||
String name(); | ||
@Option.Confidential | ||
String secret(); | ||
} |
41 changes: 41 additions & 0 deletions
41
builder/tests/builder/src/test/java/io/helidon/builder/test/ToStringTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
/* | ||
* Copyright (c) 2024 Oracle and/or its affiliates. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package io.helidon.builder.test; | ||
|
||
import io.helidon.builder.test.testsubjects.tostring.Secret; | ||
|
||
import org.junit.jupiter.api.Test; | ||
|
||
import static org.hamcrest.CoreMatchers.containsString; | ||
import static org.hamcrest.CoreMatchers.not; | ||
import static org.hamcrest.MatcherAssert.assertThat; | ||
|
||
class ToStringTest { | ||
@Test | ||
void testToStringWithConfidential() { | ||
var builder = Secret.builder() | ||
.name("public-name") | ||
.secret("secret-value"); | ||
var secret = builder.build(); | ||
|
||
assertThat(builder.toString(), containsString("public-name")); | ||
assertThat(builder.toString(), not(containsString("secret-value"))); | ||
|
||
assertThat(secret.toString(), containsString("public-name")); | ||
assertThat(secret.toString(), not(containsString("secret-value"))); | ||
} | ||
} |