From c4809834398b4312016cc77dc8b28bf5be500e37 Mon Sep 17 00:00:00 2001 From: Stephen Chen Date: Mon, 14 May 2018 12:39:46 -0400 Subject: [PATCH] fix(roles/file): Handle empty file-based roles. (#227) --- .../fiat/roles/file/FileBasedUserRolesProvider.java | 7 +++++-- fiat-file/src/test/resources/fiat-test-permissions.yml | 4 ++++ 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/fiat-file/src/main/java/com/netflix/spinnaker/fiat/roles/file/FileBasedUserRolesProvider.java b/fiat-file/src/main/java/com/netflix/spinnaker/fiat/roles/file/FileBasedUserRolesProvider.java index a30fbb34e..8361a546c 100644 --- a/fiat-file/src/main/java/com/netflix/spinnaker/fiat/roles/file/FileBasedUserRolesProvider.java +++ b/fiat-file/src/main/java/com/netflix/spinnaker/fiat/roles/file/FileBasedUserRolesProvider.java @@ -102,9 +102,12 @@ static class UserRoles { List roles; public List getRoles() { + if (roles == null) { + return Collections.emptyList(); + } return roles.stream() - .map(r -> new Role(r.getName()).setSource(Role.Source.FILE)) - .collect(Collectors.toList()); + .map(r -> new Role(r.getName()).setSource(Role.Source.FILE)) + .collect(Collectors.toList()); } } } diff --git a/fiat-file/src/test/resources/fiat-test-permissions.yml b/fiat-file/src/test/resources/fiat-test-permissions.yml index 87a0337c6..bf3b9bbf1 100644 --- a/fiat-file/src/test/resources/fiat-test-permissions.yml +++ b/fiat-file/src/test/resources/fiat-test-permissions.yml @@ -7,3 +7,7 @@ users: roles: - crimeFighter - jokerJailer + - username: robin + roles: [] + - username: nanana +