Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add workflows for managing ServiceGroup services.
Change-Id: I978f64b431ba7d7c6b7e8fabd6b6d950ac8b3180 Partial-Bug: #1772594
- Loading branch information
1 parent
dfc37d6
commit 020779b
Showing
40 changed files
with
762 additions
and
175 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
75 changes: 75 additions & 0 deletions
75
...ests/src/test/groovy/net/juniper/contrail/vro/tests/actions/NetworkPolicyRulesSpec.groovy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
/* | ||
* Copyright (c) 2018 Juniper Networks, Inc. All rights reserved. | ||
*/ | ||
|
||
package net.juniper.contrail.vro.tests.actions | ||
|
||
import net.juniper.contrail.api.types.ActionListType | ||
import net.juniper.contrail.api.types.AddressType | ||
import net.juniper.contrail.api.types.NetworkPolicy | ||
import net.juniper.contrail.api.types.PolicyEntriesType | ||
import net.juniper.contrail.api.types.PolicyRuleType | ||
import net.juniper.contrail.api.types.PortType | ||
|
||
import static net.juniper.contrail.vro.config.Actions.networkPolicyRules | ||
import static net.juniper.contrail.vro.model.UtilsKt.utils | ||
|
||
class NetworkPolicyRulesSpec extends ActionSpec { | ||
def action = actionFromScript(networkPolicyRules) | ||
|
||
def "null network policy results in empty list" () { | ||
given: "null network policy" | ||
def policy = null | ||
|
||
when: "retrieved list of rules" | ||
def result = invokeAction(action, policy) as List<String> | ||
|
||
then: | ||
result.isEmpty() | ||
} | ||
|
||
def "empty network policy results in empty list" () { | ||
given: "empty policy" | ||
def policy = new NetworkPolicy() | ||
|
||
when: "retrieved list of rules" | ||
def result = invokeAction(action, policy) as List<String> | ||
|
||
then: | ||
result.isEmpty() | ||
} | ||
|
||
def "network policy with empty rule list list results in empty list" () { | ||
given: "network policy with empty list of rules" | ||
def policy = new NetworkPolicy() | ||
def rules = new PolicyEntriesType() | ||
policy.entries = rules | ||
|
||
when: "retrieved list of rules" | ||
def result = invokeAction(action, policy) as List<String> | ||
|
||
then: | ||
result.isEmpty() | ||
} | ||
|
||
def "network policy with single rule results in list with single formatted rule" () { | ||
given: "network policy with single rule" | ||
def policy = new NetworkPolicy() | ||
def rules = new PolicyEntriesType() | ||
policy.entries = rules | ||
def rule = new PolicyRuleType() | ||
rules.addPolicyRule(rule) | ||
rule.actionList = new ActionListType("deny") | ||
rule.addSrcAddresses(new AddressType()) | ||
rule.addDstAddresses(new AddressType()) | ||
rule.addSrcPorts(new PortType()) | ||
rule.addDstPorts(new PortType()) | ||
|
||
when: "retrieved list of rules" | ||
def result = invokeAction(action, policy) as List<String> | ||
|
||
then: "resulting list has one formatted element" | ||
result.size() == 1 | ||
result[0] == utils.ruleToString(rule, 0) | ||
} | ||
} |
82 changes: 82 additions & 0 deletions
82
...ts/src/test/groovy/net/juniper/contrail/vro/tests/actions/ServiceGroupServicesSpec.groovy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
/* | ||
* Copyright (c) 2018 Juniper Networks, Inc. All rights reserved. | ||
*/ | ||
|
||
package net.juniper.contrail.vro.tests.actions | ||
|
||
import net.juniper.contrail.api.types.FirewallServiceGroupType | ||
import net.juniper.contrail.api.types.FirewallServiceType | ||
import net.juniper.contrail.api.types.PortType | ||
import net.juniper.contrail.api.types.ServiceGroup | ||
|
||
import static net.juniper.contrail.vro.config.Actions.serviceGroupServices | ||
import static net.juniper.contrail.vro.model.UtilsKt.utils | ||
|
||
class ServiceGroupServicesSpec extends ActionSpec implements ValidationAsserts { | ||
def actionScript = actionFromScript(serviceGroupServices) | ||
|
||
def "null service group results in empty list" () { | ||
given: | ||
def item = null | ||
|
||
when: | ||
def result = invokeAction(actionScript, item) as List<String> | ||
|
||
then: | ||
result.isEmpty() | ||
} | ||
|
||
def "null FirewallServiceGroupType object results in empty list" () { | ||
given: | ||
def item = new ServiceGroup() | ||
item.setFirewallServiceList(null) | ||
|
||
when: | ||
def result = invokeAction(actionScript, item) as List<String> | ||
|
||
then: | ||
result.isEmpty() | ||
} | ||
|
||
def "null firewall service list results in empty list" () { | ||
given: | ||
def item = new ServiceGroup() | ||
def listType = new FirewallServiceGroupType(null) | ||
item.setFirewallServiceList(listType) | ||
|
||
when: | ||
def result = invokeAction(actionScript, item) as List<String> | ||
|
||
then: | ||
result.isEmpty() | ||
} | ||
|
||
def "empty firewall service list results in empty list" () { | ||
given: | ||
def item = new ServiceGroup() | ||
def listType = new FirewallServiceGroupType(new ArrayList<FirewallServiceType>()) | ||
item.setFirewallServiceList(listType) | ||
|
||
when: | ||
def result = invokeAction(actionScript, item) as List<String> | ||
|
||
then: | ||
result.isEmpty() | ||
} | ||
|
||
def "single service in the list results in list with single element formatted using Utils" () { | ||
given: | ||
def item = new ServiceGroup() | ||
def listType = new FirewallServiceGroupType() | ||
item.setFirewallServiceList(listType) | ||
def service = new FirewallServiceType("tcp", null, new PortType(0, 65535), new PortType(7, 131)) | ||
listType.addFirewallService(service) | ||
|
||
when: | ||
def result = invokeAction(actionScript, item) as List<String> | ||
|
||
then: | ||
result.size() == 1 | ||
result[0] == utils.firewallServiceToString(service, 0) | ||
} | ||
} |
Oops, something went wrong.