use of org.neo4j.bolt.testing.BoltResponseRecorder in project neo4j by neo4j.
the class BoltConnectionAuthIT method shouldBeAbleToActOnSessionWhenUpdatingCredentials.
@Test
public void shouldBeAbleToActOnSessionWhenUpdatingCredentials() throws Throwable {
BoltStateMachine machine = env.newMachine(CONNECTION_DESCRIPTOR);
BoltResponseRecorder recorder = new BoltResponseRecorder();
// when
machine.init(USER_AGENT, map("scheme", "basic", "principal", "neo4j", "credentials", "neo4j", "new_credentials", "secret"), recorder);
machine.run("CREATE ()", map(), recorder);
// then
assertThat(recorder.nextResponse(), succeeded());
assertThat(recorder.nextResponse(), succeeded());
}
use of org.neo4j.bolt.testing.BoltResponseRecorder in project neo4j by neo4j.
the class BoltConnectionAuthIT method shouldGiveCredentialsExpiredStatusOnExpiredCredentials.
@Test
public void shouldGiveCredentialsExpiredStatusOnExpiredCredentials() throws Throwable {
// Given it is important for client applications to programmatically
// identify expired credentials as the cause of not being authenticated
BoltStateMachine machine = env.newMachine(CONNECTION_DESCRIPTOR);
BoltResponseRecorder recorder = new BoltResponseRecorder();
// When
machine.init(USER_AGENT, map("scheme", "basic", "principal", "neo4j", "credentials", "neo4j"), recorder);
machine.run("CREATE ()", map(), recorder);
// Then
assertThat(recorder.nextResponse(), succeededWithMetadata("credentials_expired", true));
assertThat(recorder.nextResponse(), failedWithStatus(Status.Security.CredentialsExpired));
}
use of org.neo4j.bolt.testing.BoltResponseRecorder in project neo4j by neo4j.
the class BoltConnectionIT method shouldCloseConnectionResetBeforeInit.
@Test
public void shouldCloseConnectionResetBeforeInit() throws Throwable {
// Given
BoltStateMachine machine = env.newMachine(CONNECTION_DESCRIPTOR);
// when
BoltResponseRecorder recorder = new BoltResponseRecorder();
verifyKillsConnection(() -> machine.reset(recorder));
// then
assertThat(recorder.nextResponse(), failedWithStatus(Status.Request.Invalid));
}
use of org.neo4j.bolt.testing.BoltResponseRecorder in project neo4j by neo4j.
the class BoltConnectionIT method shouldAllowUserControlledRollbackOnExplicitTxFailure.
@Test
public void shouldAllowUserControlledRollbackOnExplicitTxFailure() throws Throwable {
// Given whenever en explicit transaction has a failure,
// it is more natural for drivers to see the failure, acknowledge it
// and send a `ROLLBACK`, because that means that all failures in the
// transaction, be they client-local or inside neo, can be handled the
// same way by a driver.
BoltStateMachine machine = env.newMachine(new BoltConnectionDescriptor(new InetSocketAddress("bolt-test", 56789), new InetSocketAddress("test-server", 7468)));
machine.init(USER_AGENT, emptyMap(), null);
machine.run("BEGIN", EMPTY_PARAMS, nullResponseHandler());
machine.discardAll(nullResponseHandler());
machine.run("CREATE (n:Victim)-[:REL]->()", EMPTY_PARAMS, nullResponseHandler());
machine.discardAll(nullResponseHandler());
// When I perform an action that will fail
BoltResponseRecorder recorder = new BoltResponseRecorder();
machine.run("this is not valid syntax", EMPTY_PARAMS, recorder);
// Then I should see a failure
assertThat(recorder.nextResponse(), failedWithStatus(Status.Statement.SyntaxError));
// And when I acknowledge that failure, and roll back the transaction
recorder.reset();
machine.ackFailure(recorder);
machine.run("ROLLBACK", EMPTY_PARAMS, recorder);
// Then both operations should succeed
assertThat(recorder.nextResponse(), succeeded());
assertThat(recorder.nextResponse(), succeeded());
}
use of org.neo4j.bolt.testing.BoltResponseRecorder in project neo4j by neo4j.
the class BoltConnectionIT method shouldExecuteStatement.
@Test
public void shouldExecuteStatement() throws Throwable {
// Given
BoltStateMachine machine = env.newMachine(CONNECTION_DESCRIPTOR);
machine.init(USER_AGENT, emptyMap(), null);
// When
BoltResponseRecorder recorder = new BoltResponseRecorder();
machine.run("CREATE (n {k:'k'}) RETURN n.k", EMPTY_PARAMS, recorder);
// Then
assertThat(recorder.nextResponse(), succeeded());
// When
recorder.reset();
machine.pullAll(recorder);
// Then
recorder.nextResponse().assertRecord(0, "k");
//assertThat( pulling.next(), streamContaining( StreamMatchers.eqRecord( equalTo( "k" ) ) ) );
}
Aggregations