Skip to content

Commit

Permalink
chore: Decouple oauth2-spi from data-address-http-data-spi (#3584)
Browse files Browse the repository at this point in the history
Decouple the oauth2-spi from data-address-http-data-spi
  • Loading branch information
jimmarino authored Oct 31, 2023
1 parent dbc079b commit 5dcd530
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 13 deletions.
1 change: 0 additions & 1 deletion spi/common/oauth2-spi/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ plugins {
}

dependencies {
api(project(":spi:common:data-address:data-address-http-data-spi"))
api(project(":spi:common:jwt-spi"))
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
*/
public class Oauth2DataAddressValidator implements Predicate<DataAddress> {

private final Predicate<DataAddress> isHttpDataType = dataAddress -> "HttpData".equals(dataAddress.getType());
private final Predicate<DataAddress> hasClientId = dataAddress -> dataAddress.hasProperty(CLIENT_ID);
private final Predicate<DataAddress> hasClientSecretKey = dataAddress -> dataAddress.hasProperty(CLIENT_SECRET_KEY);
private final Predicate<DataAddress> hasPrivateKeySecretName = dataAddress -> dataAddress.hasProperty(PRIVATE_KEY_NAME);
Expand All @@ -37,11 +36,7 @@ public class Oauth2DataAddressValidator implements Predicate<DataAddress> {

@Override
public boolean test(DataAddress dataAddress) {
return isHttpDataType
.and(hasClientId)
.and(hasTokenUrl)
.and(hasSecretInfo)
.test(dataAddress);
return hasClientId.and(hasTokenUrl).and(hasSecretInfo).test(dataAddress);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@

package org.eclipse.edc.iam.oauth2.spi;

import org.eclipse.edc.dataaddress.httpdata.spi.HttpDataAddressSchema;
import org.eclipse.edc.spi.types.domain.DataAddress;
import org.junit.jupiter.api.extension.ExtensionContext;
import org.junit.jupiter.params.ParameterizedTest;
Expand Down Expand Up @@ -43,33 +42,33 @@ public static final class DataAddressProvider implements ArgumentsProvider {
@Override
public Stream<? extends Arguments> provideArguments(ExtensionContext context) {
var addressWithPrivateKeyName = DataAddress.Builder.newInstance()
.type(HttpDataAddressSchema.HTTP_DATA_TYPE)
.type("TestType")
.property(Oauth2DataAddressSchema.CLIENT_ID, "aClientId")
.property(Oauth2DataAddressSchema.PRIVATE_KEY_NAME, "aPrivateKeyName")
.property(Oauth2DataAddressSchema.TOKEN_URL, "aTokenUrl")
.build();

var addressWithSharedSecret = DataAddress.Builder.newInstance()
.type(HttpDataAddressSchema.HTTP_DATA_TYPE)
.type("TestType")
.property(Oauth2DataAddressSchema.CLIENT_ID, "aClientId")
.property(Oauth2DataAddressSchema.CLIENT_SECRET_KEY, "aSecret")
.property(Oauth2DataAddressSchema.TOKEN_URL, "aTokenUrl")
.build();

var missingTokenUrl = DataAddress.Builder.newInstance()
.type(HttpDataAddressSchema.HTTP_DATA_TYPE)
.type("TestType")
.property(Oauth2DataAddressSchema.CLIENT_ID, "aClientId")
.property(Oauth2DataAddressSchema.CLIENT_SECRET_KEY, "aSecret")
.build();

var missingClientId = DataAddress.Builder.newInstance()
.type(HttpDataAddressSchema.HTTP_DATA_TYPE)
.type("TestType")
.property(Oauth2DataAddressSchema.CLIENT_SECRET_KEY, "secret-key")
.property(Oauth2DataAddressSchema.TOKEN_URL, "aTokenUrl")
.build();

var missingPrivateKeyOrSharedSecret = DataAddress.Builder.newInstance()
.type(HttpDataAddressSchema.HTTP_DATA_TYPE)
.type("TestType")
.property(Oauth2DataAddressSchema.CLIENT_ID, "aClientId")
.property(Oauth2DataAddressSchema.TOKEN_URL, "aTokenUrl")
.build();
Expand Down

0 comments on commit 5dcd530

Please sign in to comment.