@@ -52,9 +52,9 @@ public void testAuthorizeRunAs() {
5252 CustomAuthorizationEngine engine = new CustomAuthorizationEngine ();
5353 // unauthorized
5454 {
55- Authentication authentication =
56- new Authentication (new User ("joe " , new String []{ "custom_superuser" } , new User ( "bar " , "not_superuser" )),
57- new RealmRef ( "test " , "test" , "node " ), new RealmRef ("test" , "test" , "node" ));
55+ Authentication authentication = Authentication
56+ . newRealmAuthentication (new User ("bar " , "not_superuser" ) , new RealmRef ( "test " , "test" , "node" ))
57+ . runAs ( new User ( "joe " , "custom_superuser " ), new RealmRef ("test" , "test" , "node" ));
5858 RequestInfo info = new RequestInfo (authentication , request , action , null );
5959 PlainActionFuture <AuthorizationInfo > future = new PlainActionFuture <>();
6060 engine .resolveAuthorizationInfo (info , future );
@@ -69,9 +69,9 @@ public void testAuthorizeRunAs() {
6969
7070 // authorized
7171 {
72- Authentication authentication =
73- new Authentication (new User ("joe " , new String []{ "not_superuser" } , new User ( "bar " , "custom_superuser" )),
74- new RealmRef ( "test " , "test" , "node " ), new RealmRef ("test" , "test" , "node" ));
72+ Authentication authentication = Authentication
73+ . newRealmAuthentication (new User ("bar " , "custom_superuser" ) , new RealmRef ( "test " , "test" , "node" ))
74+ . runAs ( new User ( "joe " , "not_superuser " ), new RealmRef ("test" , "test" , "node" ));
7575 RequestInfo info = new RequestInfo (authentication , request , action , null );
7676 PlainActionFuture <AuthorizationInfo > future = new PlainActionFuture <>();
7777 engine .resolveAuthorizationInfo (info , future );
@@ -103,7 +103,8 @@ public void testAuthorizeClusterAction() {
103103 // unauthorized
104104 {
105105 RequestInfo unauthReqInfo =
106- new RequestInfo (new Authentication (new User ("joe" , "not_superuser" ), new RealmRef ("test" , "test" , "node" ), null ),
106+ new RequestInfo (
107+ Authentication .newRealmAuthentication (new User ("joe" , "not_superuser" ), new RealmRef ("test" , "test" , "node" )),
107108 requestInfo .getRequest (), requestInfo .getAction (), null );
108109 PlainActionFuture <AuthorizationInfo > future = new PlainActionFuture <>();
109110 engine .resolveAuthorizationInfo (unauthReqInfo , future );
@@ -128,7 +129,8 @@ public void testAuthorizeIndexAction() {
128129 // authorized
129130 {
130131 RequestInfo requestInfo =
131- new RequestInfo (new Authentication (new User ("joe" , "custom_superuser" ), new RealmRef ("test" , "test" , "node" ), null ),
132+ new RequestInfo (
133+ Authentication .newRealmAuthentication (new User ("joe" , "custom_superuser" ), new RealmRef ("test" , "test" , "node" )),
132134 new SearchRequest (), "indices:data/read/search" , null );
133135 PlainActionFuture <AuthorizationInfo > future = new PlainActionFuture <>();
134136 engine .resolveAuthorizationInfo (requestInfo , future );
@@ -149,7 +151,8 @@ public void testAuthorizeIndexAction() {
149151 // unauthorized
150152 {
151153 RequestInfo requestInfo =
152- new RequestInfo (new Authentication (new User ("joe" , "not_superuser" ), new RealmRef ("test" , "test" , "node" ), null ),
154+ new RequestInfo (
155+ Authentication .newRealmAuthentication (new User ("joe" , "not_superuser" ), new RealmRef ("test" , "test" , "node" )),
153156 new SearchRequest (), "indices:data/read/search" , null );
154157 PlainActionFuture <AuthorizationInfo > future = new PlainActionFuture <>();
155158 engine .resolveAuthorizationInfo (requestInfo , future );
@@ -171,7 +174,7 @@ private RequestInfo getRequestInfo() {
171174 final String action = "cluster:monitor/foo" ;
172175 final TransportRequest request = new TransportRequest () {};
173176 final Authentication authentication =
174- new Authentication (new User ("joe" , "custom_superuser" ), new RealmRef ("test" , "test" , "node" ), null );
177+ Authentication . newRealmAuthentication (new User ("joe" , "custom_superuser" ), new RealmRef ("test" , "test" , "node" ));
175178 return new RequestInfo (authentication , request , action , null );
176179 }
177180}
0 commit comments