Skip to content

Commit

Permalink
fix(api): Stop parsing application names in fiat using frigga. (#225)
Browse files Browse the repository at this point in the history
For APPLICATION resourceType, the caller should pass in the application
name as the resourceName instead of fiat trying to parse out the name.
This allows applications names with dashes to work properly.

spinnaker/spinnaker#2513
  • Loading branch information
dibyom authored and lwander committed May 8, 2018
1 parent 109def3 commit 3167d18
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -103,11 +103,8 @@ public boolean hasPermission(Authentication authentication,
a = Authorization.valueOf(authorization.toString());
}

if (r == ResourceType.APPLICATION) {
val parsedName = Names.parseName(resourceName.toString()).getApp();
if (StringUtils.isNotEmpty(parsedName)) {
resourceName = parsedName;
}
if (r == ResourceType.APPLICATION && StringUtils.isNotEmpty(resourceName.toString())) {
resourceName = resourceName.toString();
}

UserPermission.View permission = getPermission(getUsername(authentication));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,21 +73,18 @@ class FiatPermissionEvaluatorSpec extends Specification {
then:
1 * fiatService.getUserPermission("testUser") >> new UserPermission(
applications: [
new Application(name: "abc",
new Application(name: "abc-def",
permissions: Permissions.factory([
(Authorization.READ): ["testRole"]
]))
])),
],
roles: [new Role("testRole")]
).getView()
result

where:
resource | resourceName | resourceType
"abc" | "abc" | ResourceType.APPLICATION
"abc-def" | "abc" | ResourceType.APPLICATION
"abc-def-ghi" | "abc" | ResourceType.APPLICATION
"abc-def-ghi-1234" | "abc" | ResourceType.APPLICATION
resource | resourceName | resourceType
"abc-def" | "abc-def" | ResourceType.APPLICATION

authorization = 'READ'
}
Expand Down

0 comments on commit 3167d18

Please sign in to comment.