Skip to content

Commit 4bad425

Browse files
build: Add support for configuring the Neo4j username in tests, too.
1 parent 8e17484 commit 4bad425

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/test/java/org/springframework/data/neo4j/test/Neo4jExtension.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ public class Neo4jExtension implements BeforeAllCallback, BeforeEachCallback {
8383
private static final String KEY_DRIVER_INSTANCE = "neo4j.driver";
8484

8585
private static final String SYS_PROPERTY_NEO4J_URL = "SDN_NEO4J_URL";
86+
private static final String SYS_PROPERTY_NEO4J_USERNAME = "SDN_NEO4J_USERNAME";
8687
private static final String SYS_PROPERTY_NEO4J_PASSWORD = "SDN_NEO4J_PASSWORD";
8788
private static final String SYS_PROPERTY_NEO4J_ACCEPT_COMMERCIAL_EDITION = "SDN_NEO4J_ACCEPT_COMMERCIAL_EDITION";
8889
private static final String SYS_PROPERTY_NEO4J_REPOSITORY = "SDN_NEO4J_REPOSITORY";
@@ -107,6 +108,7 @@ public void beforeAll(ExtensionContext context) throws Exception {
107108
}
108109

109110
String neo4jUrl = Optional.ofNullable(System.getenv(SYS_PROPERTY_NEO4J_URL)).orElse("");
111+
String neo4jUser = Optional.ofNullable(System.getenv(SYS_PROPERTY_NEO4J_USERNAME)).orElse("neo4j").trim();
110112
String neo4jPassword = Optional.ofNullable(System.getenv(SYS_PROPERTY_NEO4J_PASSWORD)).orElse("").trim();
111113

112114
ExtensionContext.Store contextStore = context.getStore(NAMESPACE);
@@ -115,7 +117,7 @@ public void beforeAll(ExtensionContext context) throws Exception {
115117
if (neo4jConnectionSupport == null) {
116118
if (!(neo4jUrl.isEmpty() || neo4jPassword.isEmpty())) {
117119
log.info(LogMessage.format("Using Neo4j instance at %s.", neo4jUrl));
118-
neo4jConnectionSupport = new Neo4jConnectionSupport(neo4jUrl, AuthTokens.basic("neo4j", neo4jPassword));
120+
neo4jConnectionSupport = new Neo4jConnectionSupport(neo4jUrl, AuthTokens.basic(neo4jUser, neo4jPassword));
119121
} else {
120122
log.info("Using Neo4j test container.");
121123
ContainerAdapter adapter = contextStore.getOrComputeIfAbsent(KEY_NEO4J_INSTANCE,

0 commit comments

Comments
 (0)