Search in sources :

Example 6 with SearchingContent

use of com.att.aro.core.searching.pojo.SearchingContent in project VideoOptimzer by attdevsupport.

the class PatternSearchingHandlerTest method testResultNotFound.

@Test
public void testResultNotFound() {
    SearchingPatternBuilder pattenBuilder = new SearchingPatternBuilder();
    pattenBuilder.add("\\d{3}[-\\.\\s]\\d{3}[-\\.\\s]\\d{4},-,3,8,-,7,4", PrivateDataType.regex_phone_number.name());
    String text = "https://www.google.com/login/username=fakeName&password=1234&id=423456-7865";
    SearchingContent content = new SearchingContent(text);
    SearchingResult result = searchingHandler.search(pattenBuilder.build(), content);
    assertNotNull(result);
    assertEquals(0, result.getWords().size());
}
Also used : SearchingResult(com.att.aro.core.searching.pojo.SearchingResult) SearchingContent(com.att.aro.core.searching.pojo.SearchingContent) SearchingPatternBuilder(com.att.aro.core.searching.pojo.SearchingPatternBuilder) Test(org.junit.Test) BaseTest(com.att.aro.core.BaseTest)

Example 7 with SearchingContent

use of com.att.aro.core.searching.pojo.SearchingContent in project VideoOptimzer by attdevsupport.

the class TransmissionPrivateDataImpl method getContent.

/**
 * get content string from given session
 * @param session
 * @return
 */
private SearchingContent getContent(Session session) {
    String str = "";
    ByteArrayOutputStream data = new ByteArrayOutputStream();
    BufferedOutputStream dataWrapper = new BufferedOutputStream(data);
    try {
        for (HttpRequestResponseInfo rrInfo : session.getRequestResponseInfo()) {
            if (rrInfo.getDirection() == HttpDirection.REQUEST) {
                dataWrapper.write(rrInfo.getPayloadData().toByteArray());
            }
        }
        dataWrapper.flush();
    } catch (IOException e) {
        LOGGER.error("Error extracting content from Session: " + session.getSessionKey());
    }
    str = Util.byteArrayToString(data.toByteArray());
    return new SearchingContent(str);
}
Also used : HttpRequestResponseInfo(com.att.aro.core.packetanalysis.pojo.HttpRequestResponseInfo) SearchingContent(com.att.aro.core.searching.pojo.SearchingContent) ByteArrayOutputStream(java.io.ByteArrayOutputStream) IOException(java.io.IOException) BufferedOutputStream(java.io.BufferedOutputStream)

Example 8 with SearchingContent

use of com.att.aro.core.searching.pojo.SearchingContent in project VideoOptimzer by attdevsupport.

the class PatternSearchingHandlerTest method testResultFound.

@Test
public void testResultFound() {
    SearchingPatternBuilder pattenBuilder = new SearchingPatternBuilder();
    pattenBuilder.add("\\d{3}[-\\.\\s]\\d{3}[-\\.\\s]\\d{4},-,3,8,-,7,4", PrivateDataType.regex_phone_number.name());
    String text = "https://www.google.com/login/username=fakeName&password=1234&phone=443-237-7431";
    SearchingContent content = new SearchingContent(text);
    SearchingResult result = searchingHandler.search(pattenBuilder.build(), content);
    assertNotNull(result);
    assertEquals(1, result.getWords().size());
    assertEquals("443-237-7431", result.getWords().get(0));
}
Also used : SearchingResult(com.att.aro.core.searching.pojo.SearchingResult) SearchingContent(com.att.aro.core.searching.pojo.SearchingContent) SearchingPatternBuilder(com.att.aro.core.searching.pojo.SearchingPatternBuilder) Test(org.junit.Test) BaseTest(com.att.aro.core.BaseTest)

Example 9 with SearchingContent

use of com.att.aro.core.searching.pojo.SearchingContent in project VideoOptimzer by attdevsupport.

the class SearchingStrategyTest method testSinglePatternMatchFound.

@Test
public void testSinglePatternMatchFound() {
    SearchingContent content = new SearchingContent("abcabeabd");
    SearchingPatternBuilder patternBuilder = new SearchingPatternBuilder();
    patternBuilder.add("abe", PrivateDataType.regex_credit_card_number.name());
    SearchingResult result = searchStrategy.applySearch(patternBuilder.build(), content);
    assertNotNull(result);
    assertEquals(1, result.getWords().size());
    assertEquals("abe", result.getWords().get(0));
}
Also used : SearchingResult(com.att.aro.core.searching.pojo.SearchingResult) SearchingContent(com.att.aro.core.searching.pojo.SearchingContent) SearchingPatternBuilder(com.att.aro.core.searching.pojo.SearchingPatternBuilder) Test(org.junit.Test) BaseTest(com.att.aro.core.BaseTest)

Example 10 with SearchingContent

use of com.att.aro.core.searching.pojo.SearchingContent in project VideoOptimzer by attdevsupport.

the class SearchingStrategyTest method testEmptyContent.

@Test
public void testEmptyContent() {
    SearchingContent content = new SearchingContent("");
    SearchingPatternBuilder patternBuilder = new SearchingPatternBuilder();
    patternBuilder.add("abc", PrivateDataType.regex_credit_card_number.name());
    SearchingResult result = searchStrategy.applySearch(patternBuilder.build(), content);
    assertNotNull(result);
    assertEquals(0, result.getWords().size());
}
Also used : SearchingResult(com.att.aro.core.searching.pojo.SearchingResult) SearchingContent(com.att.aro.core.searching.pojo.SearchingContent) SearchingPatternBuilder(com.att.aro.core.searching.pojo.SearchingPatternBuilder) Test(org.junit.Test) BaseTest(com.att.aro.core.BaseTest)

Aggregations

SearchingContent (com.att.aro.core.searching.pojo.SearchingContent)15 SearchingResult (com.att.aro.core.searching.pojo.SearchingResult)14 BaseTest (com.att.aro.core.BaseTest)13 Test (org.junit.Test)13 SearchingPatternBuilder (com.att.aro.core.searching.pojo.SearchingPatternBuilder)11 SearchingPattern (com.att.aro.core.searching.pojo.SearchingPattern)3 TransmissionPrivateDataEntry (com.att.aro.core.bestpractice.pojo.TransmissionPrivateDataEntry)1 HttpRequestResponseInfo (com.att.aro.core.packetanalysis.pojo.HttpRequestResponseInfo)1 Session (com.att.aro.core.packetanalysis.pojo.Session)1 BufferedOutputStream (java.io.BufferedOutputStream)1 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1 IOException (java.io.IOException)1 LinkedList (java.util.LinkedList)1