ITNeutronE2E.test_fetch(url, false, "Firewall Rule Element Negative Get Failed");
}
+ public String test_bug6398_fw_rule_create_test() {
+ String url = base + "/fw/firewall_rules";
+ String content = "{ \"firewall_rule\": { \"action\": \"allow\"," + "\"destination_ip_address\": null,"
+ + "\"destination_port_min\": \"80\", \"destination_port_max\": \"80\"," + "\"enabled\": true,"
+ + "\"firewall_policy_id\": null," + "\"id\": \"8722e0e0-9cc9-4490-9660-8c9a5732fbb0\","
+ + "\"ip_version\": 4, \"name\": \"ALLOW_HTTP\"," + "\"position\": null, \"protocol\": \"TCP\","
+ + "\"shared\": false, \"source_ip_address\": null,"
+ + "\"source_port_min\": null, \"source_port_max\": null,"
+ + "\"tenant_id\": \"45977fa2dbd7482098dd68d0d8970117\" } }";
+ ITNeutronE2E.test_create(url, 400, content, "Firewall Rule Singleton Post Bug 6398 regressed");
+ return content;
+ }
+
public static void runTests(String base) {
NeutronFirewallRuleTests fw_rule_tester = new NeutronFirewallRuleTests(base);
String createJsonString = fw_rule_tester.singleton_fw_rule_create_test();
fw_rule_tester.fw_rule_modify_test();
fw_rule_tester.fw_rule_delete_test();
fw_rule_tester.fw_rule_element_negative_get_test();
+ fw_rule_tester.test_bug6398_fw_rule_create_test();
}
}
ITNeutronE2E.test_delete(url, "LB Listener Element Delete Failed");
}
+ public String test_bug6398_lb_listener_create_test() {
+ String url = base + "/lbaas/listeners";
+ String content = "{ \"listener\": { " + "\"admin_state_up\": true, " + "\"connection_limit\": 100, "
+ + "\"default_pool_id\": null, " + "\"description\": \"listener one\", "
+ + "\"id\": \"39de4d56-d663-46e5-85a1-5b9d5fa17829\", " + "\"loadbalancers\": [ { "
+ + "\"id\": \"a36c20d0-18e9-42ce-88fd-82a35977ee8c\" } ], " + "\"name\": \"listener1\", "
+ + "\"protocol\": \"http\", " + "\"protocol_port\": 80, "
+ + "\"tenant_id\": \"b7c1a69e88bf4b21a8148f787aef2081\" } }";
+ ITNeutronE2E.test_create(url, 400, content, "LB Listener Post Bug 6398 regressed");
+ return content;
+ }
+
public static void runTests(String base) {
NeutronLBListenerTests listener_tester = new NeutronLBListenerTests(base);
String createJsonString = listener_tester.singleton_lb_listener_create_test();
listener_tester.listener_collection_get_test();
listener_tester.listener_delete_test();
listener_tester.listener_element_negative_get_test();
+ listener_tester.test_bug6398_lb_listener_create_test();
}
}
ITNeutronE2E.test_delete(url, "Security Rule Delete Failed");
}
+ public String bug6398_sr_create_test() {
+ String url = base + "/security-group-rules";
+ String content = " {\"security_group_rule\": " + "{\"remote_group_id\": null, \"direction\": \"ingress\", "
+ + "\"remote_ip_prefix\": null, \"protocol\": \"TCP\", " + "\"ethertype\": \"IPv6\", \"tenant_id\": "
+ + "\"00f340c7c3b34ab7be1fc690c05a0275\", \"port_range_max\": 77, " + "\"port_range_min\": 77, "
+ + "\"id\": \"9b4be7fa-e56e-40fb-9516-1f0fa9185669\", " + "\"security_group_id\": "
+ + "\"b60490fe-60a5-40be-af63-1d641381b784\"}}";
+ ITNeutronE2E.test_create(url, 400, content, "Security Rule Singleton Post Bug 6398 regressed");
+ return content;
+ }
+
public static void runTests(String base) {
NeutronSecurityRuleTests securityRule_tester = new NeutronSecurityRuleTests(base);
String createJsonString = securityRule_tester.singleton_sr_create_test();
securityRule_tester.bug5478_rule_delete_negative_test();
securityRule_tester.bug4043_ipv4_test();
securityRule_tester.bug4043_ipv6_test();
+ securityRule_tester.bug6398_sr_create_test();
}
}
import com.google.common.collect.ImmutableBiMap;
import java.util.List;
import org.opendaylight.controller.md.sal.binding.api.DataBroker;
+import org.opendaylight.neutron.northbound.api.BadRequestException;
import org.opendaylight.neutron.spi.INeutronFirewallRuleCRUD;
import org.opendaylight.neutron.spi.NeutronFirewallRule;
import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.constants.rev150712.IpVersionBase;
}
if (rule.getFirewallRuleProtocol() != null) {
final String protocolString = rule.getFirewallRuleProtocol();
- final Protocol protocol = new Protocol(protocolString.toCharArray());
- ruleBuilder.setProtocol(protocol);
+ try {
+ final Protocol protocol = new Protocol(protocolString.toCharArray());
+ ruleBuilder.setProtocol(protocol);
+ } catch (NumberFormatException e) {
+ throw new BadRequestException("Protocol {" + rule.getFirewallRuleProtocol()
+ + "} is not supported");
+ }
}
if (rule.getFirewallRuleIpVer() != null) {
final ImmutableBiMap<Integer, Class<? extends IpVersionBase>> mapper = IP_VERSION_MAP.inverse();
import java.util.ArrayList;
import java.util.List;
import org.opendaylight.controller.md.sal.binding.api.DataBroker;
+import org.opendaylight.neutron.northbound.api.BadRequestException;
import org.opendaylight.neutron.spi.INeutronLoadBalancerListenerCRUD;
import org.opendaylight.neutron.spi.NeutronLoadBalancerListener;
import org.opendaylight.neutron.spi.Neutron_ID;
}
if (listener.getNeutronLoadBalancerListenerProtocol() != null) {
final ImmutableBiMap<String, Class<? extends ProtocolBase>> mapper = PROTOCOL_MAP.inverse();
- listenerBuilder.setProtocol(
- (Class<? extends ProtocolBase>) mapper.get(listener.getNeutronLoadBalancerListenerProtocol()));
+ Class<? extends ProtocolBase> protocol = mapper.get(listener.getNeutronLoadBalancerListenerProtocol());
+ if (protocol != null) {
+ listenerBuilder.setProtocol(protocol);
+ } else {
+ throw new BadRequestException("Protocol {" + listener.getNeutronLoadBalancerListenerProtocol()
+ + "} is not supported");
+ }
}
if (listener.getNeutronLoadBalancerListenerProtocolPort() != null) {
listenerBuilder.setProtocolPort(Integer.valueOf(listener.getNeutronLoadBalancerListenerProtocolPort()));
import com.google.common.collect.ImmutableBiMap;
import java.util.List;
import org.opendaylight.controller.md.sal.binding.api.DataBroker;
+import org.opendaylight.neutron.northbound.api.BadRequestException;
import org.opendaylight.neutron.spi.INeutronSecurityRuleCRUD;
import org.opendaylight.neutron.spi.NeutronSecurityRule;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpPrefix;
}
if (securityRule.getSecurityRuleProtocol() != null) {
final String protocolString = securityRule.getSecurityRuleProtocol();
- final Protocol protocol = new Protocol(protocolString.toCharArray());
- securityRuleBuilder.setProtocol(protocol);
+ try {
+ final Protocol protocol = new Protocol(protocolString.toCharArray());
+ securityRuleBuilder.setProtocol(protocol);
+ } catch (NumberFormatException e) {
+ throw new BadRequestException("Protocol {" + securityRule.getSecurityRuleProtocol()
+ + "} is not supported");
+ }
}
if (securityRule.getSecurityRuleEthertype() != null) {
final ImmutableBiMap<String, Class<? extends EthertypeBase>> mapper = ETHERTYPE_MAP.inverse();