Search in sources :

Example 1 with MESSAGE_DIGEST_SHA1

use of org.apache.qpid.server.protocol.v0_10.ServerConnectionDelegate.MESSAGE_DIGEST_SHA1 in project qpid-broker-j by apache.

the class ServerConnectionDelegateTest method sessionAttachWhenNameExceedsSizeLimit.

@Test
public void sessionAttachWhenNameExceedsSizeLimit() throws Exception {
    final String name = Stream.generate(() -> String.valueOf('a')).limit(BASE64_LIMIT + 1).collect(Collectors.joining());
    ;
    final SessionAttach attach = createSessionAttach(name);
    _delegate.sessionAttach(_serverConnection, attach);
    final ArgumentCaptor<ServerSession> sessionCaptor = ArgumentCaptor.forClass(ServerSession.class);
    verify(_serverConnection).registerSession(sessionCaptor.capture());
    final ServerSession serverSession = sessionCaptor.getValue();
    final Session session = serverSession.getModelObject();
    final String digest = Base64.getEncoder().encodeToString(MessageDigest.getInstance(MESSAGE_DIGEST_SHA1).digest(name.getBytes(UTF_8)));
    assertThat(session.getPeerSessionName(), CoreMatchers.is(equalTo(digest)));
}
Also used : SessionAttach(org.apache.qpid.server.protocol.v0_10.transport.SessionAttach) Test(org.junit.Test)

Aggregations

SessionAttach (org.apache.qpid.server.protocol.v0_10.transport.SessionAttach)1 Test (org.junit.Test)1