Skip to content

Commit

Permalink
add test cases for oracle db
Browse files Browse the repository at this point in the history
  • Loading branch information
mmoayyed committed Sep 18, 2019
1 parent 1bce45f commit 99d27a4
Show file tree
Hide file tree
Showing 41 changed files with 296 additions and 85 deletions.
3 changes: 3 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,9 @@ jobs:
- stage: test
script: ./ci/tests/mariadb/run-tests-mariadb.sh
name: "MariaDb Tests"
- stage: test
script: ./ci/tests/oracle/run-tests-oracle.sh
name: "Oracle Tests"
- stage: test
script: ./ci/tests/mongodb/run-tests-mongodb.sh
name: "MongoDb Tests"
Expand Down
15 changes: 15 additions & 0 deletions ci/tests/oracle/run-oracle-server.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/bin/bash

# while sleep 9m; do echo -e '\n=====[ Gradle build is still running ]====='; done &

echo "Running Oracle docker image..."
docker run -d -p 1521:1521 --name oracle-db store/oracle/database-enterprise:12.2.0.1-slim
echo "Waiting for Oracle image to prepare..."
sleep 30
docker ps | grep "oracle-db"
echo "Waiting for Oracle server to come online..."
until curl --output /dev/null --silent --fail telnet://127.0.0.1:1521; do
printf '.'
sleep 2
done
echo "Oracle docker image is running."
77 changes: 77 additions & 0 deletions ci/tests/oracle/run-tests-oracle.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
#!/bin/bash
source ./ci/functions.sh

runBuild=false
echo "Reviewing changes that might affect the Gradle build..."
currentChangeSetAffectsTests
retval=$?
if [ "$retval" == 0 ]
then
echo "Found changes that require the build to run test cases."
runBuild=true
else
echo "Changes do NOT affect project test cases."
runBuild=false
fi

if [ "$runBuild" = false ]; then
exit 0
fi

prepCommand="echo 'Running command...'; "
gradle="./gradlew $@"
gradleBuild=""
gradleBuildOptions="--stacktrace --build-cache --configure-on-demand --no-daemon -DtestCategoryType=ORACLE "

echo -e "***********************************************"
echo -e "Gradle build started at `date`"
echo -e "***********************************************"

./ci/tests/oracle/run-oracle-server.sh

gradleBuild="$gradleBuild testOracle jacocoRootReport -x test -x javadoc -x check \
-DskipGradleLint=true--parallel \
-DskipNestedConfigMetadataGen=true "

if [[ "${TRAVIS_COMMIT_MESSAGE}" == *"[show streams]"* ]]; then
gradleBuild="$gradleBuild -DshowStandardStreams=true "
fi

if [[ "${TRAVIS_COMMIT_MESSAGE}" == *"[rerun tasks]"* ]]; then
gradleBuild="$gradleBuild --rerun-tasks "
fi

if [[ "${TRAVIS_COMMIT_MESSAGE}" == *"[refresh dependencies]"* ]]; then
gradleBuild="$gradleBuild --refresh-dependencies "
fi

if [ -z "$gradleBuild" ]; then
echo "Gradle build will be ignored since no commands are specified to run."
else
tasks="$gradle $gradleBuildOptions $gradleBuild"
echo -e "***************************************************************************************"
echo $prepCommand
echo $tasks
echo -e "***************************************************************************************"

waitloop="while sleep 9m; do echo -e '\n=====[ Gradle build is still running ]====='; done &"
eval $waitloop
waitRetVal=$?

eval $prepCommand
eval $tasks
retVal=$?

echo -e "***************************************************************************************"
echo -e "Gradle build finished at `date` with exit code $retVal"
echo -e "***************************************************************************************"

if [ $retVal == 0 ]; then
echo "Uploading test coverage results..."
bash <(curl -s https://codecov.io/bash)
echo "Gradle build finished successfully."
else
echo "Gradle build did NOT finish successfully."
exit $retVal
fi
fi
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package org.apereo.cas.authentication.principal.resolvers;

import org.apereo.cas.config.support.EnvironmentConversionServiceInitializer;
import org.apereo.cas.configuration.CasConfigurationProperties;

import lombok.val;
Expand All @@ -11,7 +10,6 @@
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.cloud.autoconfigure.RefreshAutoConfiguration;
import org.springframework.context.support.StaticApplicationContext;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.TestPropertySource;

import java.util.HashMap;
Expand All @@ -26,7 +24,6 @@
*/
@Tag("Groovy")
@SpringBootTest(classes = RefreshAutoConfiguration.class)
@ContextConfiguration(initializers = EnvironmentConversionServiceInitializer.class)
@EnableConfigurationProperties(CasConfigurationProperties.class)
@TestPropertySource(properties = "cas.authn.attributeRepository.groovy[0].location=classpath:GroovyAttributeDao.groovy")
public class InternalGroovyScriptDaoTests {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,16 +49,18 @@ public Pair<Boolean, Optional<MultifactorAuthenticationProvider>> validateAuthen
val provider = providerResult.get();
if (provider.isAvailable(registeredService)) {
val bypassEvaluator = provider.getBypassEvaluator();
if (!bypassEvaluator.shouldMultifactorAuthenticationProviderExecute(authentication, registeredService, provider, request)) {
LOGGER.debug("MFA provider [{}] has determined that it should be bypassed for this service request [{}]",
if (bypassEvaluator != null) {
if (!bypassEvaluator.shouldMultifactorAuthenticationProviderExecute(authentication, registeredService, provider, request)) {
LOGGER.debug("MFA provider [{}] has determined that it should be bypassed for this service request [{}]",
providerId, assertion.getService());
bypassEvaluator.rememberBypass(authentication, provider);
return Pair.of(Boolean.TRUE, Optional.empty());
}
if (bypassEvaluator.isMultifactorAuthenticationBypassed(authentication, providerId)) {
LOGGER.debug("Authentication attempt indicates that MFA is bypassed for this request for [{}]", requestedContext);
bypassEvaluator.rememberBypass(authentication, provider);
return Pair.of(Boolean.TRUE, Optional.empty());
bypassEvaluator.rememberBypass(authentication, provider);
return Pair.of(Boolean.TRUE, Optional.empty());
}
if (bypassEvaluator.isMultifactorAuthenticationBypassed(authentication, providerId)) {
LOGGER.debug("Authentication attempt indicates that MFA is bypassed for this request for [{}]", requestedContext);
bypassEvaluator.rememberBypass(authentication, provider);
return Pair.of(Boolean.TRUE, Optional.empty());
}
}
} else {
val failure = provider.getFailureModeEvaluator().evaluate(registeredService, provider);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
</Console>
</Appenders>
<Loggers>
<Logger name="org.apereo" level="debug" additivity="false">
<Logger name="org.apereo" level="error" additivity="false">
<AppenderRef ref="console"/>
</Logger>
<Root level="off">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

import lombok.extern.slf4j.Slf4j;
import lombok.val;
import org.springframework.beans.factory.ObjectProvider;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
Expand All @@ -33,7 +34,7 @@
* @author Dmitriy Kopylenko
* @since 5.0.0
*/
@Configuration(value = "casCoreAuthenticationConfiguration", proxyBeanMethods = false)
@Configuration(value = "casCoreAuthenticationConfiguration")
@EnableConfigurationProperties(CasConfigurationProperties.class)
@Slf4j
public class CasCoreAuthenticationConfiguration {
Expand All @@ -44,17 +45,20 @@ public class CasCoreAuthenticationConfiguration {
@Autowired
private CasConfigurationProperties casProperties;

@Autowired
@Qualifier("authenticationEventExecutionPlan")
private ObjectProvider<AuthenticationEventExecutionPlan> authenticationEventExecutionPlan;

@Bean
public AuthenticationTransactionManager authenticationTransactionManager(@Qualifier("casAuthenticationManager") final AuthenticationManager authenticationManager) {
return new DefaultAuthenticationTransactionManager(applicationEventPublisher, authenticationManager);
public AuthenticationTransactionManager authenticationTransactionManager() {
return new DefaultAuthenticationTransactionManager(applicationEventPublisher, casAuthenticationManager());
}

@ConditionalOnMissingBean(name = "casAuthenticationManager")
@Autowired
@Bean
public AuthenticationManager casAuthenticationManager(@Qualifier("authenticationEventExecutionPlan") final AuthenticationEventExecutionPlan authenticationEventExecutionPlan) {
public AuthenticationManager casAuthenticationManager() {
return new PolicyBasedAuthenticationManager(
authenticationEventExecutionPlan,
authenticationEventExecutionPlan.getIfAvailable(),
casProperties.getPersonDirectory().isPrincipalResolutionFailureFatal(),
applicationEventPublisher
);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package org.apereo.cas.monitor;

import org.apereo.cas.config.support.EnvironmentConversionServiceInitializer;
import org.apereo.cas.configuration.CasConfigurationProperties;

import lombok.val;
Expand All @@ -11,7 +10,6 @@
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.cloud.autoconfigure.RefreshAutoConfiguration;
import org.springframework.test.context.ContextConfiguration;

import static org.junit.jupiter.api.Assertions.*;

Expand All @@ -25,7 +23,6 @@
RefreshAutoConfiguration.class,
AopAutoConfiguration.class
})
@ContextConfiguration(initializers = EnvironmentConversionServiceInitializer.class)
@EnableConfigurationProperties(CasConfigurationProperties.class)
public class CacheHealthIndicatorTests {

Expand Down
5 changes: 4 additions & 1 deletion gradle/dependencies.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -498,7 +498,6 @@ ext.libraries = [
exclude(group: "com.google.guava", module: "guava")
exclude(group: "joda-time", module: "joda-time")
exclude(group: "org.slf4j", module: "slf4j-api")
exclude(group: "com.google.code.gson", module: "gson")
}
],
googlegeocoding : [
Expand All @@ -508,6 +507,10 @@ ext.libraries = [
exclude(group: "org.slf4j", module: "slf4j-api")
exclude(group: "com.squareup.okio", module: "okio")
force = true
},
dependencies.create("com.squareup.okhttp3:okhttp:$okhttp3Version") {
exclude(group: "org.slf4j", module: "slf4j-api")
force = true
}
],
okhttp : [
Expand Down
11 changes: 10 additions & 1 deletion gradle/tests.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,15 @@ if (hasTestsOfCategory(project, "InfluxDb")) {
}
}

if (hasTestsOfCategory(project, "Oracle")) {
task testOracle(type: Test) {
enabled = shouldTest(project, "Oracle")
useJUnitPlatform {
includeTags "Oracle"
}
}
}

if (hasTestsOfCategory(project, "Ldap")) {
task testLdap(type: Test) {
enabled = shouldTest(project, "Ldap")
Expand Down Expand Up @@ -237,7 +246,7 @@ test {
"Ldap", "Mail", "MariaDb", "Memcached",
"MongoDb", "MsSqlServer", "MySQL", "Postgres", "Redis",
"Radius", "AmazonWebServices", "RestfulApi", "Groovy",
"OAuth", "OIDC", "SAML", "UMA"
"OAuth", "OIDC", "SAML", "UMA", "Oracle"
}
enabled = "SIMPLE".equalsIgnoreCase(rootProject.testCategoryType) && !Boolean.getBoolean("skipTests")
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
import org.apereo.cas.config.CasPersonDirectoryConfiguration;
import org.apereo.cas.config.CasRegisteredServicesTestConfiguration;
import org.apereo.cas.config.support.CasWebApplicationServiceFactoryConfiguration;
import org.apereo.cas.config.support.EnvironmentConversionServiceInitializer;
import org.apereo.cas.logout.config.CasCoreLogoutConfiguration;
import org.apereo.cas.util.SchedulingUtils;
import org.apereo.cas.web.config.CasCookieConfiguration;
Expand All @@ -39,7 +38,6 @@
import org.springframework.mock.web.MockHttpServletRequest;
import org.springframework.mock.web.MockHttpServletResponse;
import org.springframework.mock.web.MockServletContext;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.TestPropertySource;
import org.springframework.webflow.context.servlet.ServletExternalContext;
import org.springframework.webflow.execution.Action;
Expand Down Expand Up @@ -80,15 +78,14 @@
RefreshAutoConfiguration.class,
CasCoreServicesConfiguration.class
})
@ContextConfiguration(initializers = EnvironmentConversionServiceInitializer.class)
@TestPropertySource(properties = "cas.sso.allowMissingServiceParameter=false")
public class InitialFlowSetupActionSsoTests {
@Autowired
@Qualifier("initialFlowSetupAction")
private Action action;

@Test
public void disableFlowIfNoService() throws Exception {
public void disableFlowIfNoService() {
val context = new MockRequestContext();
val request = new MockHttpServletRequest();
context.setExternalContext(new ServletExternalContext(new MockServletContext(), request, new MockHttpServletResponse()));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
import org.apereo.cas.config.CasPersonDirectoryConfiguration;
import org.apereo.cas.config.GoogleAuthenticatorCouchDbConfiguration;
import org.apereo.cas.config.support.CasWebApplicationServiceFactoryConfiguration;
import org.apereo.cas.config.support.EnvironmentConversionServiceInitializer;
import org.apereo.cas.config.support.authentication.GoogleAuthenticatorAuthenticationEventExecutionPlanConfiguration;
import org.apereo.cas.couchdb.core.CouchDbConnectorFactory;
import org.apereo.cas.couchdb.gauth.credential.GoogleAuthenticatorAccountCouchDbRepository;
Expand All @@ -38,7 +37,6 @@
import org.springframework.cloud.autoconfigure.RefreshAutoConfiguration;
import org.springframework.context.annotation.EnableAspectJAutoProxy;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.test.context.ContextConfiguration;

/**
* This is {@link CouchDbGoogleAuthenticatorTokenCredentialRepositoryTests}.
Expand Down Expand Up @@ -80,7 +78,6 @@
})
@EnableAspectJAutoProxy(proxyTargetClass = true)
@EnableScheduling
@ContextConfiguration(initializers = EnvironmentConversionServiceInitializer.class)
@Getter
@EnabledIfContinuousIntegration
public class CouchDbGoogleAuthenticatorTokenCredentialRepositoryTests extends BaseOneTimeTokenCredentialRepositoryTests {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
import org.apereo.cas.config.CasPersonDirectoryConfiguration;
import org.apereo.cas.config.GoogleAuthenticatorCouchDbConfiguration;
import org.apereo.cas.config.support.CasWebApplicationServiceFactoryConfiguration;
import org.apereo.cas.config.support.EnvironmentConversionServiceInitializer;
import org.apereo.cas.config.support.authentication.GoogleAuthenticatorAuthenticationEventExecutionPlanConfiguration;
import org.apereo.cas.couchdb.core.CouchDbConnectorFactory;
import org.apereo.cas.couchdb.gauth.token.GoogleAuthenticatorTokenCouchDbRepository;
Expand All @@ -37,7 +36,6 @@
import org.springframework.cloud.autoconfigure.RefreshAutoConfiguration;
import org.springframework.context.annotation.EnableAspectJAutoProxy;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.test.context.ContextConfiguration;

/**
* This is {@link GoogleAuthenticatorCouchDbTokenRepositoryTests}.
Expand Down Expand Up @@ -79,7 +77,6 @@
})
@EnableAspectJAutoProxy(proxyTargetClass = true)
@EnableScheduling
@ContextConfiguration(initializers = EnvironmentConversionServiceInitializer.class)
@Getter
@EnabledIfContinuousIntegration
public class GoogleAuthenticatorCouchDbTokenRepositoryTests extends BaseOneTimeTokenRepositoryTests {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import org.apereo.cas.gauth.credential.JpaGoogleAuthenticatorTokenCredentialRepositoryTests;
import org.apereo.cas.gauth.credential.MariaDbJpaGoogleAuthenticatorTokenCredentialRepositoryTests;
import org.apereo.cas.gauth.credential.OracleJpaGoogleAuthenticatorTokenCredentialRepositoryTests;
import org.apereo.cas.gauth.token.GoogleAuthenticatorJpaTokenRepositoryTests;
import org.apereo.cas.gauth.token.MariaDbGoogleAuthenticatorJpaTokenRepositoryTests;

Expand All @@ -19,6 +20,7 @@
JpaGoogleAuthenticatorTokenCredentialRepositoryTests.class,
MariaDbGoogleAuthenticatorJpaTokenRepositoryTests.class,
MariaDbJpaGoogleAuthenticatorTokenCredentialRepositoryTests.class,
OracleJpaGoogleAuthenticatorTokenCredentialRepositoryTests.class,
GoogleAuthenticatorJpaTokenRepositoryTests.class
})
@RunWith(JUnitPlatform.class)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
import org.apereo.cas.config.CasPersonDirectoryConfiguration;
import org.apereo.cas.config.GoogleAuthenticatorJpaConfiguration;
import org.apereo.cas.config.support.CasWebApplicationServiceFactoryConfiguration;
import org.apereo.cas.config.support.EnvironmentConversionServiceInitializer;
import org.apereo.cas.config.support.authentication.GoogleAuthenticatorAuthenticationEventExecutionPlanConfiguration;
import org.apereo.cas.logout.config.CasCoreLogoutConfiguration;
import org.apereo.cas.otp.repository.credentials.OneTimeTokenCredentialRepository;
Expand All @@ -36,7 +35,6 @@
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.EnableAspectJAutoProxy;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.transaction.annotation.EnableTransactionManagement;

/**
Expand Down Expand Up @@ -73,7 +71,6 @@
@EnableTransactionManagement(proxyTargetClass = true)
@EnableAspectJAutoProxy(proxyTargetClass = true)
@EnableScheduling
@ContextConfiguration(initializers = EnvironmentConversionServiceInitializer.class)
@Getter
public class JpaGoogleAuthenticatorTokenCredentialRepositoryTests extends BaseOneTimeTokenCredentialRepositoryTests {
@Autowired(required = false)
Expand Down
Loading

0 comments on commit 99d27a4

Please sign in to comment.