Revision 01adca6b snf-cyclades-app/synnefo/api/tests/subnets.py

b/snf-cyclades-app/synnefo/api/tests/subnets.py
114 114
                'cidr': '10.0.3.0/24',
115 115
                'ip_version': 4,
116 116
                'allocation_pools': [{
117
                    'start': '10.0.3.0',
118
                    'end': '10.0.3.255'}
117
                    'start': '10.0.3.2',
118
                    'end': '10.0.3.252'}
119 119
                ]}
120 120
        }
121 121
        response = self.post(SUBNETS_URL, test_net.userid,
......
131 131
                'cidr': '10.0.3.0/24',
132 132
                'ip_version': 4,
133 133
                'allocation_pools': [{
134
                    'start': '10.0.3.0',
134
                    'start': '10.0.3.2',
135 135
                    'end': '10.0.3.100'}, {
136 136
                    'start': '10.0.3.200',
137 137
                    'end': '10.0.3.220'}
......
141 141
                             json.dumps(request), "json")
142 142
        self.assertSuccess(response)
143 143

  
144
    def test_create_subnet_with_gateway_inside_of_ip_pool_range(self):
145
        """Test create a subnet with an IP pool outside of network range"""
146
        test_net = mf.NetworkFactory()
147
        request = {
148
            'subnet': {
149
                'network_id': test_net.id,
150
                'cidr': '10.0.3.0/24',
151
                'ip_version': 4,
152
                'gateway_ip': '10.0.3.1',
153
                'allocation_pools': [{
154
                    'start': '10.0.3.0',
155
                    'end': '10.0.3.255'}
156
                ]}
157
        }
158
        response = self.post(SUBNETS_URL, test_net.userid,
159
                             json.dumps(request), "json")
160
        self.assertConflict(response)
161

  
144 162
    def test_create_subnet_with_ip_pool_outside_of_network_range(self):
145 163
        """Test create a subnet with an IP pool outside of network range"""
146 164
        test_net = mf.NetworkFactory()
......
151 169
                'ip_version': 4,
152 170
                'allocation_pools': [{
153 171
                    'start': '10.0.8.0',
154
                    'end': '10.0.1.255'}
172
                    'end': '10.0.1.250'}
155 173
                ]}
156 174
        }
157 175
        response = self.post(SUBNETS_URL, test_net.userid,
158 176
                             json.dumps(request), "json")
159
        self.assertBadRequest(response)
177
        self.assertConflict(response)
160 178

  
161 179
    def test_create_subnet_with_ip_pool_end_lower_than_start(self):
162 180
        """Test create a subnet with a pool where end is lower than start"""
......
173 191
        }
174 192
        response = self.post(SUBNETS_URL, test_net.userid,
175 193
                             json.dumps(request), "json")
176
        self.assertBadRequest(response)
194
        self.assertConflict(response)
177 195

  
178 196
    def test_create_subnet_with_ip_pool_in_a_ipv6_subnet(self):
179 197
        """Test create a subnet with an ip pool, in an IPv6 subnet """
......
190 208
        }
191 209
        response = self.post(SUBNETS_URL, test_net.userid,
192 210
                             json.dumps(request), "json")
193
        self.assertBadRequest(response)
211
        self.assertConflict(response)
194 212

  
195 213
    def test_create_subnet_with_invalid_network_id(self):
196 214
        """Test create a subnet with a network id that doesn't exist"""

Also available in: Unified diff