use of org.neo4j.pushtocloud.PushToCloudCommand.Copier in project neo4j by neo4j.
the class PushToCloudCommandTest method shouldAcceptPasswordViaEnvAndPromptForUsername.
@Test
public void shouldAcceptPasswordViaEnvAndPromptForUsername() throws Exception {
// given
Copier targetCommunicator = mockedTargetCommunicator();
String username = "neo4j";
PushToCloudCommand command = command().copier(targetCommunicator).console(PushToCloudConsole.fakeConsole(username, "tomte")).build();
Path dump = this.dump;
// when
String[] args = { "--dump", dump.toString(), "--bolt-uri", SOME_EXAMPLE_BOLT_URI };
var environment = Map.of("NEO4J_USERNAME", "", "NEO4J_PASSWORD", "pass");
new CommandLine(command).setResourceBundle(new MapResourceBundle(environment)).execute(args);
verify(targetCommunicator).authenticate(anyBoolean(), anyString(), eq("neo4j"), eq("pass".toCharArray()), anyBoolean());
}
use of org.neo4j.pushtocloud.PushToCloudCommand.Copier in project neo4j by neo4j.
the class PushToCloudCommandTest method shouldAcceptDumpAsSource.
@Test
void shouldAcceptDumpAsSource() throws Exception {
// given
Copier targetCommunicator = mockedTargetCommunicator();
PushToCloudCommand command = command().copier(targetCommunicator).build();
// when
PushToCloudCommand.Uploader uploader = command.makeDumpUploader(this.dump);
String[] args = { "--dump", dump.toString(), "--bolt-uri", SOME_EXAMPLE_BOLT_URI };
new CommandLine(command).execute(args);
// then
verify(targetCommunicator).checkSize(anyBoolean(), any(), anyLong(), any());
verify(targetCommunicator).copy(anyBoolean(), any(), any(), eq(uploader.source), eq(false), any());
}
use of org.neo4j.pushtocloud.PushToCloudCommand.Copier in project neo4j by neo4j.
the class PushToCloudCommandTest method shouldUseNeo4jAsDefaultUsernameIfUserHitsEnter.
@Test
public void shouldUseNeo4jAsDefaultUsernameIfUserHitsEnter() throws Exception {
// given
Copier targetCommunicator = mockedTargetCommunicator();
PushToCloudConsole console = mock(PushToCloudConsole.class);
when(console.readLine(anyString(), anyString())).thenReturn("");
String defaultUsername = "neo4j";
String password = "super-secret-password";
PushToCloudCommand command = command().copier(targetCommunicator).console(console).build();
// when
String[] args = { "--dump", dump.toString(), "--bolt-uri", SOME_EXAMPLE_BOLT_URI, "--password", password.toString() };
new CommandLine(command).execute(args);
// then
verify(console).readLine("%s", format("Neo4j aura username (default: %s):", defaultUsername));
verify(targetCommunicator).authenticate(anyBoolean(), any(), eq(defaultUsername), eq(password.toCharArray()), anyBoolean());
verify(targetCommunicator).copy(anyBoolean(), any(), any(), any(), eq(false), any());
}
Aggregations