Skip to content

Commit afa09c4

Browse files
Created unit test for /api/v1/firewall/traffic_shaper endpoint
1 parent b7c2c5d commit afa09c4

1 file changed

Lines changed: 148 additions & 0 deletions

File tree

Lines changed: 148 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,148 @@
1+
# Copyright 2021 Jared Hendrickson
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
import unit_test_framework
16+
17+
class APIUnitTestFirewallRule(unit_test_framework.APIUnitTest):
18+
url = "/api/v1/firewall/traffic_shaper"
19+
post_tests = [
20+
{
21+
"name": "Create a traffic shaper",
22+
"payload": {
23+
"interface": "lan",
24+
"scheduler": "PRIQ",
25+
"bandwidthtype": "Gb",
26+
"bandwidth": 1,
27+
"enabled": False,
28+
"qlimit": 1000,
29+
"tbrconfig": 1000,
30+
"apply": True
31+
}
32+
},
33+
{
34+
"name": "Check interface requirement",
35+
"status": 400,
36+
"return": 4110
37+
},
38+
{
39+
"name": "Check interface validation",
40+
"status": 400,
41+
"return": 4111,
42+
"payload": {
43+
"interface": "INVALID"
44+
}
45+
},
46+
{
47+
"name": "Check interface unique constraint",
48+
"status": 400,
49+
"return": 4112,
50+
"payload": {
51+
"interface": "LAN"
52+
}
53+
},
54+
{
55+
"name": "Check scheduler requirement",
56+
"status": 400,
57+
"return": 4113,
58+
"payload": {
59+
"interface": "wan"
60+
}
61+
},
62+
{
63+
"name": "Check scheduler validation",
64+
"status": 400,
65+
"return": 4114,
66+
"payload": {
67+
"interface": "wan",
68+
"scheduler": "INVALID"
69+
}
70+
},
71+
{
72+
"name": "Check bandwidth type requirement",
73+
"status": 400,
74+
"return": 4115,
75+
"payload": {
76+
"interface": "wan",
77+
"scheduler": "HFSC"
78+
}
79+
},
80+
{
81+
"name": "Check bandwidth type validation",
82+
"status": 400,
83+
"return": 4116,
84+
"payload": {
85+
"interface": "wan",
86+
"scheduler": "HFSC",
87+
"bandwidthtype": "INVALID"
88+
}
89+
},
90+
{
91+
"name": "Check bandwidth requirement",
92+
"status": 400,
93+
"return": 4117,
94+
"payload": {
95+
"interface": "wan",
96+
"scheduler": "HFSC",
97+
"bandwidthtype": "%"
98+
}
99+
},
100+
{
101+
"name": "Check bandwidth minimum constraint",
102+
"status": 400,
103+
"return": 4118,
104+
"payload": {
105+
"interface": "wan",
106+
"scheduler": "HFSC",
107+
"bandwidthtype": "%",
108+
"bandwidth": 0
109+
}
110+
},
111+
{
112+
"name": "Check bandwidth maximum constraint when percentage type is chosen",
113+
"status": 400,
114+
"return": 4119,
115+
"payload": {
116+
"interface": "wan",
117+
"scheduler": "HFSC",
118+
"bandwidthtype": "%",
119+
"bandwidth": 101
120+
}
121+
},
122+
{
123+
"name": "Check queue limit minimum constraint",
124+
"status": 400,
125+
"return": 4120,
126+
"payload": {
127+
"interface": "wan",
128+
"scheduler": "HFSC",
129+
"bandwidthtype": "%",
130+
"bandwidth": 25,
131+
"qlimit": 0
132+
}
133+
},
134+
{
135+
"name": "Check TBR size minimum constraint",
136+
"status": 400,
137+
"return": 4121,
138+
"payload": {
139+
"interface": "wan",
140+
"scheduler": "HFSC",
141+
"bandwidthtype": "%",
142+
"bandwidth": 25,
143+
"tbrconfig": 0
144+
}
145+
},
146+
]
147+
148+
APIUnitTestFirewallRule()

0 commit comments

Comments
 (0)