[ 
https://issues.apache.org/jira/browse/METRON-639?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15770401#comment-15770401
 ] 

ASF GitHub Bot commented on METRON-639:
---------------------------------------

Github user ottobackwards commented on a diff in the pull request:

    https://github.com/apache/incubator-metron/pull/402#discussion_r93650018
  
    --- Diff: 
metron-platform/metron-common/src/test/java/org/apache/metron/common/stellar/network/NetworkFunctionsTest.java
 ---
    @@ -0,0 +1,164 @@
    +/**
    + * Licensed to the Apache Software Foundation (ASF) under one
    + * or more contributor license agreements.  See the NOTICE file
    + * distributed with this work for additional information
    + * regarding copyright ownership.  The ASF licenses this file
    + * to you under the Apache License, Version 2.0 (the
    + * "License"); you may not use this file except in compliance
    + * with the License.  You may obtain a copy of the License at
    + *
    + *     http://www.apache.org/licenses/LICENSE-2.0
    + *
    + * Unless required by applicable law or agreed to in writing, software
    + * distributed under the License is distributed on an "AS IS" BASIS,
    + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    + * See the License for the specific language governing permissions and
    + * limitations under the License.
    + */
    +package org.apache.metron.common.stellar.network;
    +
    +import com.google.common.collect.ImmutableMap;
    +import org.junit.Test;
    +
    +import java.util.HashMap;
    +
    +import static org.apache.metron.common.utils.StellarProcessorUtils.run;
    +import static org.junit.Assert.assertEquals;
    +import static org.junit.Assert.assertFalse;
    +import static org.junit.Assert.assertTrue;
    +
    +public class NetworkFunctionsTest {
    +
    +  @Test
    +  public void inSubnetTest_positive() {
    +    assertTrue((Boolean) run("IN_SUBNET(ip, cidr)"
    +                            , ImmutableMap.of("ip", "192.168.0.1", "cidr", 
"192.168.0.0/24")
    +            ));
    +  }
    +
    +  @Test
    +  public void inSubnetTest_negative() {
    +    assertFalse((Boolean) run("IN_SUBNET(ip, cidr)"
    +                             , ImmutableMap.of("ip", "192.168.1.1", 
"cidr", "192.168.0.0/24")
    +               ));
    +  }
    +
    +  @Test
    +  public void inSubnetTest_multiple() {
    +    assertTrue((Boolean) run("IN_SUBNET(ip, cidr1, cidr2)"
    +                            , ImmutableMap.of("ip", "192.168.1.1"
    +                                             , "cidr1", "192.168.0.0/24"
    +                                             , "cidr2", "192.168.1.0/24")
    +              ));
    +  }
    +
    +  private static void runSimple(String function, String argument, Object 
expected) {
    --- End diff --
    
    I think this should be in the StellarProcessorUtils


> The Network Stellar functions need to have better unit testing
> --------------------------------------------------------------
>
>                 Key: METRON-639
>                 URL: https://issues.apache.org/jira/browse/METRON-639
>             Project: Metron
>          Issue Type: Bug
>            Reporter: Casey Stella
>
> We have very little unit test coverage around the Networking functions in 
> Stellar at the edge level.  When diving a bit deeper on real data, I found a 
> number of bugs around:
> * Domains with TLDs that are not part of the proper set of TLDs
> * URIs with schemes that Java doesn't know about.
> * IN_SUBNET takes multiple CIDRs, but only evaluates the first one.
> Generally calling validate on these methods can be unsafe because they do not 
> handle null arguments correctly.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to