Skip to content

Commit

Permalink
update test settings
Browse files Browse the repository at this point in the history
  • Loading branch information
paullatzelsperger committed May 14, 2024
1 parent 52acfb2 commit 78a076e
Show file tree
Hide file tree
Showing 8 changed files with 26 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@
import org.eclipse.edc.spi.system.ServiceExtensionContext;
import org.eclipse.tractusx.edc.core.utils.PathUtils;

import static org.eclipse.tractusx.edc.core.utils.ConfigUtil.propertyCompatibility;
import static java.util.Optional.ofNullable;
import static org.eclipse.tractusx.edc.core.utils.ConfigUtil.missingMandatoryProperty;

/**
* Configuration Extension for the STS OAuth2 client
Expand All @@ -35,19 +36,13 @@
public class DimStsConfigurationExtension implements ServiceExtension {

@Setting(value = "STS OAuth2 endpoint for requesting a token")
public static final String TOKEN_URL = "tx.edc.iam.sts.oauth.token.url";
@Deprecated(since = "0.7.1")
public static final String TOKEN_URL_DEPRECATED = "edc.iam.sts.oauth.token.url";
public static final String TOKEN_URL = "edc.iam.sts.oauth.token.url";

@Setting(value = "STS OAuth2 client id")
public static final String CLIENT_ID = "tx.edc.iam.sts.oauth.client.id";
@Deprecated(since = "0.7.1")
public static final String CLIENT_ID_DEPRECATED = "edc.iam.sts.oauth.client.id";
public static final String CLIENT_ID = "edc.iam.sts.oauth.client.id";

@Setting(value = "Vault alias of STS OAuth2 client secret")
public static final String CLIENT_SECRET_ALIAS = "tx.edc.iam.sts.oauth.client.secret.alias";
@Deprecated(since = "0.7.1")
public static final String CLIENT_SECRET_ALIAS_DEPRECATED = "edc.iam.sts.oauth.client.secret.alias";
public static final String CLIENT_SECRET_ALIAS = "edc.iam.sts.oauth.client.secret.alias";

protected static final String NAME = "DIM STS client configuration extension";

Expand All @@ -60,12 +55,21 @@ public String name() {
@Provider
public StsRemoteClientConfiguration clientConfiguration(ServiceExtensionContext context) {

var tokenUrl = PathUtils.removeTrailingSlash(propertyCompatibility(context, TOKEN_URL, TOKEN_URL_DEPRECATED));
var clientId = propertyCompatibility(context, CLIENT_ID, CLIENT_ID_DEPRECATED);
var clientSecretAlias = propertyCompatibility(context, CLIENT_SECRET_ALIAS, CLIENT_SECRET_ALIAS_DEPRECATED);
var tokenUrl = ofNullable(context.getConfig().getString(TOKEN_URL, null))
.map(PathUtils::removeTrailingSlash).orElse(null);
var clientId = context.getConfig().getString(CLIENT_ID, null);
var clientSecretAlias = context.getConfig().getString(CLIENT_SECRET_ALIAS, null);

var monitor = context.getMonitor().withPrefix("STS Client for DIM");

if (tokenUrl == null) {
missingMandatoryProperty(monitor, TOKEN_URL);
}
if (clientId == null) {
missingMandatoryProperty(monitor, CLIENT_ID);
}
if (clientSecretAlias == null) {
missingMandatoryProperty(monitor, CLIENT_SECRET_ALIAS);
}
return new StsRemoteClientConfiguration(tokenUrl, clientId, clientSecretAlias);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public class DimParticipant extends TractusxIatpParticipantBase {
public Map<String, String> iatpConfiguration(TractusxIatpParticipantBase... others) {
var config = new HashMap<>(super.iatpConfiguration(others));
config.put("edc.iam.sts.dim.url", dimUri.toString());
config.put("tx.iam.iatp.bdrs.server.url", bdrsUri.toString());
config.put("tx.edc.iam.iatp.bdrs.server.url", bdrsUri.toString());
config.put("edc.transfer.proxy.token.verifier.publickey.alias", getKeyId());
return config;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public Map<String, String> iatpConfiguration(TractusxIatpParticipantBase... othe
};

Stream.concat(Stream.of(this), Arrays.stream(others)).forEach(p -> {
var prefix = "tx.iam.iatp.audiences.%s".formatted(p.getName().toLowerCase());
var prefix = "tx.edc.iam.iatp.audiences.%s".formatted(p.getName().toLowerCase());
iatpConfiguration.put("%s.from".formatted(prefix), p.getBpn());
iatpConfiguration.put("%s.to".formatted(prefix), p.getDid());
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ public Map<String, String> getConfiguration() {
put("edc.iam.sts.oauth.client.id", "test-clientid");
put("edc.iam.sts.oauth.client.secret.alias", "test-clientid-alias");
put("edc.iam.sts.dim.url", "http://sts.example.com");
put("tx.iam.iatp.bdrs.server.url", "http://sts.example.com");
put("tx.edc.iam.iatp.bdrs.server.url", "http://sts.example.com");
put("edc.dataplane.api.public.baseurl", "http://localhost:%d/api/public/v2/data".formatted(dataPlanePublic.getPort()));
}
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public static Map<String, String> baseConfig(String controlPath, int controlPort
put("edc.iam.sts.oauth.client.id", "test-clientid");
put("edc.iam.sts.oauth.client.secret.alias", "test-clientid-alias");
put("edc.iam.sts.dim.url", "http://sts.example.com");
put("tx.iam.iatp.bdrs.server.url", "http://sts.example.com");
put("tx.edc.iam.iatp.bdrs.server.url", "http://sts.example.com");
}
};
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public Map<String, String> baseConfig() {
put("edc.iam.sts.oauth.client.id", "test-clientid");
put("edc.iam.sts.oauth.client.secret.alias", "test-clientid-alias");
put("edc.iam.sts.dim.url", "http://sts.example.com");
put("tx.iam.iatp.bdrs.server.url", "http://sts.example.com");
put("tx.edc.iam.iatp.bdrs.server.url", "http://sts.example.com");
}
};
}
Expand Down
2 changes: 1 addition & 1 deletion samples/edc-dast/edc-dast-runtime/configuration.properties
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,5 @@ web.http.default.path=/api
web.http.sts.port=8990
web.http.sts.path=/v1/sts
edc.api.auth.key=password
tx.iam.iatp.bdrs.server.url=http://localhost:8081
tx.edc.iam.iatp.bdrs.server.url=http://localhost:8081
tx.vault.seed.secrets=client_secret_alias:secret
5 changes: 2 additions & 3 deletions samples/multi-tenancy/src/test/resources/tenants.properties
Original file line number Diff line number Diff line change
Expand Up @@ -16,18 +16,17 @@
#
# SPDX-License-Identifier: Apache-2.0
#################################################################################

edc.tenants.one.edc.any=any
edc.tenants.one.web.http.port=18181
edc.tenants.one.web.http.path=/api
edc.tenants.one.web.http.protocol.port=18282
edc.tenants.one.web.http.protocol.path=/protocol
edc.tenants.one.tx.iam.iatp.bdrs.server.url=http://bdrs.test.com
edc.tenants.one.tx.edc.iam.iatp.bdrs.server.url=http://bdrs.test.com
edc.tenants.one.edc.iam.issuer.id=did:web:tenant1
edc.tenants.two.edc.any=any
edc.tenants.two.web.http.port=28181
edc.tenants.two.web.http.path=/api
edc.tenants.two.web.http.protocol.port=28282
edc.tenants.two.web.http.protocol.path=/protocol
edc.tenants.two.tx.iam.iatp.bdrs.server.url=http://bdrs.test.com
edc.tenants.two.tx.edc.iam.iatp.bdrs.server.url=http://bdrs.test.com
edc.tenants.two.edc.iam.issuer.id=did:web:tenant2

0 comments on commit 78a076e

Please sign in to comment.