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: replace '__' with '--' in the Sql EDR Store #538

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 @@ -46,7 +46,7 @@

public class SqlEndpointDataReferenceCache extends AbstractSqlStore implements EndpointDataReferenceCache {

public static final String SEPARATOR = "__";
public static final String SEPARATOR = "--";
public static final String VAULT_PREFIX = "edr" + SEPARATOR;
private final EdrStatements statements;
private final Clock clock;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import org.eclipse.tractusx.edc.edr.store.sql.schema.postgres.PostgresEdrStatements;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;

import java.io.IOException;
Expand All @@ -33,10 +34,15 @@
import java.sql.SQLException;
import java.time.Clock;

import static java.util.UUID.randomUUID;
import static org.eclipse.tractusx.edc.edr.spi.TestFunctions.edr;
import static org.eclipse.tractusx.edc.edr.spi.TestFunctions.edrEntry;
import static org.eclipse.tractusx.edc.edr.store.sql.SqlEndpointDataReferenceCache.SEPARATOR;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.anyString;
import static org.mockito.ArgumentMatchers.argThat;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;

@PostgresqlDbIntegrationTest
Expand Down Expand Up @@ -71,6 +77,20 @@ void tearDown(PostgresqlStoreSetupExtension extension) throws SQLException {
extension.runQuery("DROP TABLE " + statements.getEdrTable() + " CASCADE");
}

@Test
void verify_unoffensive_secretKey() {
var tpId = "tp1";
var assetId = "asset1";
var edrId = "edr1";

var edr = edr(edrId);
var entry = edrEntry(assetId, randomUUID().toString(), tpId);

getStore().save(entry, edr);

verify(vault).storeSecret(argThat(s -> s.startsWith("edr--")), anyString());
}

@Override
protected EndpointDataReferenceCache getStore() {
return cache;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,5 +126,5 @@ void deleteByTransferProcessId_shouldReturnError_whenNotFound() {
.extracting(StoreResult::reason)
.isEqualTo(StoreFailure.Reason.NOT_FOUND);
}

}