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

Commit ae4b9db

Browse files
committed
Feedback and test fix.
1 parent 333c3a2 commit ae4b9db

File tree

3 files changed

+17
-8
lines changed

3 files changed

+17
-8
lines changed

cypher-shell/src/integration-test/java/org/neo4j/shell/commands/CypherShellProtocolIntegrationTest.java

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
import static org.junit.Assume.assumeTrue;
1515
import static org.neo4j.shell.DatabaseManager.ABSENT_DB_NAME;
1616
import static org.neo4j.shell.util.Versions.majorVersion;
17+
import static org.neo4j.shell.util.Versions.minorVersion;
1718

1819
public class CypherShellProtocolIntegrationTest{
1920

@@ -35,28 +36,29 @@ public void shouldConnectWithNeo4jProtocol() throws Exception {
3536
@Test
3637
public void shouldConnectWithBoltSSCProtocol() throws Exception {
3738
CypherShell shell = new CypherShell( new StringLinePrinter(), new PrettyConfig( Format.PLAIN, true, 1000), false, new ShellParameterMap());
38-
// Given 3.X series, where SSC are the default. Hard to test in 4.0 sadly.
39-
onlyIn3x(shell);
39+
// Given 3.X series where X > 1, where SSC are the default. Hard to test in 4.0 sadly.
40+
onlyIn3_2to3_6( shell);
4041
shell.connect( new ConnectionConfig( "bolt+ssc://", "localhost", 7687, "neo4j", "neo", Encryption.DEFAULT, ABSENT_DB_NAME ) );
4142
assertTrue(shell.isConnected());
4243
}
4344

4445
@Test
4546
public void shouldConnectWithNeo4jSSCProtocol() throws Exception {
4647
CypherShell shell = new CypherShell( new StringLinePrinter(), new PrettyConfig( Format.PLAIN, true, 1000), false, new ShellParameterMap());
47-
// Given 3.X series, where SSC are the default. Hard to test in 4.0 sadly.
48-
onlyIn3x(shell);
48+
// Given 3.X series where X > 1, where SSC are the default. Hard to test in 4.0 sadly.
49+
onlyIn3_2to3_6( shell);
4950
// This should work by falling back to bolt+ssc
5051
shell.connect( new ConnectionConfig( "neo4j+ssc://", "localhost", 7687, "neo4j", "neo", Encryption.DEFAULT, ABSENT_DB_NAME ) );
5152
assertTrue(shell.isConnected());
5253
}
5354

5455
// Here should be tests for "neo4j+s" and "bolt+s", but we don't have the infrastructure for those.
5556

56-
private void onlyIn3x(CypherShell shell) throws Exception {
57+
private void onlyIn3_2to3_6( CypherShell shell) throws Exception {
5758
// Default connection settings
5859
shell.connect( new ConnectionConfig( "bolt://", "localhost", 7687, "neo4j", "neo", Encryption.DEFAULT, ABSENT_DB_NAME ) );
59-
assumeTrue( majorVersion( shell.getServerVersion() ) < 4 );
60+
assumeTrue( majorVersion( shell.getServerVersion() ) == 3 );
61+
assumeTrue( minorVersion( shell.getServerVersion() ) > 1 );
6062
shell.disconnect();
6163
}
6264
}

cypher-shell/src/main/java/org/neo4j/shell/cli/CliArgHelper.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -162,8 +162,8 @@ private static ArgumentParser setupParser(ParameterMap parameterMap)
162162
.help("password to connect with. Can also be specified using environment variable " + ConnectionConfig.PASSWORD_ENV_VAR);
163163
connGroup.addArgument("--encryption")
164164
.help("whether the connection to Neo4j should be encrypted. This must be consistent with Neo4j's " +
165-
"configuration. If choosing " + Encryption.DEFAULT.name().toLowerCase() +
166-
" the encryption setting is deduced from the specified address. " +
165+
"configuration. If choosing '" + Encryption.DEFAULT.name().toLowerCase() +
166+
"' the encryption setting is deduced from the specified address. " +
167167
"For example the 'neo4j+ssc' protocol would use encryption.")
168168
.choices(new CollectionArgumentChoice<>(
169169
Encryption.TRUE.name().toLowerCase(),

cypher-shell/src/test/java/org/neo4j/shell/cli/CliArgHelperTest.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,13 @@ public void allowsEncryptionToBeTurnedOnOrOff() {
195195
assertEquals(Encryption.FALSE, CliArgHelper.parse("--encryption", "false").getEncryption());
196196
}
197197

198+
@Test
199+
public void shouldNotAcceptInvalidEncryption() throws Exception {
200+
thrown.expect( ArgumentParserException.class );
201+
thrown.expectMessage( containsString("argument --encryption: invalid choice: 'bugaluga' (choose from {true,false,default})"));
202+
CliArgHelper.parseAndThrow("--encryption", "bugaluga");
203+
}
204+
198205
@Test
199206
public void shouldParseSingleIntegerArgWithAddition() {
200207
CliArgs cliArgs = CliArgHelper.parse( "-P", "foo=>3+5" );

0 commit comments

Comments
 (0)