use of org.neo4j.shell.ConnectionConfig in project neo4j by neo4j.
the class CypherShellMultiDatabaseIntegrationTest method switchingToNonExistingDatabaseShouldGiveErrorResponseFromServerInteractive.
@Test
public void switchingToNonExistingDatabaseShouldGiveErrorResponseFromServerInteractive() throws CommandException {
shell = new CypherShell(linePrinter, new PrettyConfig(Format.PLAIN, true, 1000), true, new ShellParameterMap());
useCommand = new Use(shell);
shell.connect(new ConnectionConfig("bolt", "localhost", 7687, "neo4j", "neo", Encryption.DEFAULT, ABSENT_DB_NAME));
useCommand.execute(SYSTEM_DB_NAME);
try {
useCommand.execute("this_database_name_does_not_exist_in_test_container");
fail("No ClientException thrown");
} catch (ClientException e) {
// In interactive we do not want to switch if the database does not exist
assertOnSystemDB();
}
}
use of org.neo4j.shell.ConnectionConfig in project neo4j by neo4j.
the class CypherShellProtocolIntegrationTest method shouldConnectWithBoltSSCProtocol.
@Test
public void shouldConnectWithBoltSSCProtocol() throws Exception {
CypherShell shell = new CypherShell(new StringLinePrinter(), new PrettyConfig(Format.PLAIN, true, 1000), false, new ShellParameterMap());
// Given 3.X series where X > 1, where SSC are the default. Hard to test in 4.0 sadly.
onlyIn3_2to3_6(shell);
shell.connect(new ConnectionConfig("bolt+ssc", "localhost", 7687, "neo4j", "neo", Encryption.DEFAULT, ABSENT_DB_NAME));
assertTrue(shell.isConnected());
}
use of org.neo4j.shell.ConnectionConfig in project neo4j by neo4j.
the class CypherShellProtocolIntegrationTest method shouldConnectWithNeo4jSSCProtocol.
@Test
public void shouldConnectWithNeo4jSSCProtocol() throws Exception {
CypherShell shell = new CypherShell(new StringLinePrinter(), new PrettyConfig(Format.PLAIN, true, 1000), false, new ShellParameterMap());
// Given 3.X series where X > 1, where SSC are the default. Hard to test in 4.0 sadly.
onlyIn3_2to3_6(shell);
// This should work by falling back to bolt+ssc
shell.connect(new ConnectionConfig("neo4j+ssc", "localhost", 7687, "neo4j", "neo", Encryption.DEFAULT, ABSENT_DB_NAME));
assertTrue(shell.isConnected());
}
use of org.neo4j.shell.ConnectionConfig in project neo4j by neo4j.
the class CypherShellProtocolIntegrationTest method onlyIn3_2to3_6.
// Here should be tests for "neo4j+s" and "bolt+s", but we don't have the infrastructure for those.
private void onlyIn3_2to3_6(CypherShell shell) throws Exception {
// Default connection settings
shell.connect(new ConnectionConfig("bolt", "localhost", 7687, "neo4j", "neo", Encryption.DEFAULT, ABSENT_DB_NAME));
assumeTrue(majorVersion(shell.getServerVersion()) == 3);
assumeTrue(minorVersion(shell.getServerVersion()) > 1);
shell.disconnect();
}
use of org.neo4j.shell.ConnectionConfig in project neo4j by neo4j.
the class BoltStateHandlerTest method shouldChangePasswordAndKeepSystemDbBookmark.
@Test
public void shouldChangePasswordAndKeepSystemDbBookmark() throws CommandException {
// Given
ConnectionConfig config = new ConnectionConfig("bolt", "", -1, "", "", Encryption.DEFAULT, ABSENT_DB_NAME);
config.setNewPassword("newPW");
Bookmark bookmark = InternalBookmark.parse("myBookmark");
Session sessionMock = mock(Session.class);
Result resultMock = mock(Result.class);
Driver driverMock = stubResultSummaryInAnOpenSession(resultMock, sessionMock, "Neo4j/9.4.1-ALPHA", "my_default_db");
when(sessionMock.run("CALL dbms.security.changePassword($n)", Values.parameters("n", config.newPassword()))).thenReturn(resultMock);
when(sessionMock.lastBookmark()).thenReturn(bookmark);
BoltStateHandler handler = new OfflineBoltStateHandler(driverMock);
// When
handler.changePassword(config);
// Then
assertEquals("newPW", config.password());
assertNull(config.newPassword());
assertNull(handler.session);
// When connecting to system db again
handler.connect(new ConnectionConfig("bolt", "", -1, "", "", Encryption.DEFAULT, SYSTEM_DB_NAME));
// Then use bookmark for system DB
verify(driverMock).session(SessionConfig.builder().withDefaultAccessMode(AccessMode.WRITE).withDatabase(SYSTEM_DB_NAME).withBookmarks(bookmark).build());
}
Aggregations