Skip to content

Commit 6702707

Browse files
committed
Add tests for SystemSubject
Signed-off-by: Craig Perkins <cwperx@amazon.com>
1 parent 4f4d758 commit 6702707

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
/*
2+
* SPDX-License-Identifier: Apache-2.0
3+
*
4+
* The OpenSearch Contributors require contributions made to
5+
* this file be licensed under the Apache-2.0 license or a
6+
* compatible open source license.
7+
*/
8+
9+
package org.opensearch.identity;
10+
11+
import org.opensearch.test.OpenSearchTestCase;
12+
import org.opensearch.threadpool.TestThreadPool;
13+
import org.opensearch.threadpool.ThreadPool;
14+
15+
public class SystemSubjectTests extends OpenSearchTestCase {
16+
public void testSystemSubject() {
17+
ThreadPool threadPool = new TestThreadPool(getTestName());
18+
SystemSubject systemSubject = SystemSubject.getInstance();
19+
assertEquals("system", systemSubject.getPrincipal().getName());
20+
systemSubject.initialize(threadPool);
21+
assertFalse(threadPool.getThreadContext().isSystemContext());
22+
systemSubject.runAs(() -> {
23+
assertTrue(threadPool.getThreadContext().isSystemContext());
24+
return false;
25+
});
26+
terminate(threadPool);
27+
}
28+
}

0 commit comments

Comments
 (0)