Skip to content

Commit 1abfe97

Browse files
committed
Fix tests
Signed-off-by: Craig Perkins <[email protected]>
1 parent bc610a2 commit 1abfe97

File tree

2 files changed

+9
-9
lines changed

2 files changed

+9
-9
lines changed

plugins/identity-shiro/src/main/java/org/opensearch/identity/shiro/ShiroIdentityPlugin.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -83,14 +83,14 @@ public AuthcRestHandler(RestHandler original) {
8383

8484
@Override
8585
public void handleRequest(RestRequest request, RestChannel channel, NodeClient client) throws Exception {
86-
final AuthToken token = RestTokenExtractor.extractToken(request);
87-
// If no token was found, continue executing the request
88-
if (token == null) {
89-
// Authentication did not fail so return true. Authorization is handled at the action level.
90-
delegate.handleRequest(request, channel, client);
91-
return;
92-
}
9386
try {
87+
final AuthToken token = RestTokenExtractor.extractToken(request);
88+
// If no token was found, continue executing the request
89+
if (token == null) {
90+
// Authentication did not fail so return true. Authorization is handled at the action level.
91+
delegate.handleRequest(request, channel, client);
92+
return;
93+
}
9494
ShiroSubject shiroSubject = (ShiroSubject) getSubject();
9595
shiroSubject.authenticate(token);
9696
// Caller was authorized, forward the request to the handler

plugins/identity-shiro/src/main/java/org/opensearch/identity/shiro/realm/OpenSearchRealm.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ public OpenSearchRealm build() {
9191
public User getInternalUser(final String principalIdentifier) throws UnknownAccountException {
9292
final User userRecord = internalUsers.get(principalIdentifier);
9393
if (userRecord == null) {
94-
throw new UnknownAccountException();
94+
throw new UnknownAccountException("Incorrect credentials");
9595
}
9696
return userRecord;
9797
}
@@ -129,7 +129,7 @@ protected AuthenticationInfo doGetAuthenticationInfo(final AuthenticationToken t
129129
return sai;
130130
} else {
131131
// Bad password
132-
throw new IncorrectCredentialsException();
132+
throw new IncorrectCredentialsException("Incorrect credentials");
133133
}
134134
}
135135

0 commit comments

Comments
 (0)