#9145 fix ee8 openid module

Signed-off-by: Ludovic Orban <lorban@bitronix.be>
This commit is contained in:
Ludovic Orban 2023-01-10 13:56:53 +01:00
parent ded18f523d
commit 08a829fdd2
2 changed files with 77 additions and 1 deletions

View File

@ -4,7 +4,7 @@
Adds OpenId Connect authentication to the server.
[depend]
security
ee8-security
client
[lib]

View File

@ -0,0 +1,76 @@
//
// ========================================================================
// Copyright (c) 1995-2022 Mort Bay Consulting Pty Ltd and others.
//
// This program and the accompanying materials are made available under the
// terms of the Eclipse Public License v. 2.0 which is available at
// https://www.eclipse.org/legal/epl-2.0, or the Apache License, Version 2.0
// which is available at https://www.apache.org/licenses/LICENSE-2.0.
//
// SPDX-License-Identifier: EPL-2.0 OR Apache-2.0
// ========================================================================
//
package org.eclipse.jetty.tests.distribution;
import java.io.Closeable;
import java.util.concurrent.TimeUnit;
import org.eclipse.jetty.logging.JettyLevel;
import org.eclipse.jetty.logging.JettyLogger;
import org.eclipse.jetty.tests.hometester.JettyHomeTester;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.ValueSource;
import org.slf4j.LoggerFactory;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.is;
public class ModulesTest
{
private static class LogDisabler implements Closeable
{
private final JettyLevel previousLevel;
private final JettyLogger logger;
public LogDisabler(Class<?> clazz)
{
this.logger = (JettyLogger)LoggerFactory.getLogger(clazz);
this.previousLevel = logger.getLevel();
this.logger.setLevel(JettyLevel.OFF);
}
@Override
public void close()
{
logger.setLevel(previousLevel);
}
}
@ParameterizedTest
@ValueSource(strings = {"ee8-openid", "ee9-openid", "ee10-openid"})
public void testOpenidModules(String module) throws Exception
{
String jettyVersion = System.getProperty("jettyVersion");
JettyHomeTester distribution = JettyHomeTester.Builder.newInstance()
.jettyVersion(jettyVersion)
.mavenLocalRepository(System.getProperty("mavenRepoPath"))
.build();
// Add module.
try (JettyHomeTester.Run run = distribution.start("--add-modules=" + module))
{
run.awaitFor(5, TimeUnit.SECONDS);
assertThat(run.getExitValue(), is(0));
}
// Verify that Jetty fails to start b/c the issue was not configured.
try (LogDisabler ignored = new LogDisabler(JettyHomeTester.class);
JettyHomeTester.Run run = distribution.start())
{
assertThat(run.awaitConsoleLogsFor("Issuer was not configured", 5, TimeUnit.SECONDS), is(true));
run.stop();
assertThat(run.awaitFor(5, TimeUnit.SECONDS), is(true));
}
}
}