Since Jmix 1.4
the basic application test fail, if the application contains the LDAP-starter dependency but the (test environment) configuration disables the LDAP authentication.
At runtime it works as expected but the basic unit test loading the context fails in disabled ldap state:
MyApplicationTests > contextLoads() FAILED
java.lang.IllegalStateException: Failed to load ApplicationContext
at org.springframework.test.context.cache.DefaultCacheAwareContextLoaderDelegate.loadContext(DefaultCacheAwareContextLoaderDelegate.java:98)
...
at worker.org.gradle.process.internal.worker.GradleWorkerMain.main(GradleWorkerMain.java:74)
Caused by:
org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'ui_LoginScreenSupport': Unsatisfied dependency expressed through method 'setAuthenticationManager' parameter 0; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 'org.springframework.security.authentication.AuthenticationManager' available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {}
at app//org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredMethodElement.resolveMethodArguments(AutowiredAnnotationBeanPostProcessor.java:767)
...
at app//org.springframework.test.context.cache.DefaultCacheAwareContextLoaderDelegate.loadContext(DefaultCacheAwareContextLoaderDelegate.java:90)
... 87 more
Caused by:
org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 'org.springframework.security.authentication.AuthenticationManager' available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {}
at app//org.springframework.beans.factory.support.DefaultListableBeanFactory.raiseNoMatchingBeanFound(DefaultListableBeanFactory.java:1801)
at app//org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1357)
at app//org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1311)
at app//org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredMethodElement.resolveMethodArguments(AutowiredAnnotationBeanPostProcessor.java:759)
... 106 more
1 test completed, 1 failed
- Jmix version:
1.4.1
- Jmix-Dependencies:
dependencies {
implementation 'io.jmix.core:jmix-core-starter'
implementation 'io.jmix.data:jmix-eclipselink-starter'
implementation 'io.jmix.ui:jmix-ui-starter'
implementation 'io.jmix.ui:jmix-ui-data-starter'
implementation 'io.jmix.ui:jmix-ui-themes-compiled'
implementation 'io.jmix.ui:jmix-ui-widgets-compiled'
implementation 'io.jmix.security:jmix-security-starter'
implementation 'io.jmix.security:jmix-security-ui-starter'
implementation 'io.jmix.security:jmix-security-data-starter'
implementation 'io.jmix.localfs:jmix-localfs-starter'
implementation 'io.jmix.datatools:jmix-datatools-starter'
implementation 'io.jmix.datatools:jmix-datatools-ui-starter'
implementation 'io.jmix.ldap:jmix-ldap-starter'
implementation 'io.jmix.translations:jmix-translations-de'
implementation 'io.jmix.ui:jmix-ui-themes'
implementation 'org.springframework.boot:spring-boot-starter-web'
runtimeOnly 'org.hsqldb:hsqldb'
testImplementation('org.springframework.boot:spring-boot-starter-test') {
exclude group: 'org.junit.vintage', module: 'junit-vintage-engine'
}
themes 'io.jmix.ui:jmix-ui-themes'
}
- test environment configuration dummy configuration:
jmix.ldap.enabled = false
jmix.ldap.userSearchBase = ou=users
jmix.ldap.userSearchFilter = (uid={0})
jmix.ldap.usernameAttribute = uid
jmix.ldap.groupRoleAttribute = cn
jmix.ldap.groupSearchBase =
jmix.ldap.groupSearchSubtree = true
jmix.ldap.groupSearchFilter = (uniqueMember={0})
jmix.ldap.useActiveDirectoryConfiguration = false
jmix.ldap.synchronizeRoleAssignments = true
jmix.ldap.synchronizeUserOnLogin = true
jmix.ldap.defaultRoles = ui-minimal
jmix.ldap.standardAuthenticationUsers = admin
jmix.ldap.urls = ldap://change-it.localhost:389/
jmix.ldap.baseDn = dc=acme,dc=com
jmix.ldap.managerDn = cn=directory-reader,ou=users,dc=acme,dc=com
jmix.ldap.managerPassword = changeit
jmix.ldap.activeDirectoryDomain = ad.change-it.localhost
jmix.ldap.groupForSynchronization = cn=ALL,ou=groups,dc=acme,dc=com
jmix.ldap.use-active-directory-configuration = false
Simply enabling the property jmix.ldap.enabled
and keeping all other configuration values on dummy content is a workaround and makes the test pass.
Until Jmix 1.3.5
this change was not required to succeed the unit test without production values.