-
Notifications
You must be signed in to change notification settings - Fork 24.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Test unknown named application privileges #104863
base: main
Are you sure you want to change the base?
Changes from 1 commit
e5cdee7
8bd6be0
03f6e09
f3f8076
b4be2e2
56c5f4b
2d1e75e
0d8035d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||
---|---|---|---|---|
|
@@ -151,6 +151,32 @@ public void testUserWithWildcardPrivileges() throws Exception { | |||
} | ||||
} | ||||
|
||||
public void testNamed() throws IOException { | ||||
createApplicationPrivilege("app", "write", new String[] { "action:write/*" }); | ||||
createRole("correct", "app", new String[] { "read" }, new String[] { "*" }); | ||||
createRole("wrong", "app", new String[] { "read", randomFrom("create", "write") }, new String[] { "*" }); | ||||
|
||||
var password = new SecureString("password-123"); | ||||
createUser("correct", password, Set.of("correct")); | ||||
createUser("wrong", password, Set.of("wrong")); | ||||
|
||||
{ | ||||
var reqOptions = RequestOptions.DEFAULT.toBuilder() | ||||
.addHeader("Authorization", UsernamePasswordToken.basicAuthHeaderValue("correct", password)) | ||||
.build(); | ||||
var actual = hasPrivilege(reqOptions, "app", new String[] { "read" }, new String[] { "resource" }); | ||||
assertSinglePrivilege(actual, "resource", "read", true); | ||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This works and is expected behavior based on: #33928 (comment) |
||||
} | ||||
|
||||
{ | ||||
var reqOptions = RequestOptions.DEFAULT.toBuilder() | ||||
.addHeader("Authorization", UsernamePasswordToken.basicAuthHeaderValue("wrong", password)) | ||||
.build(); | ||||
var actual = hasPrivilege(reqOptions, "app", new String[] { "read" }, new String[] { "resource" }); | ||||
assertSinglePrivilege(actual, "resource", "read", true); | ||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This fails but shouldn't. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is the problem: Line 194 in 79f801b
We are checking for equality, but when there's more than one privilege on the Role, we fail this check since name is |
||||
} | ||||
} | ||||
|
||||
private void assertSinglePrivilege( | ||||
List<ResourcePrivileges> hasPrivilegesResult, | ||||
String expectedResource, | ||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Only difference between the roles: "single" unknown privilege or unknown privilege + plus another (known or unknown, doesn't matter).