WorkflowConfigurationFactory { private WorkflowTrace createHelloWorkflow() { return createHelloWorkflow(getConnection()); } WorkflowConfigurationFactory(Config config); WorkflowTrace createWorkflowTrace(WorkflowTraceType type, RunningModeType mode); WorkflowTrace createTlsEntryWorkflowtrace(AliasedConnection connection); WorkflowTrace createHelloWorkflow(AliasedConnection connection); boolean shouldServerSendACertificate(CipherSuite suite); ClientKeyExchangeMessage createClientKeyExchangeMessage(KeyExchangeAlgorithm algorithm); ServerKeyExchangeMessage createServerKeyExchangeMessage(KeyExchangeAlgorithm algorithm); void addClientKeyExchangeMessage(List<ProtocolMessage> messages); void addServerKeyExchangeMessage(List<ProtocolMessage> messages); WorkflowTrace addStartTlsActions(AliasedConnection connection, StarttlsType type, WorkflowTrace workflowTrace);  }
@Test public void testCreateHelloWorkflow() { WorkflowTrace helloWorkflow; MessageAction firstAction; MessageAction messageAction1; MessageAction messageAction2; ReceiveAction lastAction; ClientHelloMessage clientHelloMessage; WorkflowConfigurationFactory factory = new WorkflowConfigurationFactory(config); helloWorkflow = factory.createWorkflowTrace(WorkflowTraceType.HELLO, RunningModeType.CLIENT); Assert.assertThat(helloWorkflow.getMessageActions().size(), Matchers.greaterThanOrEqualTo(2)); firstAction = helloWorkflow.getMessageActions().get(0); Assert.assertEquals(ReceiveAction.class, helloWorkflow.getLastMessageAction().getClass()); lastAction = (ReceiveAction) helloWorkflow.getLastMessageAction(); Assert.assertEquals(1, firstAction.getMessages().size()); Assert.assertThat(lastAction.getExpectedMessages().size(), Matchers.greaterThanOrEqualTo(1)); Assert.assertEquals(firstAction.getMessages().get(0).getClass(), de.rub.nds.tlsattacker.core.protocol.message.ClientHelloMessage.class); Assert.assertEquals(lastAction.getExpectedMessages().get(0).getClass(), de.rub.nds.tlsattacker.core.protocol.message.ServerHelloMessage.class); config.setHighestProtocolVersion(ProtocolVersion.DTLS10); config.setClientAuthentication(false); workflowConfigurationFactory = new WorkflowConfigurationFactory(config); helloWorkflow = workflowConfigurationFactory.createWorkflowTrace(WorkflowTraceType.HELLO, RunningModeType.CLIENT); firstAction = helloWorkflow.getMessageActions().get(0); clientHelloMessage = (ClientHelloMessage) firstAction.getMessages().get(0); Assert.assertThat(helloWorkflow.getMessageActions().size(), Matchers.greaterThanOrEqualTo(4)); Assert.assertNotNull(helloWorkflow.getMessageActions().get(1)); Assert.assertNotNull(helloWorkflow.getMessageActions().get(2)); messageAction1 = helloWorkflow.getMessageActions().get(1); messageAction2 = helloWorkflow.getMessageActions().get(2); Assert.assertEquals(ReceiveAction.class, messageAction1.getClass()); Assert.assertEquals(HelloVerifyRequestMessage.class, ((ReceiveAction) messageAction1).getExpectedMessages() .get(0).getClass()); Assert.assertEquals(ClientHelloMessage.class, messageAction2.getMessages().get(0).getClass()); lastAction = (ReceiveAction) helloWorkflow.getLastMessageAction(); Assert.assertEquals(lastAction.getExpectedMessages().get(1).getClass(), de.rub.nds.tlsattacker.core.protocol.message.CertificateMessage.class); config.setHighestProtocolVersion(ProtocolVersion.DTLS10); config.setClientAuthentication(true); config.setDefaultSelectedCipherSuite(CipherSuite.TLS_DHE_DSS_WITH_AES_256_GCM_SHA384); workflowConfigurationFactory = new WorkflowConfigurationFactory(config); helloWorkflow = workflowConfigurationFactory.createWorkflowTrace(WorkflowTraceType.HELLO, RunningModeType.CLIENT); lastAction = (ReceiveAction) helloWorkflow.getLastMessageAction(); Assert.assertNotNull(lastAction.getExpectedMessages().get(2)); Assert.assertEquals(lastAction.getExpectedMessages().get(3).getClass(), de.rub.nds.tlsattacker.core.protocol.message.CertificateRequestMessage.class); }