Skip to content

Commit

Permalink
fix: replace '__' with '--' in the Sql EDR Store (eclipse-tractusx#538)
Browse files Browse the repository at this point in the history
  • Loading branch information
paullatzelsperger authored Jun 27, 2023
1 parent 09d8448 commit 14d9e59
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 2 deletions.
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);
}

}

0 comments on commit 14d9e59

Please sign in to comment.