Skip to content

Commit

Permalink
[#416] fix CI and refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
bamthomas committed Mar 31, 2020
1 parent d8ea450 commit 1bb3a85
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
import static org.apache.commons.collections4.map.UnmodifiableMap.unmodifiableMap;

public class HashMapUser extends User implements net.codestory.http.security.User {
private static final String DATASHARE_INDICES_KEY = "datashare_indices";
public static final String DATASHARE_PROJECTS_KEY = "datashare_projects";
final Map<String, Object> userMap;

public HashMapUser(final Map<String, Object> userMap) {
Expand Down Expand Up @@ -49,7 +49,7 @@ public String toJson() {
}

public List<String> getProjects() {
return (List<String>) ofNullable(userMap.get(DATASHARE_INDICES_KEY)).orElse(new LinkedList<>());
return (List<String>) ofNullable(userMap.get(DATASHARE_PROJECTS_KEY)).orElse(new LinkedList<>());
}

public Map<String, Object> getMap() {
Expand All @@ -66,7 +66,7 @@ public Map<String, Object> getMap() {
public static HashMapUser local() { return localUser("local"); }

public static HashMapUser localUser(String id) {
return new HashMapUser(new HashMap<String, Object>() {{ put("uid", id); put(DATASHARE_INDICES_KEY, singletonList(id + "-datashare"));}}) {
return new HashMapUser(new HashMap<String, Object>() {{ put("uid", id); put(DATASHARE_PROJECTS_KEY, singletonList(id + "-datashare"));}}) {
@Override public String[] roles() { return new String[] {"local"};}
};
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ protected Payload otherUri(String uri, Context context, PayloadSupplier nextFilt
private User createUser(String userName) {
HashMapUser user = new HashMapUser(new HashMap<String, Object>() {{
put("uid", userName);
put("datashare_projects", singletonList(project));
put(HashMapUser.DATASHARE_PROJECTS_KEY, singletonList(project));
}});
((RedisUsers)users).createUser(user);
return user;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public void test_get_indices_for_local_user() {
public void test_get_indices_for_external_user() {
assertThat(new HashMapUser(new HashMap<String, Object>() {{
put("uid", "userid");
put("datashare_indices", Collections.singletonList("external_index"));
put("datashare_projects", Collections.singletonList("external_index"));
}}).getProjects()).containsExactly("external_index");
}
}

0 comments on commit 1bb3a85

Please sign in to comment.