Skip to content
This repository was archived by the owner on Jul 6, 2023. It is now read-only.

Commit 235a6f7

Browse files
committed
Code Review: Add test that asserts we are asked for credentials
1 parent f1569ed commit 235a6f7

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

cypher-shell/src/integration-test/java/org/neo4j/shell/MainIntegrationTest.java

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,26 @@ public void wrongPortWithNeo4j() throws Exception
142142
main.connectMaybeInteractively( shell, connectionConfig, true, true );
143143
}
144144

145+
@Test
146+
public void shouldAskForCredentialsWhenConnectingWithAFile() throws Exception {
147+
//given
148+
149+
assertEquals("", connectionConfig.username());
150+
assertEquals("", connectionConfig.password());
151+
152+
//when
153+
CliArgs cliArgs = new CliArgs();
154+
cliArgs.setInputFilename(fileFromResource("single.cypher"));
155+
ShellAndConnection sac = getShell(cliArgs);
156+
CypherShell shell = sac.shell;
157+
ConnectionConfig connectionConfig = sac.connectionConfig;
158+
main.connectMaybeInteractively( shell, connectionConfig, true, true );
159+
160+
// then we should have prompted and set the username and password
161+
assertEquals("neo4j", connectionConfig.username());
162+
assertEquals("neo", connectionConfig.password());
163+
}
164+
145165
@Test
146166
public void shouldReadSingleCypherStatementsFromFile() throws Exception {
147167
assertEquals(format( "result%n42%n" ), executeFileNonInteractively(fileFromResource("single.cypher")));

0 commit comments

Comments
 (0)