Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix where memeber or token with null permission #1076

Merged
merged 2 commits into from
Dec 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@
*/
package com.linecorp.centraldogma.server.metadata;

import static com.google.common.collect.ImmutableMap.toImmutableMap;

import java.io.IOException;
import java.util.Collection;
import java.util.Map;
Expand All @@ -29,6 +27,8 @@
import com.fasterxml.jackson.databind.DeserializationContext;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.deser.std.StdDeserializer;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableMap.Builder;

import com.linecorp.centraldogma.common.RepositoryRole;
import com.linecorp.centraldogma.internal.Jackson;
Expand Down Expand Up @@ -94,7 +94,14 @@ private static RepositoryRole repositoryRole(Collection<Permission> permissions)
}

private static Map<String, RepositoryRole> convert(Map<String, Collection<Permission>> permissions) {
return permissions.entrySet().stream()
.collect(toImmutableMap(Entry::getKey, entry -> repositoryRole(entry.getValue())));
final Builder<String, RepositoryRole> builder = ImmutableMap.builder();
for (Entry<String, Collection<Permission>> entry : permissions.entrySet()) {
final RepositoryRole repositoryRole = repositoryRole(entry.getValue());
if (repositoryRole != null) {
builder.put(entry.getKey(), repositoryRole);
}
}

return builder.build();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,14 @@ void deserializeLegacyFormat() throws Exception {
" \"[email protected]\": [" +
" \"READ\"," +
" \"WRITE\"" +
" ]" +
" ]," +
" \"emptyMember\": []" + // Will be removed
" }," +
" \"perTokenPermissions\": {" +
" \"goodman\": [" +
" \"READ\"" +
" ]" +
" ]," +
" \"emptyToken\": []" + // Will be removed
" }," +
" \"creation\": {" +
" \"user\": \"[email protected]\"," +
Expand Down
Loading