[java-idp-integration-tests] 09/10: Formatting and Javadoc

Tom Zeller tzeller at dragonacea.biz
Wed Aug 28 22:38:37 UTC 2024


This is an automated email from the git hooks/post-receive script.

tzeller pushed a commit to branch main
in repository java-idp-integration-tests.

View the commit online:
http://git.shibboleth.net/view/?p=java-idp-integration-tests.git;a=commit;h=2ecb36256e8d67d4a45b30efb2e9b0e5e1ab9815

commit 2ecb36256e8d67d4a45b30efb2e9b0e5e1ab9815
Author: Tom Zeller <tzeller at dragonacea.biz>
AuthorDate: Wed Aug 28 00:50:00 2024 -0500

    Formatting and Javadoc
---
 .../tests/oidc/ConformanceSuiteContainer.java      | 84 +++++++++++++++-------
 .../integration/tests/oidc/OPConformanceTest.java  | 13 ++--
 2 files changed, 66 insertions(+), 31 deletions(-)

diff --git a/src/test/java/net/shibboleth/idp/integration/tests/oidc/ConformanceSuiteContainer.java b/src/test/java/net/shibboleth/idp/integration/tests/oidc/ConformanceSuiteContainer.java
index 0519339..fdf4fb4 100644
--- a/src/test/java/net/shibboleth/idp/integration/tests/oidc/ConformanceSuiteContainer.java
+++ b/src/test/java/net/shibboleth/idp/integration/tests/oidc/ConformanceSuiteContainer.java
@@ -52,20 +52,19 @@ public class ConformanceSuiteContainer extends AbstractIdentifiableInitializable
     public DockerComposeContainer<?> container;
 
     /** Path to 'conformance-suite' directory */
-    
     protected Path pathToConformanceSuite;
-    
+
     protected Path pathToDockerComposeYML;
-    
+
     protected Path pathToPerTestDirectory;
-    
+
     protected Path pathToPythonVenv;
-    
+
     protected Path pathToPythonBinActivate;
 
-    /** Path to 'test-distributions' directory */    
+    /** Path to 'test-distributions' directory */
     protected Path pathToTestDistributions;
-    
+
     /** OP hostname or FQDN, defaults to "idp.tests.shibboleth.net" */
     @Nonnull
     protected String opHost = "idp.tests.shibboleth.net";
@@ -119,9 +118,7 @@ public class ConformanceSuiteContainer extends AbstractIdentifiableInitializable
             throw new ComponentInitializationException(e);
         }
 
-        // id = "shib-test-conformance-suite"
-
-        // TODO does wait here work propertly ?
+        // TODO does wait here work properly ?
         // TODO closeable
         container = new DockerComposeContainer(getId(), pathToDockerComposeYML.toFile()) //
                 .withExposedService( //
@@ -129,7 +126,7 @@ public class ConformanceSuiteContainer extends AbstractIdentifiableInitializable
                         8443, //
                         Wait.forHttps("/") //
                                 .allowInsecure());
-        
+
         log.debug("{} Initialized", getLogPrefix());
     }
 
@@ -314,6 +311,17 @@ public class ConformanceSuiteContainer extends AbstractIdentifiableInitializable
         logProcess(process, "Set up Python venv :");
     }
 
+    /**
+     * Log output of process and return the output.
+     * 
+     * @param process
+     *            the process to be logged
+     * @param prefix
+     *            the prefix of the message to be logged
+     * @return the process output
+     * @throws IOException
+     *             if an error occurs
+     */
     public String getProcessOutput(@Nonnull final Process process, @Nullable final String prefix) throws IOException {
         final StringBuffer output = new StringBuffer();
         final BufferedReader reader = new BufferedReader(new InputStreamReader(process.getInputStream()));
@@ -358,6 +366,8 @@ public class ConformanceSuiteContainer extends AbstractIdentifiableInitializable
     /**
      * Log output of process.
      * 
+     * Implemented here because {@link BaseIntegrationTest} is not the parent class.
+     * 
      * @param process the process to be logged
      * @param prefix the prefix of the message to be logged
      * @throws IOException
@@ -370,6 +380,21 @@ public class ConformanceSuiteContainer extends AbstractIdentifiableInitializable
         }
     }
 
+    /**
+     * See {@link BaseIntegrationTest#replaceFile(Path, String, String)}
+     * 
+     * Implemented here because {@link BaseIntegrationTest} is not the parent class.
+     * 
+     * @param pathToFile
+     *            path to the file
+     * @param regex
+     *            regular expression to be replaced
+     * @param replacement
+     *            string to be substituted for each match
+     * 
+     * @throws IOException
+     *             if the file cannot be overwritten
+     */
     public static void replaceFile(@Nonnull final Path pathToFile, @Nonnull @NotEmpty final String regex,
             @Nonnull @NotEmpty final String replacement) throws IOException {
         BaseIntegrationTest.replaceFile(pathToFile, regex, replacement);
@@ -390,6 +415,16 @@ public class ConformanceSuiteContainer extends AbstractIdentifiableInitializable
         return logPrefix;
     }
 
+    /**
+     * Run conformance test.
+     * 
+     * @param description
+     *            description of test for logging
+     * @param testPlan
+     *            conformance test plan
+     * @throws IOException
+     *             if an error occurs
+     */
     protected void runTest(final String description, final String testPlan) throws IOException {
 
         final String binActivate = pathToPythonBinActivate.toAbsolutePath().toString();
@@ -413,8 +448,6 @@ public class ConformanceSuiteContainer extends AbstractIdentifiableInitializable
 
         log.debug("Ran {} test using command : '{}'", description, command);
 
-        // final Path pathToSavedOutput =
-        // pathToConformanceSuite.resolve("basicCertificationProfileAuthorizationTest.log");
         final String outputFileName = description.replaceAll(" ", "-") + ".log";
 
         final Path pathToSavedOutput = pathToConformanceSuite.resolve(outputFileName);
@@ -424,12 +457,21 @@ public class ConformanceSuiteContainer extends AbstractIdentifiableInitializable
         Files.write(pathToSavedOutput, output.getBytes());
 
         final boolean success = isSuccess(output);
-        
+
         if (!success) {
             Assert.fail("Test failure : " + description + " see " + pathToSavedOutput);
         }
     }
-    
+
+    /**
+     * Whether test was successful or not.
+     * 
+     * Tests need to run to completion with no failures or warnings.
+     * 
+     * @param output
+     *            test plan output
+     * @return whether test was successful or not.
+     */
     protected boolean isSuccess(final String output) {
 
         boolean success = true;
@@ -438,11 +480,6 @@ public class ConformanceSuiteContainer extends AbstractIdentifiableInitializable
             success = false;
         }
 
-        log.debug("test success = '{}'", success);
-
-        // Overall totals: ran 38 test modules. Conditions: 2065 successes, 0 failures,
-        // 0 warnings.
-        // Pattern pattern = Pattern.compile("\\d{2}-\\d{2}-\\d{4}");
         final Pattern pattern = Pattern.compile(
                 "Overall totals: ran (\\d+) test modules. Conditions: (\\d+) successes, (\\d+) failures, (\\d+) warnings\\.");
 
@@ -455,10 +492,7 @@ public class ConformanceSuiteContainer extends AbstractIdentifiableInitializable
         final String failures = matcher.group(3);
         final String warnings = matcher.group(4);
 
-        log.debug("matcher 1 modules   = '{}'", modules);
-        log.debug("matcher 2 successes = '{}'", successes);
-        log.debug("matcher 4 failures  = '{}'", failures);
-        log.debug("matcher 3 warnings  = '{}'", warnings);
+        log.debug("Ran {} modules with {} successes, {} failures, and {} warnings", modules, successes, failures, warnings);
 
         if (successes.equals("0")) {
             success = false;
@@ -472,7 +506,7 @@ public class ConformanceSuiteContainer extends AbstractIdentifiableInitializable
             success = false;
         }
 
-        log.debug("test success = '{}'", success);
+        log.debug("Test success = '{}'", success);
 
         return success;
     }
diff --git a/src/test/java/net/shibboleth/idp/integration/tests/oidc/OPConformanceTest.java b/src/test/java/net/shibboleth/idp/integration/tests/oidc/OPConformanceTest.java
index 24dba59..4e050a3 100644
--- a/src/test/java/net/shibboleth/idp/integration/tests/oidc/OPConformanceTest.java
+++ b/src/test/java/net/shibboleth/idp/integration/tests/oidc/OPConformanceTest.java
@@ -101,7 +101,7 @@ public class OPConformanceTest extends AbstractOPTest {
         "#    saml2/urn:oasis:names:tc:SAML:2.0:ac:classes:PasswordProtectedTransport, \\\\\n" + //
         "#    saml2/urn:oasis:names:tc:SAML:2.0:ac:classes:Password, \\\\\n" +
         "#    saml1/urn:oasis:names:tc:SAML:1.0:am:password";
-        
+
         final String newText = //
         "idp.authn.Password.supportedPrincipals = \\\\\n" + //
         "    saml2/urn:oasis:names:tc:SAML:2.0:ac:classes:PasswordProtectedTransport, \\\\\n" + //
@@ -237,25 +237,26 @@ public class OPConformanceTest extends AbstractOPTest {
 
     @Test
     public void testBasicCertificationProfileAuthorization() throws Exception {
-    
+
         if (isWindows() || idpVersion.startsWith("4")) {
             log.debug("Skipping OP conformance suite test, only runs IdP V5 on Linux with Jetty");
             return;
         }
+
         final String description = "basic certification profile authorization test";
-        
+
         final String testPlan = //
                 "scripts/run-test-plan.py " + //
                 "--expected-skips-file skip-oidcc-idtoken-unsigned.json " + //
                 "'oidcc-basic-certification-test-plan[server_metadata=discovery][client_registration=dynamic_client]' " + //
                 "testop-config.json";
-        
+
         conformanceSuite.runTest(description, testPlan);
     }
 
     @Test
     public void testConfigCertificationProfileAuthorization() throws Exception {
-    
+
         if (isWindows() || idpVersion.startsWith("4")) {
             log.debug("Skipping OP conformance suite test, only runs IdP V5 on Linux with Jetty");
             return;
@@ -266,7 +267,7 @@ public class OPConformanceTest extends AbstractOPTest {
         final String testPlan = //
                 "scripts/run-test-plan.py --verbose " + //
                 "'oidcc-config-certification-test-plan' testop-config.json";
-        
+
         conformanceSuite.runTest(description, testPlan);
     }
 

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.


More information about the commits mailing list