forked from ibmruntimes/openj9-openjdk-jdk17
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update the cloded test case for Restricted Security Mode
- Loading branch information
Showing
3 changed files
with
1,735 additions
and
0 deletions.
There are no files selected for viewing
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,3 @@ | ||
# Path to libraries in the topmost test directory. This is needed so @library | ||
# does not need ../../../ notation to reach them | ||
external.lib.roots = ../../../ |
86 changes: 86 additions & 0 deletions
86
closed/test/jdk/openj9/internal/security/TestProviderOrder.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,86 @@ | ||
/* | ||
* =========================================================================== | ||
* (c) Copyright IBM Corp. 2024, 2024 All Rights Reserved | ||
* =========================================================================== | ||
* | ||
* This code is free software; you can redistribute it and/or modify it | ||
* under the terms of the GNU General Public License version 2 only, as | ||
* published by the Free Software Foundation. | ||
* | ||
* IBM designates this particular file as subject to the "Classpath" exception | ||
* as provided by IBM in the LICENSE file that accompanied this code. | ||
* | ||
* This code is distributed in the hope that it will be useful, but WITHOUT | ||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | ||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | ||
* version 2 for more details (a copy is included in the LICENSE file that | ||
* accompanied this code). | ||
* | ||
* You should have received a copy of the GNU General Public License version | ||
* 2 along with this work; if not, see <http://www.gnu.org/licenses/>. | ||
* | ||
* =========================================================================== | ||
*/ | ||
|
||
/* | ||
* @test | ||
* @summary Test Provider Order | ||
* @library /test/lib | ||
* @run junit TestProviderOrder | ||
*/ | ||
|
||
import org.junit.jupiter.params.ParameterizedTest; | ||
import org.junit.jupiter.params.provider.Arguments; | ||
import org.junit.jupiter.params.provider.MethodSource; | ||
|
||
import java.security.Provider; | ||
import java.security.Security; | ||
|
||
import java.util.stream.Stream; | ||
|
||
import jdk.test.lib.process.OutputAnalyzer; | ||
import jdk.test.lib.process.ProcessTools; | ||
|
||
public class TestProviderOrder { | ||
|
||
private static Stream<Arguments> patternMatches() { | ||
return Stream.of( | ||
// Test case 1 | ||
Arguments.of("Test-Profile.Version-1", | ||
System.getProperty("test.src") + "/java.security", | ||
"Provider"), | ||
// Test case 2 | ||
Arguments.of("OpenJCEPlusFIPS.FIPS140-3-Weakly-Enforced", | ||
System.getProperty("test.src") + "/java.security", | ||
"Provider") | ||
// Test case 3 ... | ||
); | ||
} | ||
|
||
@ParameterizedTest | ||
@MethodSource("patternMatches") | ||
public void shouldContain(String customprofile, String securityPropertyFile, String expected) throws Exception { | ||
OutputAnalyzer outputAnalyzer = ProcessTools.executeTestJava( | ||
"-Dsemeru.fips=true", | ||
"-Dsemeru.customprofile=" + customprofile, | ||
"-Djava.security.properties=" + securityPropertyFile, | ||
"-Djava.security.debug=semerufips", | ||
"TestProviderOrder" | ||
); | ||
outputAnalyzer.reportDiagnosticSummary(); | ||
//outputAnalyzer.shouldHaveExitValue(0).shouldContain(expected); | ||
} | ||
|
||
public static void main(String[] args) throws Exception { | ||
// Something to trigger restrictedSecurity mode initialization | ||
try { | ||
Provider p[] = Security.getProviders(); | ||
for (int i = 0; i < p.length; i++) { | ||
System.out.println("Provider Name: " + p[i].getName()); | ||
System.out.println("Provider Version: " + p[i].getVersion()); | ||
} | ||
} catch (Exception e) { | ||
System.out.println(e); | ||
} | ||
} | ||
} |
Oops, something went wrong.