@@ -63,34 +63,32 @@ public void init() {
6363 }
6464
6565 @ After
66- public void shutdown () throws InterruptedException {
66+ public void shutdown () {
6767 terminate (threadPool );
6868 }
6969
7070 public void testStore_ConfiguredWithUnreadableFile () throws Exception {
71- Path xpackConf = env .configFile ();
72- Files .createDirectories (xpackConf );
73- Path file = xpackConf .resolve ("users" );
71+ Path configDir = env .configFile ();
72+ Files .createDirectories (configDir );
73+ Path file = configDir .resolve ("users" );
7474
7575 // writing in utf_16 should cause a parsing error as we try to read the file in utf_8
7676 Files .write (file , Collections .singletonList ("aldlfkjldjdflkjd" ), StandardCharsets .UTF_16 );
7777
78- Settings fileSettings = randomBoolean () ? Settings .EMPTY : Settings .builder ().put ("files.users" , file .toAbsolutePath ()).build ();
79- RealmConfig config = getRealmConfig (fileSettings );
78+ RealmConfig config = getRealmConfig ();
8079 ResourceWatcherService watcherService = new ResourceWatcherService (settings , threadPool );
8180 FileUserPasswdStore store = new FileUserPasswdStore (config , watcherService );
8281 assertThat (store .usersCount (), is (0 ));
8382 }
8483
8584 public void testStore_AutoReload () throws Exception {
8685 Path users = getDataPath ("users" );
87- Path xpackConf = env .configFile ();
88- Files .createDirectories (xpackConf );
89- Path file = xpackConf .resolve ("users" );
86+ Path configDir = env .configFile ();
87+ Files .createDirectories (configDir );
88+ Path file = configDir .resolve ("users" );
9089 Files .copy (users , file , StandardCopyOption .REPLACE_EXISTING );
9190 final Hasher hasher = Hasher .resolve (settings .get ("xpack.security.authc.password_hashing.algorithm" ));
92- Settings fileSettings = randomBoolean () ? Settings .EMPTY : Settings .builder ().put ("files.users" , file .toAbsolutePath ()).build ();
93- RealmConfig config = getRealmConfig (fileSettings );
91+ RealmConfig config = getRealmConfig ();
9492 ResourceWatcherService watcherService = new ResourceWatcherService (settings , threadPool );
9593 final CountDownLatch latch = new CountDownLatch (1 );
9694
@@ -120,23 +118,19 @@ public void testStore_AutoReload() throws Exception {
120118 assertThat (result .getUser (), is (user ));
121119 }
122120
123- private RealmConfig getRealmConfig (Settings fileSettings ) {
121+ private RealmConfig getRealmConfig () {
124122 final RealmConfig .RealmIdentifier identifier = new RealmConfig .RealmIdentifier ("file" , "file-test" );
125123 return new RealmConfig (identifier , settings , env , threadPool .getThreadContext ());
126124 }
127125
128126 public void testStore_AutoReload_WithParseFailures () throws Exception {
129127 Path users = getDataPath ("users" );
130- Path xpackConf = env .configFile ();
131- Files .createDirectories (xpackConf );
132- Path testUsers = xpackConf .resolve ("users" );
128+ Path confDir = env .configFile ();
129+ Files .createDirectories (confDir );
130+ Path testUsers = confDir .resolve ("users" );
133131 Files .copy (users , testUsers , StandardCopyOption .REPLACE_EXISTING );
134132
135- Settings fileSettings = Settings .builder ()
136- .put ("files.users" , testUsers .toAbsolutePath ())
137- .build ();
138-
139- RealmConfig config = getRealmConfig (fileSettings );
133+ RealmConfig config = getRealmConfig ();
140134 ResourceWatcherService watcherService = new ResourceWatcherService (settings , threadPool );
141135 final CountDownLatch latch = new CountDownLatch (1 );
142136
@@ -192,6 +186,7 @@ public void testParseFile_Empty() throws Exception {
192186 Path empty = createTempFile ();
193187 Logger logger = CapturingLogger .newCapturingLogger (Level .DEBUG , null );
194188 Map <String , char []> users = FileUserPasswdStore .parseFile (empty , logger , Settings .EMPTY );
189+ assertThat (users , notNullValue ());
195190 assertThat (users .isEmpty (), is (true ));
196191 List <String > events = CapturingLogger .output (logger .getName (), Level .DEBUG );
197192 assertThat (events .size (), is (1 ));
0 commit comments