Skip to content

Commit

Permalink
feat(roles): Add Execute as a type of Authorization
Browse files Browse the repository at this point in the history
  • Loading branch information
dibyom committed Apr 19, 2019
1 parent 6b10574 commit 29adca8
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,6 @@

public enum Authorization {
READ,
WRITE
WRITE,
EXECUTE
}
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public static class View extends BaseView implements Authorizable {
public View(Application application, Set<Role> userRoles, boolean isAdmin) {
this.name = application.name;
if (isAdmin) {
this.authorizations = Sets.newHashSet(Authorization.READ, Authorization.WRITE);
this.authorizations = Sets.newHashSet(Authorization.READ, Authorization.WRITE, Authorization.EXECUTE);
} else {
this.authorizations = application.permissions.getAuthorizations(userRoles);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,7 @@ public Set<Authorization> getAuthorizations(List<String> userRoles) {
.collect(Collectors.toSet());
}

@VisibleForTesting
protected List<String> get(Authorization a) {
public List<String> get(Authorization a) {
return permissions.get(a);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ class PermissionsSpec extends Specification {

private static final Authorization R = Authorization.READ
private static final Authorization W = Authorization.WRITE
private static final Authorization E = Authorization.EXECUTE

@Autowired
TestConfigProps testConfigProps
Expand Down Expand Up @@ -149,7 +150,7 @@ class PermissionsSpec extends Specification {
Permissions p = new Permissions.Builder().build()

expect:
p.getAuthorizations([]) == [R, W] as Set
p.getAuthorizations([]) == [R, W, E] as Set

when:
p = Permissions.factory([(R): ["bar"], (W): ["bar"]])
Expand Down

0 comments on commit 29adca8

Please sign in to comment.