File tree Expand file tree Collapse file tree
main/java/com/predic8/membrane/core/interceptor/apikey/stores/inConfig
test/java/com/predic8/membrane/core/interceptor/apikey/stores/inConfig Expand file tree Collapse file tree Original file line number Diff line number Diff line change 2626@ MCElement (name = "secret" , component = false )
2727public class Key {
2828
29- private final List <Scope > scopes = new ArrayList <>();
29+ private final List <String > scopes = new ArrayList <>();
3030
3131 private String value ;
3232
3333 /**
34- * @description <scope>...</scope> elements for defining scopes for this key.
34+ * @description Scopes for this key.
3535 */
3636 @ MCChildElement (allowForeign = true )
37- public void setScopes (List <Scope > scopes ) {
37+ public void setScopes (List <String > scopes ) {
3838 this .scopes .addAll (scopes );
3939 }
4040
41- public List <Scope > getScopes () {
41+ public List <String > getScopes () {
4242 return scopes ;
4343 }
4444
Load Diff This file was deleted.
Original file line number Diff line number Diff line change @@ -45,9 +45,7 @@ public List<Key> getKeys() {
4545 public Optional <Set <String >> getScopes (String apiKey ) throws UnauthorizedApiKeyException {
4646 var key = keys .stream ().filter (k -> k .getValue ().equals (apiKey )).findFirst ();
4747 if (key .isPresent ()) {
48- Set <String > scopeValues = key .get ().getScopes ().stream ()
49- .map (Scope ::getValue )
50- .collect (toSet ());
48+ Set <String > scopeValues = new HashSet <>(key .get ().getScopes ());
5149 return ofNullable (scopeValues .isEmpty () ? null : scopeValues );
5250 } else {
5351 throw new UnauthorizedApiKeyException ();
Original file line number Diff line number Diff line change @@ -32,10 +32,7 @@ void getScopes() throws UnauthorizedApiKeyException {
3232 new Key (){{setValue ("12345" );}},
3333 new Key (){{
3434 setValue ("67890" );
35- setScopes (of (
36- new Scope (){{setValue ("admin" );}},
37- new Scope (){{setValue ("user" );}})
38- );
35+ setScopes (of ("admin" , "user" ));
3936 }})
4037 );
4138 assertEquals (empty (), simpleKeyStore .getScopes ("12345" ));
You can’t perform that action at this time.
0 commit comments