aboutsummaryrefslogtreecommitdiffstats
path: root/server/sonar-auth-ldap
diff options
context:
space:
mode:
authorDuarte Meneses <duarte.meneses@sonarsource.com>2019-12-09 09:34:43 -0600
committerSonarTech <sonartech@sonarsource.com>2019-12-10 20:46:09 +0100
commitd1fd889554bccbb50122550899dbb66b90b04f78 (patch)
tree9cad838366292ee79b77ac3513403f7489b06355 /server/sonar-auth-ldap
parentf86a1094588e4e47b3abf612891af0431653cd0e (diff)
downloadsonarqube-d1fd889554bccbb50122550899dbb66b90b04f78.tar.gz
sonarqube-d1fd889554bccbb50122550899dbb66b90b04f78.zip
Fix code quality issues and reduce dependency on Guava
Diffstat (limited to 'server/sonar-auth-ldap')
-rw-r--r--server/sonar-auth-ldap/src/main/java/org/sonar/auth/ldap/Krb5LoginConfiguration.java2
-rw-r--r--server/sonar-auth-ldap/src/test/java/org/sonar/auth/ldap/LdapAutodiscoveryTest.java2
-rw-r--r--server/sonar-auth-ldap/src/test/java/org/sonar/auth/ldap/LdapGroupsProviderTest.java2
-rw-r--r--server/sonar-auth-ldap/src/test/java/org/sonar/auth/ldap/LdapSettingsManagerTest.java23
-rw-r--r--server/sonar-auth-ldap/src/test/java/org/sonar/auth/ldap/LdapUsersProviderTest.java2
5 files changed, 12 insertions, 19 deletions
diff --git a/server/sonar-auth-ldap/src/main/java/org/sonar/auth/ldap/Krb5LoginConfiguration.java b/server/sonar-auth-ldap/src/main/java/org/sonar/auth/ldap/Krb5LoginConfiguration.java
index c13360733c6..6748c4b166a 100644
--- a/server/sonar-auth-ldap/src/main/java/org/sonar/auth/ldap/Krb5LoginConfiguration.java
+++ b/server/sonar-auth-ldap/src/main/java/org/sonar/auth/ldap/Krb5LoginConfiguration.java
@@ -32,7 +32,7 @@ public class Krb5LoginConfiguration extends Configuration {
static {
String loginModule = "com.sun.security.auth.module.Krb5LoginModule";
AppConfigurationEntry.LoginModuleControlFlag flag = AppConfigurationEntry.LoginModuleControlFlag.REQUIRED;
- CONFIG_LIST[0] = new AppConfigurationEntry(loginModule, flag, new HashMap<String, Object>());
+ CONFIG_LIST[0] = new AppConfigurationEntry(loginModule, flag, new HashMap<>());
}
/**
diff --git a/server/sonar-auth-ldap/src/test/java/org/sonar/auth/ldap/LdapAutodiscoveryTest.java b/server/sonar-auth-ldap/src/test/java/org/sonar/auth/ldap/LdapAutodiscoveryTest.java
index 989a3305fd7..7cfa94a1073 100644
--- a/server/sonar-auth-ldap/src/test/java/org/sonar/auth/ldap/LdapAutodiscoveryTest.java
+++ b/server/sonar-auth-ldap/src/test/java/org/sonar/auth/ldap/LdapAutodiscoveryTest.java
@@ -73,7 +73,7 @@ public class LdapAutodiscoveryTest {
Attribute attribute = mock(Attribute.class);
NamingEnumeration namingEnumeration = mock(NamingEnumeration.class);
- when(context.getAttributes(Mockito.anyString(), Mockito.<String[]>anyObject())).thenReturn(attributes);
+ when(context.getAttributes(Mockito.anyString(), Mockito.anyObject())).thenReturn(attributes);
when(attributes.get(Mockito.eq("srv"))).thenReturn(attribute);
when(attribute.getAll()).thenReturn(namingEnumeration);
when(namingEnumeration.hasMore()).thenReturn(true, true, true, true, true, false);
diff --git a/server/sonar-auth-ldap/src/test/java/org/sonar/auth/ldap/LdapGroupsProviderTest.java b/server/sonar-auth-ldap/src/test/java/org/sonar/auth/ldap/LdapGroupsProviderTest.java
index a2aab4bc3c0..7859f415903 100644
--- a/server/sonar-auth-ldap/src/test/java/org/sonar/auth/ldap/LdapGroupsProviderTest.java
+++ b/server/sonar-auth-ldap/src/test/java/org/sonar/auth/ldap/LdapGroupsProviderTest.java
@@ -44,7 +44,7 @@ public class LdapGroupsProviderTest {
public static LdapServer infosupportServer = new LdapServer(USERS_INFOSUPPORT_COM_LDIF, "infosupport.com", "dc=infosupport,dc=com");
@Test
- public void defaults() throws Exception {
+ public void defaults() {
MapSettings settings = LdapSettingsFactory.generateSimpleAnonymousAccessSettings(exampleServer, null);
LdapSettingsManager settingsManager = new LdapSettingsManager(settings, new LdapAutodiscovery());
diff --git a/server/sonar-auth-ldap/src/test/java/org/sonar/auth/ldap/LdapSettingsManagerTest.java b/server/sonar-auth-ldap/src/test/java/org/sonar/auth/ldap/LdapSettingsManagerTest.java
index 88d16dedec8..02780a2af32 100644
--- a/server/sonar-auth-ldap/src/test/java/org/sonar/auth/ldap/LdapSettingsManagerTest.java
+++ b/server/sonar-auth-ldap/src/test/java/org/sonar/auth/ldap/LdapSettingsManagerTest.java
@@ -62,7 +62,7 @@ public class LdapSettingsManagerTest {
}
@Test
- public void testContextFactoriesWithSingleLdap() throws Exception {
+ public void testContextFactoriesWithSingleLdap() {
LdapSettingsManager settingsManager = new LdapSettingsManager(
generateSingleLdapSettingsWithUserAndGroupMapping(), new LdapAutodiscovery());
assertThat(settingsManager.getContextFactories().size()).isEqualTo(1);
@@ -71,11 +71,9 @@ public class LdapSettingsManagerTest {
/**
* Test there are 2 @link{org.sonar.plugins.ldap.LdapContextFactory}s found.
*
- * @throws Exception
- * This is not expected.
*/
@Test
- public void testContextFactoriesWithMultipleLdap() throws Exception {
+ public void testContextFactoriesWithMultipleLdap() {
LdapSettingsManager settingsManager = new LdapSettingsManager(
generateMultipleLdapSettingsWithUserAndGroupMapping(), new LdapAutodiscovery());
assertThat(settingsManager.getContextFactories().size()).isEqualTo(2);
@@ -84,7 +82,7 @@ public class LdapSettingsManagerTest {
}
@Test
- public void testAutodiscover() throws Exception {
+ public void testAutodiscover() {
LdapAutodiscovery ldapAutodiscovery = mock(LdapAutodiscovery.class);
LdapSrvRecord ldap1 = new LdapSrvRecord("ldap://localhost:189", 1, 1);
LdapSrvRecord ldap2 = new LdapSrvRecord("ldap://localhost:1899", 1, 1);
@@ -95,9 +93,9 @@ public class LdapSettingsManagerTest {
}
@Test
- public void testAutodiscoverFailed() throws Exception {
+ public void testAutodiscoverFailed() {
LdapAutodiscovery ldapAutodiscovery = mock(LdapAutodiscovery.class);
- when(ldapAutodiscovery.getLdapServers("example.org")).thenReturn(Collections.<LdapSrvRecord>emptyList());
+ when(ldapAutodiscovery.getLdapServers("example.org")).thenReturn(Collections.emptyList());
LdapSettingsManager settingsManager = new LdapSettingsManager(
generateAutodiscoverSettings(), ldapAutodiscovery);
@@ -110,11 +108,9 @@ public class LdapSettingsManagerTest {
/**
* Test there are 2 @link{org.sonar.plugins.ldap.LdapUserMapping}s found.
*
- * @throws Exception
- * This is not expected.
*/
@Test
- public void testUserMappings() throws Exception {
+ public void testUserMappings() {
LdapSettingsManager settingsManager = new LdapSettingsManager(
generateMultipleLdapSettingsWithUserAndGroupMapping(), new LdapAutodiscovery());
assertThat(settingsManager.getUserMappings().size()).isEqualTo(2);
@@ -125,11 +121,9 @@ public class LdapSettingsManagerTest {
/**
* Test there are 2 @link{org.sonar.plugins.ldap.LdapGroupMapping}s found.
*
- * @throws Exception
- * This is not expected.
*/
@Test
- public void testGroupMappings() throws Exception {
+ public void testGroupMappings() {
LdapSettingsManager settingsManager = new LdapSettingsManager(
generateMultipleLdapSettingsWithUserAndGroupMapping(), new LdapAutodiscovery());
assertThat(settingsManager.getGroupMappings().size()).isEqualTo(2);
@@ -140,10 +134,9 @@ public class LdapSettingsManagerTest {
/**
* Test what happens when no configuration is set.
* Normally there will be a contextFactory, but the autodiscovery doesn't work for the test server.
- * @throws Exception
*/
@Test
- public void testEmptySettings() throws Exception {
+ public void testEmptySettings() {
LdapSettingsManager settingsManager = new LdapSettingsManager(
new MapSettings(), new LdapAutodiscovery());
diff --git a/server/sonar-auth-ldap/src/test/java/org/sonar/auth/ldap/LdapUsersProviderTest.java b/server/sonar-auth-ldap/src/test/java/org/sonar/auth/ldap/LdapUsersProviderTest.java
index 90e61e59fea..ff2c503a044 100644
--- a/server/sonar-auth-ldap/src/test/java/org/sonar/auth/ldap/LdapUsersProviderTest.java
+++ b/server/sonar-auth-ldap/src/test/java/org/sonar/auth/ldap/LdapUsersProviderTest.java
@@ -43,7 +43,7 @@ public class LdapUsersProviderTest {
public static LdapServer infosupportServer = new LdapServer(USERS_INFOSUPPORT_COM_LDIF, "infosupport.com", "dc=infosupport,dc=com");
@Test
- public void test() throws Exception {
+ public void test() {
Settings settings = LdapSettingsFactory.generateSimpleAnonymousAccessSettings(exampleServer, infosupportServer);
LdapSettingsManager settingsManager = new LdapSettingsManager(settings, new LdapAutodiscovery());
LdapUsersProvider usersProvider = new LdapUsersProvider(settingsManager.getContextFactories(), settingsManager.getUserMappings());