private void WriteInit(InitMessage message) { try { Packer.packStructHeader(2, InitMessage.SIGNATURE); Packer.pack(message.UserAgent()); Packer.pack(ValueUtils.asMapValue(message.AuthToken())); } catch (IOException e) { throw new UncheckedIOException(e); } }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldCloseConnectionAfterAuthenticationFailure() throws Throwable //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void ShouldCloseConnectionAfterAuthenticationFailure() { // Given BoltStateMachine machine = Env.newMachine(_boltChannel); // When... then InitMessage init = new InitMessage(USER_AGENT, newBasicAuthToken("neo4j", "j4oen")); BoltResponseRecorder recorder = new BoltResponseRecorder(); verifyKillsConnection(() => machine.process(init, recorder)); // ...and assertThat(recorder.NextResponse(), failedWithStatus(Org.Neo4j.Kernel.Api.Exceptions.Status_Security.Unauthorized)); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldBeAbleToActOnSessionWhenUpdatingCredentials() throws Throwable //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void ShouldBeAbleToActOnSessionWhenUpdatingCredentials() { BoltStateMachine machine = Env.newMachine(_boltChannel); BoltResponseRecorder recorder = new BoltResponseRecorder(); // when InitMessage message = new InitMessage(USER_AGENT, map("scheme", "basic", "principal", "neo4j", "credentials", UTF8.encode("neo4j"), "new_credentials", UTF8.encode("secret"))); machine.Process(message, recorder); machine.Process(new RunMessage("CREATE ()", EMPTY_MAP), recorder); // then assertThat(recorder.NextResponse(), succeeded()); assertThat(recorder.NextResponse(), succeeded()); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldGiveKernelVersionOnInit() throws Throwable //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void ShouldGiveKernelVersionOnInit() { // Given it is important for client applications to programmatically // identify expired credentials as the cause of not being authenticated BoltStateMachine machine = Env.newMachine(_boltChannel); BoltResponseRecorder recorder = new BoltResponseRecorder(); string version = "Neo4j/" + Version.Neo4jVersion; // When InitMessage init = new InitMessage(USER_AGENT, newBasicAuthToken("neo4j", "neo4j")); machine.Process(init, recorder); machine.Process(new RunMessage("CREATE ()", EMPTY_MAP), recorder); // Then assertThat(recorder.NextResponse(), succeededWithMetadata("server", stringValue(version))); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldGiveCredentialsExpiredStatusOnExpiredCredentials() throws Throwable //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void ShouldGiveCredentialsExpiredStatusOnExpiredCredentials() { // Given it is important for client applications to programmatically // identify expired credentials as the cause of not being authenticated BoltStateMachine machine = Env.newMachine(_boltChannel); BoltResponseRecorder recorder = new BoltResponseRecorder(); // When InitMessage init = new InitMessage(USER_AGENT, newBasicAuthToken("neo4j", "neo4j")); machine.Process(init, recorder); machine.Process(new RunMessage("CREATE ()", EMPTY_MAP), recorder); // Then assertThat(recorder.NextResponse(), succeededWithMetadata("credentials_expired", TRUE)); assertThat(recorder.NextResponse(), failedWithStatus(Org.Neo4j.Kernel.Api.Exceptions.Status_Security.CredentialsExpired)); }