Skip to content

Serialize application privileges in PutRoleRequest#31712

Merged
tvernum merged 4 commits intoelastic:security-app-privsfrom
tvernum:app-priv/role-serialize
Jul 3, 2018
Merged

Serialize application privileges in PutRoleRequest#31712
tvernum merged 4 commits intoelastic:security-app-privsfrom
tvernum:app-priv/role-serialize

Conversation

@tvernum
Copy link
Copy Markdown
Contributor

@tvernum tvernum commented Jul 2, 2018

The serialization methods for PutRoleRequest did not handle the
applicationPrivileges array.
Fixes this and added tests

The serialization methods for `PutRoleRequest` did not handle the
applicationPrivileges array.
Fixes this and added tests
@tvernum tvernum added >bug review :Security/Authorization Roles, Privileges, DLS/FLS, RBAC/ABAC labels Jul 2, 2018
@tvernum tvernum requested a review from albertzaharovits July 2, 2018 02:53
@elasticmachine
Copy link
Copy Markdown
Collaborator

Pinging @elastic/es-security

out.writeStringArray(runAs);
refreshPolicy.writeTo(out);
out.writeMap(metadata);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: extra line

final PutRoleRequest copy = new PutRoleRequest();
copy.readFrom(out.bytes().streamInput());

assertThat(copy.roleDescriptor(), equalTo(original.roleDescriptor()));
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see that RoleDescriptor.ApplicationPrivilege#equals

does not check for application name to be equal.
This looks to me as an oversight?

request.cluster(randomSubsetOf(Arrays.asList("monitor", "manage", "all", "manage_security", "manage_ml", "monitor_watcher"))
.toArray(Strings.EMPTY_ARRAY));

for (int i = randomIntBetween(1, 4); i > 0; i--) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

randomIntBetween(0, 4), would be more alike to a true request?


final Supplier<String> stringWithInitialLowercase = ()
-> randomAlphaOfLength(1).toLowerCase(Locale.ROOT) + randomAlphaOfLengthBetween(3, 12);
final ApplicationResourcePrivileges[] applicationPrivileges = new ApplicationResourcePrivileges[randomIntBetween(1, 5)];
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same heere, randomIntBetween(0, 5) would be more life-like

Copy link
Copy Markdown
Contributor

@albertzaharovits albertzaharovits left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One question and 3 nits, OTT LGTM

@tvernum tvernum merged commit 95948c7 into elastic:security-app-privs Jul 3, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

>bug :Security/Authorization Roles, Privileges, DLS/FLS, RBAC/ABAC

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants