package com.github.ambry.network;

import javax.net.ssl.SSLContext;
import javax.net.ssl.SSLEngine;
import javax.net.ssl.SSLServerSocketFactory;
import javax.net.ssl.SSLSocketFactory;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;

import static org.junit.Assert.fail;


public class SSLFactoryTest {

  @Before
  public void setup()
      throws Exception {
  }

  @After
  public void teardown()
      throws Exception {
  }

  @Test
  public void testSSLFactory() {
    try {
      SSLFactory sslFactory = TestUtils.createSSLFactory();
      SSLContext sslContext = sslFactory.createSSLContext();
      SSLSocketFactory socketFactory = sslContext.getSocketFactory();
      SSLServerSocketFactory serverSocketFactory = sslContext.getServerSocketFactory();
      SSLEngine engine = sslFactory.createSSLEngine(sslContext, "localhost", 9095, true);
      System.out.println(socketFactory.toString());
      System.out.println(serverSocketFactory.toString());
      System.out.println(engine.toString());
    } catch (Exception e) {
      fail("Unexpected error in SSLFactory testing");
      e.printStackTrace();
    }
  }
}

@@ -201,16 +201,41 @@
 .After;%0A
+import org.junit.Assert;%0A
 import o
@@ -890,16 +890,653 @@
 , true);
+%0A%0A      Assert.assertEquals(sslContext.getProtocol(), %22TLS%22);%0A      String%5B%5D enabledCipherSuites = engine.getEnabledCipherSuites();%0A      Assert.assertEquals(enabledCipherSuites.length, 1);%0A      Assert.assertEquals(enabledCipherSuites%5B0%5D, %22TLS_RSA_WITH_AES_128_CBC_SHA256%22);%0A      String%5B%5D enabledProtocols = engine.getEnabledProtocols();%0A      Assert.assertEquals(enabledProtocols.length, 1);%0A      Assert.assertEquals(enabledProtocols%5B0%5D, %22TLSv1.2%22);%0A      Assert.assertEquals(engine.getNeedClientAuth(), false);%0A      Assert.assertEquals(engine.getUseClientMode(), true);%0A      Assert.assertEquals(engine.getWantClientAuth(), false);
 %0A      S

add more asserts in SSLFactoryTest