diff --git a/closed/test/jdk/TEST.ROOT b/closed/test/jdk/TEST.ROOT index dbac953bb69..5d509fe4c50 100644 --- a/closed/test/jdk/TEST.ROOT +++ b/closed/test/jdk/TEST.ROOT @@ -1,3 +1,23 @@ +# =========================================================================== +# (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 . +# =========================================================================== + # Path to libraries in the topmost test directory. This is needed so @library -# does not need ../../../ notation to reach them +# does not need ../../../ notation to reach them. external.lib.roots = ../../../ diff --git a/closed/test/jdk/openj9/internal/security/TestProperties.java b/closed/test/jdk/openj9/internal/security/TestProperties.java index a83d34fdbb1..c3bfc89e88b 100644 --- a/closed/test/jdk/openj9/internal/security/TestProperties.java +++ b/closed/test/jdk/openj9/internal/security/TestProperties.java @@ -22,7 +22,7 @@ * =========================================================================== */ - /* +/* * @test * @summary Test Restricted Security Mode Properties * @library /test/lib @@ -32,123 +32,123 @@ 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 TestProperties { - + private static Stream patternMatches_expectedExitValue1() { return Stream.of( - // 1 - Test profile - base profile misspell properties + // 1 - Test profile - base profile misspell properties. Arguments.of("Test-Profile.Base", System.getProperty("test.src") + "/property-java.security", - "The property names: RestrictedSecurity.Test-Profile.Base.tls.disabledAlgorithmsWrongTypo " + - "in profile RestrictedSecurity.Test-Profile.Base \\(or a base profile\\) are not recognized"), - // 2 - Test profile - extenstion profile misspell properties + "The property names: RestrictedSecurity.Test-Profile.Base.tls.disabledAlgorithmsWrongTypo " + + "in profile RestrictedSecurity.Test-Profile.Base \\(or a base profile\\) are not recognized"), + // 2 - Test profile - extenstion profile misspell properties. Arguments.of("Test-Profile.Extended_1", System.getProperty("test.src") + "/property-java.security", - "The property names: RestrictedSecurity.Test-Profile.Extended_1.desc.nameWrongTypo, " + - "RestrictedSecurity.Test-Profile.Extended_1.jce.providerWrongTypo in profile " + - "RestrictedSecurity.Test-Profile.Extended_1 \\(or a base profile\\) are not recognized"), - // 3 - Test profile - extension profile from another extension profile misspell properties + "The property names: RestrictedSecurity.Test-Profile.Extended_1.desc.nameWrongTypo, " + + "RestrictedSecurity.Test-Profile.Extended_1.jce.providerWrongTypo in profile " + + "RestrictedSecurity.Test-Profile.Extended_1 \\(or a base profile\\) are not recognized"), + // 3 - Test profile - extension profile from another extension profile misspell properties. Arguments.of("Test-Profile.Extended_2", System.getProperty("test.src") + "/property-java.security", - "The property names: RestrictedSecurity.Test-Profile.Extended_2.jce.providerWrongTypo " + - "in profile RestrictedSecurity.Test-Profile.Extended_2 \\(or a base profile\\) are not recognized"), - // 4 - Test profile - profile not exist + "The property names: RestrictedSecurity.Test-Profile.Extended_2.jce.providerWrongTypo " + + "in profile RestrictedSecurity.Test-Profile.Extended_2 \\(or a base profile\\) are not recognized"), + // 4 - Test profile - profile not exist. Arguments.of("Test-Profile-NotExist.Base", System.getProperty("test.src") + "/property-java.security", - "Test-Profile.NotExist.Base is not present in the java.security file."), - // 5 - Test profile - Multi Default profile + "Test-Profile-NotExist.Base is not present in the java.security file."), + // 5 - Test profile - Multi Default profile. Arguments.of("Test-Profile-MultiDefault", System.getProperty("test.src") + "/property-java.security", "Multiple default RestrictedSecurity profiles for Test-Profile-MultiDefault"), - // 6 - Test profile - no default profile + // 6 - Test profile - no default profile. Arguments.of("Test-Profile-NoDefault", System.getProperty("test.src") + "/property-java.security", "No default RestrictedSecurity profile was found for Test-Profile-NoDefault"), - // 7 - Test profile - base profile not exist + // 7 - Test profile - base profile does not exist. Arguments.of("Test-Profile.Extended_3", System.getProperty("test.src") + "/property-java.security", - "RestrictedSecurity.Test-Profile.BaseNotExist that is supposed to extend \\'RestrictedSecurity.Test-Profile.Extended_3\\' " + - "is not present in the java.security file or any appended files"), - // 8 - Test profile - base profile not full profile name + "RestrictedSecurity.Test-Profile.BaseNotExist that is supposed to extend \\'RestrictedSecurity.Test-Profile.Extended_3\\' " + + "is not present in the java.security file or any appended files"), + // 8 - Test profile - base profile not full profile name. Arguments.of("Test-Profile.Extended_4", System.getProperty("test.src") + "/property-java.security", - "RestrictedSecurity.BaseNotFullProfileName that is supposed to extend \\'RestrictedSecurity.Test-Profile.Extended_4\\' " + - "is not a full profile name"), - // 9 - Test profile - base profile without hash value + "RestrictedSecurity.BaseNotFullProfileName that is supposed to extend \\'RestrictedSecurity.Test-Profile.Extended_4\\' " + + "is not a full profile name"), + // 9 - Test profile - base profile without hash value. Arguments.of("Test-Profile-BaseWithoutHash", System.getProperty("test.src") + "/property-java.security", "Test-Profile-BaseWithoutHash is a base profile, so a hash value is mandatory"), - // 10 - Test profile - incorrect definition of hash value + // 10 - Test profile - incorrect definition of hash value. Arguments.of("Test-Profile-Hash_1", System.getProperty("test.src") + "/property-java.security", "Incorrect definition of hash value for RestrictedSecurity.Test-Profile-Hash_1"), - // 11 - Test profile - incorrect hash value + // 11 - Test profile - incorrect hash value. Arguments.of("Test-Profile-Hash_2", System.getProperty("test.src") + "/property-java.security", "Hex produced from profile is not the same is a base profile, so a hash value is mandatory"), - // 12 - Test property - property not appendable + // 12 - Test property - property not appendable. Arguments.of("Test-Profile-SetProperty.Extension_1", System.getProperty("test.src") + "/property-java.security", "Property \\'jdkSecureRandomProvider\\' is not appendable"), - // 13 - Test property - property does not exist in parent profile, cannot append + // 13 - Test property - property does not exist in parent profile, cannot append. Arguments.of("Test-Profile-SetProperty.Extension_2", System.getProperty("test.src") + "/property-java.security", "Property \\'jdkTlsDisabledNamedCurves\\' does not exist in parent profile or java.security file. Cannot append"), - // 14 - Test property - property value is not in existing values + // 14 - Test property - property value is not in existing values. Arguments.of("Test-Profile-SetProperty.Extension_3", System.getProperty("test.src") + "/property-java.security", "Value \\'TestDisabledlgorithms\\' is not in existing values"), - // 15 - Test property - policy sunset + // 15 - Test property - policy sunset. Arguments.of("Test-Profile-PolicySunset.Base", System.getProperty("test.src") + "/property-java.security", "Restricted security policy expired"), - // 16 - Test property - policy sunset format + // 16 - Test property - policy sunset format. Arguments.of("Test-Profile-PolicySunsetFormat.Base", System.getProperty("test.src") + "/property-java.security", "Restricted security policy sunset date is incorrect, the correct format is yyyy-MM-dd"), - // 17 - Test property - secure random check 1 + // 17 - Test property - secure random check 1. Arguments.of("Test-Profile-SecureRandomCheck_1", System.getProperty("test.src") + "/property-java.security", "Restricted security mode secure random is missing"), - // 18 - Test property - secure random check 2 + // 18 - Test property - secure random check 2. Arguments.of("Test-Profile-SecureRandomCheck_2", System.getProperty("test.src") + "/property-java.security", "Restricted security mode secure random is missing"), - // 19 - Test constraint - constraint check 1 + // 19 - Test constraint - constraint check 1. Arguments.of("Test-Profile-Constraint_1", System.getProperty("test.src") + "/property-java.security", "Provider format is incorrect"), - // 20 - Test constraint - constraint check 2 + // 20 - Test constraint - constraint check 2. Arguments.of("Test-Profile-Constraint_2", System.getProperty("test.src") + "/property-java.security", "Incorrect constraint definition for provider"), - // 21 - Test constraint - constraint check 3 + // 21 - Test constraint - constraint check 3. Arguments.of("Test-Profile-Constraint_3", System.getProperty("test.src") + "/property-java.security", "Incorrect constraint definition for provider"), - // 22 - Test constraint - constraint attributes check + // 22 - Test constraint - constraint attributes check. Arguments.of("Test-Profile-Constraint_Attributes", System.getProperty("test.src") + "/property-java.security", "Constraint attributes format is incorrect"), - // 23 - Test constraint - constraint changed 1 + // 23 - Test constraint - constraint changed 1. Arguments.of("Test-Profile-ConstraintChanged_1.Extension", System.getProperty("test.src") + "/property-java.security", - "Cannot append or remove constraints since the provider (.*?) " + - "wasn't in this position in the profile extended"), - // 24 - Test constraint - constraint changed 2 + "Cannot append or remove constraints since the provider (.*?) " + + "wasn't in this position in the profile extended"), + // 24 - Test constraint - constraint changed 2. Arguments.of("Test-Profile-ConstraintChanged_2.Extension", System.getProperty("test.src") + "/property-java.security", "Constraint (.*?)is not part of existing constraints"), - // 25 - Test constraint - constraint changed 3 + // 25 - Test constraint - constraint changed 3. Arguments.of("Test-Profile-ConstraintChanged_3.Base", System.getProperty("test.src") + "/property-java.security", "You cannot add or remove to provider (.*?). This is the base profile.") @@ -159,23 +159,21 @@ private static Stream patternMatches_expectedExitValue1() { @MethodSource("patternMatches_expectedExitValue1") public void shouldContain_expectedExitValue1(String customprofile, String securityPropertyFile, String expected) throws Exception { OutputAnalyzer outputAnalyzer = ProcessTools.executeTestJava( - "-Dsemeru.fips=true", + "-Dsemeru.fips=true", "-Dsemeru.customprofile=" + customprofile, "-Djava.security.properties=" + securityPropertyFile, - //"-Djava.security.debug=semerufips", "TestProperties" ); outputAnalyzer.reportDiagnosticSummary(); outputAnalyzer.shouldHaveExitValue(1).shouldMatch(expected); } - - public static void main(String[] args) throws Exception { - // Something to trigger "properties" debug output + + public static void main(String[] args) { + // Something to trigger "properties" debug output. 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()); + for (Provider provider : Security.getProviders()) { + System.out.println("Provider Name: " + provider.getName()); + System.out.println("Provider Version: " + provider.getVersionStr()); } } catch (Exception e) { System.out.println(e); diff --git a/closed/test/jdk/openj9/internal/security/TestProviders.java b/closed/test/jdk/openj9/internal/security/TestProviders.java index 25639c9a660..b513e90cd7c 100644 --- a/closed/test/jdk/openj9/internal/security/TestProviders.java +++ b/closed/test/jdk/openj9/internal/security/TestProviders.java @@ -22,7 +22,7 @@ * =========================================================================== */ - /* +/* * @test * @summary Test Restricted Security Mode Provider List * @library /test/lib @@ -32,40 +32,40 @@ 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 TestProviders { - + private static Stream patternMatches_expectedExitValue0() { return Stream.of( - // Test strict profile provider list + // Test strict profile provider list. Arguments.of("TestBase.Version", System.getProperty("test.src") + "/provider-java.security", "(?s)(?=.*Sun)(?=.*\\bSunJCE\\b)(?=.*SunJSSE)"), - // Test default profile provider list + // Test default profile provider list. Arguments.of("TestBase", System.getProperty("test.src") + "/provider-java.security", - "(?s)(?=.*Sun)(?=.*SunRsaSign)(?=.*SunEC)(?=.*SunJSSE)" + - "(?=.*SunJCE)(?=.*SunJGSS)(?=.*SunSASL)" + - "(?=.*XMLDSig)(?=.*SunPCSC)(?=.*JdkLDAP)(?=.*JdkSASL)"), - // Test extended profile provider list + "(?s)(?=.*Sun)(?=.*SunRsaSign)(?=.*SunEC)(?=.*SunJSSE)" + + "(?=.*SunJCE)(?=.*SunJGSS)(?=.*SunSASL)" + + "(?=.*XMLDSig)(?=.*SunPCSC)(?=.*JdkLDAP)(?=.*JdkSASL)"), + // Test extended profile provider list. Arguments.of("TestBase.Version-Extended", System.getProperty("test.src") + "/provider-java.security", - "(?s)(?=.*Sun)(?=.*SunRsaSign)(?=.*SunEC)(?=.*SunJSSE)" + - "(?=.*SunJCE)(?=.*SunJGSS)(?=.*SunSASL)" + - "(?=.*XMLDSig)(?=.*SunPCSC)(?=.*JdkLDAP)(?=.*JdkSASL)"), - // Test update provider list with value + "(?s)(?=.*Sun)(?=.*SunRsaSign)(?=.*SunEC)(?=.*SunJSSE)" + + "(?=.*SunJCE)(?=.*SunJGSS)(?=.*SunSASL)" + + "(?=.*XMLDSig)(?=.*SunPCSC)(?=.*JdkLDAP)(?=.*JdkSASL)"), + // Test update provider list with value. Arguments.of("Test-Profile.Updated_1", System.getProperty("test.src") + "/provider-java.security", "(?s)(?=.*Sun)(?=.*\\bSunJCE\\b)(?=.*SunSASL)"), - // Test update provider list with null + // Test update provider list with null. Arguments.of("Test-Profile.Updated_2", System.getProperty("test.src") + "/provider-java.security", "(?s)(?=.*Sun)(?=.*\\bSunJCE\\b)(?=.*SunJSSE)") @@ -74,60 +74,59 @@ private static Stream patternMatches_expectedExitValue0() { private static Stream patternMatches_expectedExitValue1() { return Stream.of( - // Test base profile - provider order numbers are not consecutive + // Test base profile - provider order numbers are not consecutive. Arguments.of("Test-Profile.Base", System.getProperty("test.src") + "/provider-java.security", - "The order numbers of providers in profile RestrictedSecurity.Test-Profile.Base " + - "\\(or a base profile\\) are not consecutive"), - // Test extended profile, provider order numbers are not consecutive + "The order numbers of providers in profile RestrictedSecurity.Test-Profile.Base " + + "\\(or a base profile\\) are not consecutive"), + // Test extended profile, provider order numbers are not consecutive. Arguments.of("Test-Profile.Extended_1", System.getProperty("test.src") + "/provider-java.security", - "The order numbers of providers in profile RestrictedSecurity.Test-Profile.Extended_1 " + - "\\(or a base profile\\) are not consecutive."), - // Test extended profile from another extended profile, provider order numbers are not consecutive + "The order numbers of providers in profile RestrictedSecurity.Test-Profile.Extended_1 " + + "\\(or a base profile\\) are not consecutive."), + // Test extended profile from another extended profile, provider order numbers are not consecutive. Arguments.of("Test-Profile.Extended_2", System.getProperty("test.src") + "/provider-java.security", - "The order numbers of providers in profile RestrictedSecurity.Test-Profile.Extended_2 " + - "\\(or a base profile\\) are not consecutive."), - // Test update provider list with empty, the empty is the last one in base profile + "The order numbers of providers in profile RestrictedSecurity.Test-Profile.Extended_2 " + + "\\(or a base profile\\) are not consecutive."), + // Test update provider list with empty, the empty is the last one in base profile. Arguments.of("Test-Profile.Updated_3", System.getProperty("test.src") + "/provider-java.security", "Cannot add a provider in position \\d+ after removing the ones in previous positions"), - // Test update provider list with empty, the empty is NOT the last one in base profile + // Test update provider list with empty, the empty is NOT the last one in base profile. Arguments.of("Test-Profile.Updated_4", System.getProperty("test.src") + "/provider-java.security", "Cannot specify an empty provider in position \\d+ when non-empty ones are specified after it"), - // Test base profile - one of the provider in list empty + // Test base profile - one of the provider in list empty. Arguments.of("Test-Profile.BaseOneProviderEmpty", System.getProperty("test.src") + "/provider-java.security", "Cannot specify an empty provider in position \\d+. Nothing specified before"), - // Test extended profile - one of the provider in list empty + // Test extended profile - one of the provider in list empty. Arguments.of("Test-Profile.ExtendedOneProviderEmpty", System.getProperty("test.src") + "/provider-java.security", "Cannot specify an empty provider in position \\d+. Nothing specified before"), - // Test base profile - no provider list + // Test base profile - no provider list. Arguments.of("Test-Profile.BaseNoProviderList", System.getProperty("test.src") + "/provider-java.security", "No providers are specified as part of the Restricted Security profile"), - // Test profile - provider must be specified using the fully-qualified class name + // Test profile - provider must be specified using the fully-qualified class name. Arguments.of("Test-Profile.ProviderClassName", System.getProperty("test.src") + "/provider-java.security", "Provider must be specified using the fully-qualified class name"), - // Test profile - provider format is incorrect + // Test profile - provider format is incorrect. Arguments.of("Test-Profile.ProviderFormat", System.getProperty("test.src") + "/provider-java.security", "Provider format is incorrect") ); } - + @ParameterizedTest @MethodSource("patternMatches_expectedExitValue0") public void shouldContain_expectedExitValue0(String customprofile, String securityPropertyFile, String expected) throws Exception { OutputAnalyzer outputAnalyzer = ProcessTools.executeTestJava( - "-Dsemeru.fips=true", + "-Dsemeru.fips=true", "-Dsemeru.customprofile=" + customprofile, "-Djava.security.properties=" + securityPropertyFile, - //"-Djava.security.debug=semerufips", "TestProviders" ); outputAnalyzer.reportDiagnosticSummary(); @@ -138,22 +137,20 @@ public void shouldContain_expectedExitValue0(String customprofile, String securi @MethodSource("patternMatches_expectedExitValue1") public void shouldContain_expectedExitValue1(String customprofile, String securityPropertyFile, String expected) throws Exception { OutputAnalyzer outputAnalyzer = ProcessTools.executeTestJava( - "-Dsemeru.fips=true", + "-Dsemeru.fips=true", "-Dsemeru.customprofile=" + customprofile, "-Djava.security.properties=" + securityPropertyFile, - //"-Djava.security.debug=semerufips", "TestProviders" ); outputAnalyzer.reportDiagnosticSummary(); outputAnalyzer.shouldHaveExitValue(1).shouldMatch(expected); } - - public static void main(String[] args) throws Exception { + + public static void main(String[] args) { 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()); + for (Provider provider : Security.getProviders()) { + System.out.println("Provider Name: " + provider.getName()); + System.out.println("Provider Version: " + provider.getVersionStr()); } } catch (Exception e) { System.out.println(e); diff --git a/closed/test/jdk/openj9/internal/security/property-java.security b/closed/test/jdk/openj9/internal/security/property-java.security index 70915490f0a..490d33e1594 100644 --- a/closed/test/jdk/openj9/internal/security/property-java.security +++ b/closed/test/jdk/openj9/internal/security/property-java.security @@ -1,3 +1,23 @@ +# =========================================================================== +# (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 . +# =========================================================================== + RestrictedSecurity.TestBase.Version.desc.name = Test Base Profile RestrictedSecurity.TestBase.Version.desc.default = false RestrictedSecurity.TestBase.Version.desc.fips = true @@ -402,7 +422,7 @@ RestrictedSecurity.Test-Profile-Constraint_3.securerandom.algorithm = SHA512DRBG # # Test-Profile-Constraint_Attributes -# Test constraint - constraint attributes check +# Test constraint - constraint attributes check # RestrictedSecurity.Test-Profile-Constraint_Attributes.desc.name = Test-Profile-Constraint_Attributes RestrictedSecurity.Test-Profile-Constraint_Attributes.desc.default = true diff --git a/closed/test/jdk/openj9/internal/security/provider-java.security b/closed/test/jdk/openj9/internal/security/provider-java.security index b6a50256057..3f09f0954fd 100644 --- a/closed/test/jdk/openj9/internal/security/provider-java.security +++ b/closed/test/jdk/openj9/internal/security/provider-java.security @@ -1,3 +1,23 @@ +# =========================================================================== +# (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 . +# =========================================================================== + RestrictedSecurity.TestBase.Version.desc.name = Test Base Profile RestrictedSecurity.TestBase.Version.desc.default = false RestrictedSecurity.TestBase.Version.desc.fips = true