@Test public void testUDPSessionNotConsidered() { Session session1 = mock(Session.class); Session session2 = mock(Session.class); InetAddress ipAddr = mock(InetAddress.class); when(ipAddr.getHostAddress()).thenReturn("157.56.19.80"); when(session1.isUdpOnly()).thenReturn(true); when(session2.getRemoteIP()).thenReturn(ipAddr); when(session2.getDomainName()).thenReturn("www.hotmail.com"); TCPPacket tcpPacket1 = mock(TCPPacket.class); TCPPacket tcpPacket2 = mock(TCPPacket.class); when(tcpPacket1.containsSSLRecord()).thenReturn(false); when(tcpPacket2.containsSSLRecord()).thenReturn(false); PacketInfo packetInfo_tcp1 = mock(PacketInfo.class); PacketInfo packetInfo_tcp2 = mock(PacketInfo.class); when(packetInfo_tcp1.getPayloadLen()).thenReturn(1); when(packetInfo_tcp1.getPacket()).thenReturn(tcpPacket1); when(packetInfo_tcp2.getPayloadLen()).thenReturn(1); when(packetInfo_tcp2.getPacket()).thenReturn(tcpPacket2); List<PacketInfo> packetsInfo = new ArrayList<PacketInfo>(); packetsInfo.add(packetInfo_tcp1); packetsInfo.add(packetInfo_tcp2); when(session2.getPackets()).thenReturn(packetsInfo); List<Session> sessions = new ArrayList<Session>(); sessions.add(session1); sessions.add(session2); pktAnalyzerResult.setSessionlist(sessions); httpsUsageResult = (HttpsUsageResult) httpsUsageImpl.runTest(pktAnalyzerResult); httpsUsageEntries = httpsUsageResult.getResults(); assertEquals(1, httpsUsageEntries.size()); }
@Override public AbstractBestPracticeResult runTest(PacketAnalyzerResult tracedata) { totalNumConnectionsCurrentTrace = 0; totalNumHttpConnectionsCurrentTrace = 0; List<Session> sessions = tracedata.getSessionlist(); Map<InetAddress, List<Session>> ipSessionsMap = buildIpSessionsMap(sessions); List<HttpsUsageEntry> httpsUsageEntries = buildHttpsUsageEntry(ipSessionsMap); int httpConnectionsPercentageCurrentTrace = getHttpConnectionsPercentage(totalNumHttpConnectionsCurrentTrace, totalNumConnectionsCurrentTrace); HttpsUsageResult result = new HttpsUsageResult(); String testResultText = ""; if (passTest()) { result.setResultType(BPResultType.PASS); testResultText = MessageFormat.format(testResultPassText, ApplicationConfig.getInstance().getAppShortName(), totalNumHttpConnectionsCurrentTrace); } else if (failTest(httpsUsageEntries, httpConnectionsPercentageCurrentTrace)) { result.setResultType(BPResultType.FAIL); testResultText = MessageFormat.format(testResultAnyText, ApplicationConfig.getInstance().getAppShortName(), totalNumHttpConnectionsCurrentTrace, httpConnectionsPercentageCurrentTrace); } else { result.setResultType(BPResultType.WARNING); testResultText = MessageFormat.format(testResultAnyText, ApplicationConfig.getInstance().getAppShortName(), totalNumHttpConnectionsCurrentTrace, httpConnectionsPercentageCurrentTrace); } result.setOverviewTitle(overviewTitle); result.setDetailTitle(detailedTitle); result.setLearnMoreUrl(learnMoreUrl); result.setAboutText(aboutText); result.setResults(httpsUsageEntries); result.setResultText(testResultText); result.setExportAll(exportAll); return result; }
HttpsUsageImpl implements IBestPractice { @Override public AbstractBestPracticeResult runTest(PacketAnalyzerResult tracedata) { totalNumConnectionsCurrentTrace = 0; totalNumHttpConnectionsCurrentTrace = 0; List<Session> sessions = tracedata.getSessionlist(); Map<InetAddress, List<Session>> ipSessionsMap = buildIpSessionsMap(sessions); List<HttpsUsageEntry> httpsUsageEntries = buildHttpsUsageEntry(ipSessionsMap); int httpConnectionsPercentageCurrentTrace = getHttpConnectionsPercentage(totalNumHttpConnectionsCurrentTrace, totalNumConnectionsCurrentTrace); HttpsUsageResult result = new HttpsUsageResult(); String testResultText = ""; if (passTest()) { result.setResultType(BPResultType.PASS); testResultText = MessageFormat.format(testResultPassText, ApplicationConfig.getInstance().getAppShortName(), totalNumHttpConnectionsCurrentTrace); } else if (failTest(httpsUsageEntries, httpConnectionsPercentageCurrentTrace)) { result.setResultType(BPResultType.FAIL); testResultText = MessageFormat.format(testResultAnyText, ApplicationConfig.getInstance().getAppShortName(), totalNumHttpConnectionsCurrentTrace, httpConnectionsPercentageCurrentTrace); } else { result.setResultType(BPResultType.WARNING); testResultText = MessageFormat.format(testResultAnyText, ApplicationConfig.getInstance().getAppShortName(), totalNumHttpConnectionsCurrentTrace, httpConnectionsPercentageCurrentTrace); } result.setOverviewTitle(overviewTitle); result.setDetailTitle(detailedTitle); result.setLearnMoreUrl(learnMoreUrl); result.setAboutText(aboutText); result.setResults(httpsUsageEntries); result.setResultText(testResultText); result.setExportAll(exportAll); return result; } }
HttpsUsageImpl implements IBestPractice { @Override public AbstractBestPracticeResult runTest(PacketAnalyzerResult tracedata) { totalNumConnectionsCurrentTrace = 0; totalNumHttpConnectionsCurrentTrace = 0; List<Session> sessions = tracedata.getSessionlist(); Map<InetAddress, List<Session>> ipSessionsMap = buildIpSessionsMap(sessions); List<HttpsUsageEntry> httpsUsageEntries = buildHttpsUsageEntry(ipSessionsMap); int httpConnectionsPercentageCurrentTrace = getHttpConnectionsPercentage(totalNumHttpConnectionsCurrentTrace, totalNumConnectionsCurrentTrace); HttpsUsageResult result = new HttpsUsageResult(); String testResultText = ""; if (passTest()) { result.setResultType(BPResultType.PASS); testResultText = MessageFormat.format(testResultPassText, ApplicationConfig.getInstance().getAppShortName(), totalNumHttpConnectionsCurrentTrace); } else if (failTest(httpsUsageEntries, httpConnectionsPercentageCurrentTrace)) { result.setResultType(BPResultType.FAIL); testResultText = MessageFormat.format(testResultAnyText, ApplicationConfig.getInstance().getAppShortName(), totalNumHttpConnectionsCurrentTrace, httpConnectionsPercentageCurrentTrace); } else { result.setResultType(BPResultType.WARNING); testResultText = MessageFormat.format(testResultAnyText, ApplicationConfig.getInstance().getAppShortName(), totalNumHttpConnectionsCurrentTrace, httpConnectionsPercentageCurrentTrace); } result.setOverviewTitle(overviewTitle); result.setDetailTitle(detailedTitle); result.setLearnMoreUrl(learnMoreUrl); result.setAboutText(aboutText); result.setResults(httpsUsageEntries); result.setResultText(testResultText); result.setExportAll(exportAll); return result; }  }
HttpsUsageImpl implements IBestPractice { @Override public AbstractBestPracticeResult runTest(PacketAnalyzerResult tracedata) { totalNumConnectionsCurrentTrace = 0; totalNumHttpConnectionsCurrentTrace = 0; List<Session> sessions = tracedata.getSessionlist(); Map<InetAddress, List<Session>> ipSessionsMap = buildIpSessionsMap(sessions); List<HttpsUsageEntry> httpsUsageEntries = buildHttpsUsageEntry(ipSessionsMap); int httpConnectionsPercentageCurrentTrace = getHttpConnectionsPercentage(totalNumHttpConnectionsCurrentTrace, totalNumConnectionsCurrentTrace); HttpsUsageResult result = new HttpsUsageResult(); String testResultText = ""; if (passTest()) { result.setResultType(BPResultType.PASS); testResultText = MessageFormat.format(testResultPassText, ApplicationConfig.getInstance().getAppShortName(), totalNumHttpConnectionsCurrentTrace); } else if (failTest(httpsUsageEntries, httpConnectionsPercentageCurrentTrace)) { result.setResultType(BPResultType.FAIL); testResultText = MessageFormat.format(testResultAnyText, ApplicationConfig.getInstance().getAppShortName(), totalNumHttpConnectionsCurrentTrace, httpConnectionsPercentageCurrentTrace); } else { result.setResultType(BPResultType.WARNING); testResultText = MessageFormat.format(testResultAnyText, ApplicationConfig.getInstance().getAppShortName(), totalNumHttpConnectionsCurrentTrace, httpConnectionsPercentageCurrentTrace); } result.setOverviewTitle(overviewTitle); result.setDetailTitle(detailedTitle); result.setLearnMoreUrl(learnMoreUrl); result.setAboutText(aboutText); result.setResults(httpsUsageEntries); result.setResultText(testResultText); result.setExportAll(exportAll); return result; }  @Override AbstractBestPracticeResult runTest(PacketAnalyzerResult tracedata); }
HttpsUsageImpl implements IBestPractice { @Override public AbstractBestPracticeResult runTest(PacketAnalyzerResult tracedata) { totalNumConnectionsCurrentTrace = 0; totalNumHttpConnectionsCurrentTrace = 0; List<Session> sessions = tracedata.getSessionlist(); Map<InetAddress, List<Session>> ipSessionsMap = buildIpSessionsMap(sessions); List<HttpsUsageEntry> httpsUsageEntries = buildHttpsUsageEntry(ipSessionsMap); int httpConnectionsPercentageCurrentTrace = getHttpConnectionsPercentage(totalNumHttpConnectionsCurrentTrace, totalNumConnectionsCurrentTrace); HttpsUsageResult result = new HttpsUsageResult(); String testResultText = ""; if (passTest()) { result.setResultType(BPResultType.PASS); testResultText = MessageFormat.format(testResultPassText, ApplicationConfig.getInstance().getAppShortName(), totalNumHttpConnectionsCurrentTrace); } else if (failTest(httpsUsageEntries, httpConnectionsPercentageCurrentTrace)) { result.setResultType(BPResultType.FAIL); testResultText = MessageFormat.format(testResultAnyText, ApplicationConfig.getInstance().getAppShortName(), totalNumHttpConnectionsCurrentTrace, httpConnectionsPercentageCurrentTrace); } else { result.setResultType(BPResultType.WARNING); testResultText = MessageFormat.format(testResultAnyText, ApplicationConfig.getInstance().getAppShortName(), totalNumHttpConnectionsCurrentTrace, httpConnectionsPercentageCurrentTrace); } result.setOverviewTitle(overviewTitle); result.setDetailTitle(detailedTitle); result.setLearnMoreUrl(learnMoreUrl); result.setAboutText(aboutText); result.setResults(httpsUsageEntries); result.setResultText(testResultText); result.setExportAll(exportAll); return result; }  @Override AbstractBestPracticeResult runTest(PacketAnalyzerResult tracedata);  }