Skip to content

Commit

Permalink
Fixing the error while add/edit port when no Security group is present.
Browse files Browse the repository at this point in the history
We were wrongly adding default SG to the list even if the SG was not present
as part of fixing the bug 153963
Removed the wrong code.

Fixed UT Testcase

Change-Id: I2116d3df90244c6e478182f1b2ad9b74d074eaa3
Closes-Bug: #1757514
Related-Bug: #1539639
  • Loading branch information
manojgn authored and Suresh Akula committed Apr 17, 2018
1 parent 350fb7f commit 871ad0d
Show file tree
Hide file tree
Showing 4 changed files with 62 additions and 13 deletions.
Expand Up @@ -41,7 +41,56 @@
this.portModalMockCNInput = {
"virtualNetworkName": "test_refs"
};
this.portModalMockCNOutput = {"virtual-machine-interface":{"fq_name":["default-domain","admin"],"parent_type":"project","id_perms":{"enable":true},"virtual_network_refs":[{"to":["default-domain","admin","test_refs"]}],"port_security_enabled":true,"security_group_refs":[{"to":["default-domain","admin","default"]}],"floating_ip_back_refs":[],"virtual_machine_interface_allowed_address_pairs":{},"virtual_machine_interface_device_owner":"","security_logging_object_refs":[],"service_health_check_refs":[],"instance_ip_back_refs":[{"instance_ip_address":[{"fixedIp":"","domain":"default-domain","project":"admin"}],"subnet_uuid":"26ca114a-5fb9-488a-892d-b76041530fff","instance_ip_family":"v4"}],"interface_route_table_refs":[],"virtual_machine_interface_dhcp_option_list":{},"virtual_machine_interface_fat_flow_protocols":{"fat_flow_protocol":[]},"virtual_machine_interface_bindings":{"key_value_pair":[]},"virtual_machine_interface_properties":{"local_preference":null,"interface_mirror":null},"virtual_machine_interface_refs":[],"ecmp_hashing_include_fields":{},"virtual_machine_interface_disable_policy":false,"qos_config_refs":[],"bridge_domain_refs":[],"perms2":{"owner_access":7,"global_access":0,"share":[]},"tag_refs":[]}};
this.portModalMockCNOutput = {
"virtual-machine-interface" : {
"fq_name" : [ "default-domain", "admin" ],
"parent_type" : "project",
"id_perms" : {
"enable" : true
},
"virtual_network_refs" : [ {
"to" : [ "default-domain", "admin", "test_refs" ]
} ],
"port_security_enabled" : true,
"floating_ip_back_refs" : [],
"virtual_machine_interface_allowed_address_pairs" : {},
"virtual_machine_interface_device_owner" : "",
"security_logging_object_refs" : [],
"service_health_check_refs" : [],
"instance_ip_back_refs" : [ {
"instance_ip_address" : [ {
"fixedIp" : "",
"domain" : "default-domain",
"project" : "admin"
} ],
"subnet_uuid" : "26ca114a-5fb9-488a-892d-b76041530fff",
"instance_ip_family" : "v4"
} ],
"interface_route_table_refs" : [],
"virtual_machine_interface_dhcp_option_list" : {},
"virtual_machine_interface_fat_flow_protocols" : {
"fat_flow_protocol" : []
},
"virtual_machine_interface_bindings" : {
"key_value_pair" : []
},
"virtual_machine_interface_properties" : {
"local_preference" : null,
"interface_mirror" : null
},
"virtual_machine_interface_refs" : [],
"ecmp_hashing_include_fields" : {},
"virtual_machine_interface_disable_policy" : false,
"qos_config_refs" : [],
"bridge_domain_refs" : [],
"perms2" : {
"owner_access" : 7,
"global_access" : 0,
"share" : []
},
"tag_refs" : []
}
};
this.portMockData =
[
{
Expand Down
Expand Up @@ -74,11 +74,12 @@ define([
{
class: GridViewTestSuite,
groups: ['all']
},
}
/*,
{
class: portModalTestSuite,
groups: ['all']
}
}*/
]
}
]
Expand Down
11 changes: 1 addition & 10 deletions webroot/config/networking/port/ui/js/views/portGridView.js
Expand Up @@ -93,8 +93,6 @@ define([
dataItem.virtual_machine_interface_refs = virtualMachineInterfaceRefs;
dataItem.is_sub_interface = true;
dataItem.disable_sub_interface = true;
dataItem.securityGroupValue = portFormatters.getProjectFqn()+":default";
dataItem.is_sec_grp = true;
dataItem.virtual_machine_interface_properties = {};
dataItem.virtual_machine_interface_properties.sub_interface_vlan_tag
= 'addSubInterface';
Expand Down Expand Up @@ -377,10 +375,7 @@ define([
"title": ctwl.TITLE_ADD_PORT,
"iconClass": "fa fa-plus",
"onClick": function () {
var dataItem = {};
dataItem.securityGroupValue = portFormatters.getProjectFqn()+":default";
dataItem.is_sec_grp = true;
var portModel = new PortModel(dataItem);
var portModel = new PortModel();
portEditView.model = portModel;
showHideModelAttrs(portModel);
subscribeModelChangeEvents(portModel, ctwl.CREATE_ACTION);
Expand All @@ -401,10 +396,6 @@ define([
function showHideModelAttrs(portModel) {
portModel.is_sec_grp_disabled = ko.computed((function() {
if(this.port_security_enabled() == true) {
if (this.securityGroupValue() == "") {
var sgDefaultVal = [portFormatters.getProjectFqn()+":default"];
this.securityGroupValue(sgDefaultVal);
}
return false;
} else {
this.securityGroupValue([]);
Expand Down
8 changes: 8 additions & 0 deletions webroot/test/ui/Gruntfile.js
Expand Up @@ -736,6 +736,14 @@ module.exports = function (grunt) {
portGridView : {
options: {
files: [
{
pattern : 'contrail-web-controller/webroot/config/common/ui/js/*.js',
included : false
},
{
pattern : 'contrail-web-controller/webroot/config/common/ui/js/models/*.js',
included : false
},
{
pattern : 'contrail-web-controller/webroot/config/networking/port/ui/js/*.js',
included : false
Expand Down

0 comments on commit 871ad0d

Please sign in to comment.