/
EditServiceOfServiceGroupSpec.groovy
68 lines (58 loc) · 2.32 KB
/
EditServiceOfServiceGroupSpec.groovy
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
/*
* Copyright (c) 2018 Juniper Networks, Inc. All rights reserved.
*/
package net.juniper.contrail.vro.tests.workflows
import net.juniper.contrail.api.Status
import net.juniper.contrail.api.types.ServiceGroup
class EditServiceOfServiceGroupSpec extends WorkflowSpec {
def workflowScript = workflowFromScript("Edit service of service group")
def addServiceScript = workflowFromScript("Add service to service group")
def someProtocol = "tcp"
def startPort = 157
def endPort = 2391
def somePorts = "$startPort-$endPort".toString()
def someOtherProtocol = "udp"
def someOtherStartPort = 73
def someOtherEndPort = 372
def someOtherPorts = "$someOtherStartPort-$someOtherEndPort".toString()
def "Editing service of service group"() {
given:
def serviceGroup = dependencies.someGlobalServiceGroup()
connectorMock.read(_) >> Status.success()
connectorMock.update(_) >> Status.success()
def initialSize = serviceGroup.getFirewallServiceList()?.getFirewallService()?.size() ?: 0
def serviceToEdit = "$initialSize: dummy representation"
//add service to service group
invokeFunction(
addServiceScript,
serviceGroup,
someProtocol,
somePorts
)
def sizeBeforeEdit = serviceGroup.getFirewallServiceList().getFirewallService().size()
when: "workflow is executed"
invokeFunction(
workflowScript,
serviceGroup,
serviceToEdit,
someOtherProtocol,
someOtherPorts
)
then: "the parent service group should be updated."
1 * connectorMock.update({
def _it = it as ServiceGroup
_it.uuid == serviceGroup.uuid &&
_it.firewallServiceList.firewallService.size() == sizeBeforeEdit &&
! _it.firewallServiceList.firewallService.any{
it.protocol == someProtocol &&
it.dstPorts.startPort == startPort &&
it.dstPorts.endPort == endPort
} &&
_it.firewallServiceList.firewallService.any{
it.protocol == someOtherProtocol &&
it.dstPorts.startPort == someOtherStartPort &&
it.dstPorts.endPort == someOtherEndPort
}
}) >> Status.success()
}
}