Search in sources :

Example 46 with Session

use of com.att.aro.core.packetanalysis.pojo.Session in project VideoOptimzer by attdevsupport.

the class TransmissionPrivateDataTest method getPacketAnalyzerResult.

private PacketAnalyzerResult getPacketAnalyzerResult(Map<String, String> keywords, String text) {
    Session session = mock(Session.class);
    InetAddress address = mock(InetAddress.class);
    String ipAddress = "127.0.0.1";
    when(address.getHostAddress()).thenReturn(ipAddress);
    int port = 8080;
    byte[] storage = text.getBytes();
    when(session.getStorageUl()).thenReturn(storage);
    when(session.getRemoteIP()).thenReturn(address);
    when(session.getRemotePort()).thenReturn(port);
    List<Session> sessions = new ArrayList<>();
    sessions.add(session);
    packetAnalyzerResult.setSessionlist(sessions);
    packetAnalyzerResult.setDeviceKeywords(keywords);
    return packetAnalyzerResult;
}
Also used : ArrayList(java.util.ArrayList) InetAddress(java.net.InetAddress) Session(com.att.aro.core.packetanalysis.pojo.Session)

Example 47 with Session

use of com.att.aro.core.packetanalysis.pojo.Session in project VideoOptimzer by attdevsupport.

the class FileCompressionImplTest method runTest_2.

/**
 * tests for PASS
 */
@Test
public void runTest_2() {
    tracedata = mock(PacketAnalyzerResult.class);
    session = mock(Session.class);
    sessionlist = new ArrayList<Session>();
    sessionlist.add(session);
    req = mock(HttpRequestResponseInfo.class);
    req.setDirection(HttpDirection.REQUEST);
    List<HttpRequestResponseInfo> reqList = new ArrayList<HttpRequestResponseInfo>();
    reqList.add(req);
    Mockito.when(session.getRequestResponseInfo()).thenReturn(reqList);
    Mockito.when(session.getDomainName()).thenReturn("mock.domain.name");
    Mockito.when(tracedata.getSessionlist()).thenReturn(sessionlist);
    // HttpDirection.REQUEST
    Mockito.when(req.getDirection()).thenReturn(HttpDirection.REQUEST);
    Mockito.when(req.getObjName()).thenReturn("mock.obj.name");
    // condition 1
    Mockito.when(req.getPacketDirection()).thenReturn(PacketDirection.DOWNLINK);
    // condition 2
    Mockito.when(req.getContentLength()).thenReturn(1);
    // condition 3 & 4
    // "application/ecmascript" "application/json" "application/javascript" "text/javascript" "message/http"
    Mockito.when(req.getContentType()).thenReturn("application/.something.xml");
    Mockito.when(req.getContentEncoding()).thenReturn("identity");
    FileCompressionImpl = (FileCompressionImpl) context.getBean("textFileCompression");
    AbstractBestPracticeResult result = FileCompressionImpl.runTest(tracedata);
    assertEquals("Sending compressed files over the network will speed delivery, and unzipping files on a device is a very low overhead operation. Ensure that all your text files are compressed while being sent over the network.", result.getAboutText());
    assertEquals("FILE_COMPRESSION", result.getBestPracticeType().toString());
    assertEquals("Text File Compression", result.getDetailTitle());
    assertEquals("File Download: Text File Compression", result.getOverviewTitle());
    assertEquals(ApplicationConfig.getInstance().getAppShortName() + " detected 0 text files above 850 bytes were sent without compression. Adding compression will speed the delivery of your content to your customers. (Note: Only files larger than 850 bytes are flagged.)", result.getResultText());
    assertEquals("PASS", result.getResultType().toString());
}
Also used : HttpRequestResponseInfo(com.att.aro.core.packetanalysis.pojo.HttpRequestResponseInfo) ArrayList(java.util.ArrayList) AbstractBestPracticeResult(com.att.aro.core.bestpractice.pojo.AbstractBestPracticeResult) PacketAnalyzerResult(com.att.aro.core.packetanalysis.pojo.PacketAnalyzerResult) Session(com.att.aro.core.packetanalysis.pojo.Session) Test(org.junit.Test) BaseTest(com.att.aro.core.BaseTest)

Example 48 with Session

use of com.att.aro.core.packetanalysis.pojo.Session in project VideoOptimzer by attdevsupport.

the class FileCompressionImplTest method runTest_3.

/**
 * tests for WARNING
 */
@Test
public void runTest_3() {
    tracedata = mock(PacketAnalyzerResult.class);
    session = mock(Session.class);
    sessionlist = new ArrayList<Session>();
    sessionlist.add(session);
    req = mock(HttpRequestResponseInfo.class);
    req.setDirection(HttpDirection.REQUEST);
    List<HttpRequestResponseInfo> reqList = new ArrayList<HttpRequestResponseInfo>();
    reqList.add(req);
    Mockito.when(session.getRequestResponseInfo()).thenReturn(reqList);
    Mockito.when(session.getDomainName()).thenReturn("mock.domain.name");
    Mockito.when(tracedata.getSessionlist()).thenReturn(sessionlist);
    // HttpDirection.REQUEST
    Mockito.when(req.getDirection()).thenReturn(HttpDirection.REQUEST);
    Mockito.when(req.getObjName()).thenReturn("mock.obj.name");
    // condition 1
    Mockito.when(req.getPacketDirection()).thenReturn(PacketDirection.DOWNLINK);
    // condition 2
    Mockito.when(req.getContentLength()).thenReturn(900);
    // condition 3 & 4
    // "application/ecmascript" "application/json" "application/javascript" "text/javascript" "message/http"
    Mockito.when(req.getContentType()).thenReturn("application/.something.xml");
    Mockito.when(req.getContentEncoding()).thenReturn("identity");
    FileCompressionImpl = (FileCompressionImpl) context.getBean("textFileCompression");
    AbstractBestPracticeResult result = FileCompressionImpl.runTest(tracedata);
    assertEquals("Sending compressed files over the network will speed delivery, and unzipping files on a device is a very low overhead operation. Ensure that all your text files are compressed while being sent over the network.", result.getAboutText());
    assertEquals("FILE_COMPRESSION", result.getBestPracticeType().toString());
    assertEquals("Text File Compression", result.getDetailTitle());
    assertEquals("File Download: Text File Compression", result.getOverviewTitle());
    assertEquals(ApplicationConfig.getInstance().getAppShortName() + " detected 100% (0KB of 0KB) of text files were sent without compression. Adding compression will speed the delivery of your content to your customers. (Note: Only files larger than 850 bytes are flagged.)", result.getResultText());
    assertEquals("WARNING", result.getResultType().toString());
}
Also used : HttpRequestResponseInfo(com.att.aro.core.packetanalysis.pojo.HttpRequestResponseInfo) ArrayList(java.util.ArrayList) AbstractBestPracticeResult(com.att.aro.core.bestpractice.pojo.AbstractBestPracticeResult) PacketAnalyzerResult(com.att.aro.core.packetanalysis.pojo.PacketAnalyzerResult) Session(com.att.aro.core.packetanalysis.pojo.Session) Test(org.junit.Test) BaseTest(com.att.aro.core.BaseTest)

Example 49 with Session

use of com.att.aro.core.packetanalysis.pojo.Session in project VideoOptimzer by attdevsupport.

the class ForwardSecrecyImplTest method getPacketAnalyzerResult.

private PacketAnalyzerResult getPacketAnalyzerResult(String cipherSuite) {
    Session session = mock(Session.class);
    PacketInfo info = mock(PacketInfo.class);
    TCPPacket tcpPacket = mock(TCPPacket.class);
    InetAddress address = mock(InetAddress.class);
    String ipAddress = "127.0.0.1";
    int port = 8080;
    List<Session> sessions = new ArrayList<>();
    sessions.add(session);
    List<PacketInfo> packetInfos = new LinkedList<>();
    packetInfos.add(info);
    packetAnalyzerResult.setSessionlist(sessions);
    when(session.getTcpPackets()).thenReturn(packetInfos);
    when(info.getPacket()).thenReturn(tcpPacket);
    when(tcpPacket.getSelectedCipherSuite()).thenReturn(cipherSuite);
    when(address.getHostAddress()).thenReturn(ipAddress);
    when(session.getRemoteIP()).thenReturn(address);
    when(session.getRemotePort()).thenReturn(port);
    return packetAnalyzerResult;
}
Also used : TCPPacket(com.att.aro.core.packetreader.pojo.TCPPacket) ArrayList(java.util.ArrayList) PacketInfo(com.att.aro.core.packetanalysis.pojo.PacketInfo) InetAddress(java.net.InetAddress) LinkedList(java.util.LinkedList) Session(com.att.aro.core.packetanalysis.pojo.Session)

Example 50 with Session

use of com.att.aro.core.packetanalysis.pojo.Session in project VideoOptimzer by attdevsupport.

the class Http3xxCodeImplTest method runTest_resTypeIsPass.

@Test
public void runTest_resTypeIsPass() {
    Mockito.when(httpRequestInfo01.getDirection()).thenReturn(HttpDirection.RESPONSE);
    Mockito.when(httpRequestInfo01.getScheme()).thenReturn(HttpRequestResponseInfo.HTTP_SCHEME);
    Mockito.when(httpRequestInfo01.getStatusCode()).thenReturn(200);
    Mockito.when(httpRequestInfo02.getDirection()).thenReturn(HttpDirection.REQUEST);
    List<HttpRequestResponseInfo> value = new ArrayList<HttpRequestResponseInfo>();
    value.add(httpRequestInfo01);
    value.add(httpRequestInfo02);
    Mockito.when(session01.getRequestResponseInfo()).thenReturn(value);
    Mockito.when(session01.getDomainName()).thenReturn("www.google.com");
    List<Session> sessionList = new ArrayList<Session>();
    sessionList.add(session01);
    Mockito.when(tracedata.getSessionlist()).thenReturn(sessionList);
    http3xxCodeImpl = (Http3xxCodeImpl) context.getBean("http3xx");
    AbstractBestPracticeResult result = http3xxCodeImpl.runTest(tracedata);
    assertEquals(BPResultType.PASS, result.getResultType());
}
Also used : HttpRequestResponseInfo(com.att.aro.core.packetanalysis.pojo.HttpRequestResponseInfo) ArrayList(java.util.ArrayList) AbstractBestPracticeResult(com.att.aro.core.bestpractice.pojo.AbstractBestPracticeResult) Session(com.att.aro.core.packetanalysis.pojo.Session) Test(org.junit.Test) BaseTest(com.att.aro.core.BaseTest)

Aggregations

Session (com.att.aro.core.packetanalysis.pojo.Session)130 ArrayList (java.util.ArrayList)86 HttpRequestResponseInfo (com.att.aro.core.packetanalysis.pojo.HttpRequestResponseInfo)74 BaseTest (com.att.aro.core.BaseTest)49 Test (org.junit.Test)49 PacketInfo (com.att.aro.core.packetanalysis.pojo.PacketInfo)32 AbstractBestPracticeResult (com.att.aro.core.bestpractice.pojo.AbstractBestPracticeResult)31 InetAddress (java.net.InetAddress)26 HashMap (java.util.HashMap)19 TCPPacket (com.att.aro.core.packetreader.pojo.TCPPacket)17 HashSet (java.util.HashSet)11 TreeMap (java.util.TreeMap)11 List (java.util.List)10 Statistic (com.att.aro.core.packetanalysis.pojo.Statistic)9 File (java.io.File)9 TraceDirectoryResult (com.att.aro.core.packetanalysis.pojo.TraceDirectoryResult)8 DomainNameSystem (com.att.aro.core.packetreader.pojo.DomainNameSystem)8 BurstCollectionAnalysisData (com.att.aro.core.packetanalysis.pojo.BurstCollectionAnalysisData)7 HttpRequestResponseInfoWithSession (com.att.aro.core.packetanalysis.pojo.HttpRequestResponseInfoWithSession)7 UDPPacket (com.att.aro.core.packetreader.pojo.UDPPacket)7