Fix: Make compilation work with java 8

Also fixes a test, which was relying on order

Original commit: elastic/x-pack-elasticsearch@56b8cd0381
This commit is contained in:
Alexander Reelsen 2014-09-01 11:11:58 +02:00
parent ef48bf7c6e
commit 4fa7abd7d6
2 changed files with 13 additions and 11 deletions

View File

@ -27,7 +27,7 @@ public class AuthenticationModule extends AbstractModule implements SpawnModules
@Override
public Iterable<? extends Module> spawnModules() {
ImmutableList.Builder<? extends Module> modules = ImmutableList.builder();
ImmutableList.Builder<Module> modules = ImmutableList.builder();
modules.add(new SystemRealm.Module());
if (ESUsersModule.enabled(settings)) {
modules.add(new ESUsersModule());

View File

@ -122,21 +122,23 @@ public class ESUsersToolTests extends CliToolTestCase {
assertFileExists(userFile);
List<String> lines = Files.readLines(userFile, Charsets.UTF_8);
assertThat(lines.size(), is(2));
assertThat(lines.get(0), equalTo("user2:hash2"));
assertThat(lines, hasSize(2));
assertThat(lines, hasItem("user2:hash2"));
assertThat(lines, hasItem(startsWith("user1:")));
// we can't just hash again and compare the lines, as every time we hash a new salt is generated
// instead we'll just verify the generated hash against the correct password.
String line = lines.get(1);
assertThat(line, startsWith("user1:"));
String hash = line.substring("user1:".length());
assertThat(Hasher.HTPASSWD.verify("changeme".toCharArray(), hash.toCharArray()), is(true));
for (String line : lines) {
if (line.startsWith("user1")) {
String hash = line.substring("user1:".length());
assertThat(Hasher.HTPASSWD.verify("changeme".toCharArray(), hash.toCharArray()), is(true));
}
}
assertFileExists(userRolesFile);
lines = Files.readLines(userRolesFile, Charsets.UTF_8);
assertThat(lines.size(), is(2));
assertThat(lines.get(0), equalTo("user2:r3,r4"));
line = lines.get(1);
assertThat(line, equalTo("user1:r1,r2"));
assertThat(lines, hasSize(2));
assertThat(lines, containsInAnyOrder("user2:r3,r4", "user1:r1,r2"));
}
@Test