Skip to content

Commit

Permalink
Update the cloded test case for Restricted Security Mode
Browse files Browse the repository at this point in the history
  • Loading branch information
taoliult committed Sep 26, 2024
1 parent 218d284 commit fafc2c7
Show file tree
Hide file tree
Showing 3 changed files with 1,735 additions and 0 deletions.
3 changes: 3 additions & 0 deletions closed/test/jdk/TEST.ROOT
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 closed/test/jdk/openj9/internal/security/TestProviderOrder.java
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);
}
}
}
Loading

0 comments on commit fafc2c7

Please sign in to comment.