@Test public void connectShouldReturnTrueWhenConnecting() throws Exception { server = createServer(createProtocol(Optional.empty()), Encryption.createStartTls(BogusSslContextFactory.getServerContext())); smtpsClient = createClient(); server.bind(); InetSocketAddress bindedAddress = new ProtocolServerUtils(server).retrieveBindedAddress(); smtpsClient.connect(bindedAddress.getAddress().getHostAddress(), bindedAddress.getPort()); assertThat(SMTPReply.isPositiveCompletion(smtpsClient.getReplyCode())).isTrue(); }
@Test public void connectShouldReturnTrueWhenConnecting() throws Exception { server = createServer(createProtocol(Optional.empty()), Encryption.createStartTls(BogusSslContextFactory.getServerContext())); smtpsClient = createClient(); server.bind(); InetSocketAddress bindedAddress = new ProtocolServerUtils(server).retrieveBindedAddress(); smtpsClient.connect(bindedAddress.getAddress().getHostAddress(), bindedAddress.getPort()); assertThat(SMTPReply.isPositiveCompletion(smtpsClient.getReplyCode())).isTrue(); }
@Test public void startTlsShouldFailWhenFollowedByInjectedCommand() throws Exception { server = createServer(createProtocol(Optional.empty()), Encryption.createStartTls(BogusSslContextFactory.getServerContext())); smtpsClient = createClient(); server.bind(); InetSocketAddress bindedAddress = new ProtocolServerUtils(server).retrieveBindedAddress(); smtpsClient.connect(bindedAddress.getAddress().getHostAddress(), bindedAddress.getPort()); smtpsClient.sendCommand("EHLO localhost"); smtpsClient.sendCommand("STARTTLS\r\nRSET\r\n"); assertThat(SMTPReply.isPositiveCompletion(smtpsClient.getReplyCode())).isFalse(); }
@Test public void ehloShouldReturnTrueWhenSendingTheCommand() throws Exception { server = createServer(createProtocol(Optional.empty()), Encryption.createStartTls(BogusSslContextFactory.getServerContext())); smtpsClient = createClient(); server.bind(); InetSocketAddress bindedAddress = new ProtocolServerUtils(server).retrieveBindedAddress(); smtpsClient.connect(bindedAddress.getAddress().getHostAddress(), bindedAddress.getPort()); smtpsClient.sendCommand("EHLO localhost"); assertThat(SMTPReply.isPositiveCompletion(smtpsClient.getReplyCode())).isTrue(); }
@Test public void startTlsShouldFailWhenFollowedByInjectedCommandAndNotAtBeginningOfLine() throws Exception { server = createServer(createProtocol(Optional.empty()), Encryption.createStartTls(BogusSslContextFactory.getServerContext())); smtpsClient = createClient(); server.bind(); InetSocketAddress bindedAddress = new ProtocolServerUtils(server).retrieveBindedAddress(); smtpsClient.connect(bindedAddress.getAddress().getHostAddress(), bindedAddress.getPort()); smtpsClient.sendCommand("EHLO localhost"); smtpsClient.sendCommand("RSET\r\nSTARTTLS\r\nRSET\r\n"); assertThat(SMTPReply.isPositiveCompletion(smtpsClient.getReplyCode())).isFalse(); }
@Test public void ehloShouldReturnTrueWhenSendingTheCommand() throws Exception { server = createServer(createProtocol(Optional.empty()), Encryption.createStartTls(BogusSslContextFactory.getServerContext())); smtpsClient = createClient(); server.bind(); InetSocketAddress bindedAddress = new ProtocolServerUtils(server).retrieveBindedAddress(); smtpsClient.connect(bindedAddress.getAddress().getHostAddress(), bindedAddress.getPort()); smtpsClient.sendCommand("EHLO localhost"); assertThat(SMTPReply.isPositiveCompletion(smtpsClient.getReplyCode())).isTrue(); }
@Test public void startTlsShouldFailWhenFollowedByInjectedCommandAndNotAtBeginningOfLine() throws Exception { server = createServer(createProtocol(Optional.empty()), Encryption.createStartTls(BogusSslContextFactory.getServerContext())); smtpsClient = createClient(); server.bind(); InetSocketAddress bindedAddress = new ProtocolServerUtils(server).retrieveBindedAddress(); smtpsClient.connect(bindedAddress.getAddress().getHostAddress(), bindedAddress.getPort()); smtpsClient.sendCommand("EHLO localhost"); smtpsClient.sendCommand("RSET\r\nSTARTTLS\r\nRSET\r\n"); assertThat(SMTPReply.isPositiveCompletion(smtpsClient.getReplyCode())).isFalse(); }
@Test public void startTlsShouldFailWhenFollowedByInjectedCommand() throws Exception { server = createServer(createProtocol(Optional.empty()), Encryption.createStartTls(BogusSslContextFactory.getServerContext())); smtpsClient = createClient(); server.bind(); InetSocketAddress bindedAddress = new ProtocolServerUtils(server).retrieveBindedAddress(); smtpsClient.connect(bindedAddress.getAddress().getHostAddress(), bindedAddress.getPort()); smtpsClient.sendCommand("EHLO localhost"); smtpsClient.sendCommand("STARTTLS\r\nRSET\r\n"); assertThat(SMTPReply.isPositiveCompletion(smtpsClient.getReplyCode())).isFalse(); }