Skip to content

Commit

Permalink
UI: allow src/destination service to be empty and send assertionID wh…
Browse files Browse the repository at this point in the history
…ile validating (#1829)

Signed-off-by: craman <[email protected]>

Co-authored-by: craman <[email protected]>
  • Loading branch information
chandrasekhar1996 and craman authored Mar 28, 2022
1 parent 5e255a1 commit 913fad9
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 23 deletions.
2 changes: 2 additions & 0 deletions ui/src/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -1938,6 +1938,7 @@ const Api = (req) => {
destinationPort,
protocol,
domainName,
assertionId,
_csrf
) {
return new Promise((resolve, reject) => {
Expand All @@ -1957,6 +1958,7 @@ const Api = (req) => {
destinationPort,
protocol,
domainName,
assertionId,
})
.end((err, data) => {
if (err) {
Expand Down
31 changes: 8 additions & 23 deletions ui/src/components/microsegmentation/AddSegmentation.js
Original file line number Diff line number Diff line change
Expand Up @@ -527,17 +527,6 @@ export default class AddSegmentation extends React.Component {
return 1;
}

if (
this.state.sourceServiceMembers.length <= 0 &&
this.state.members.length == 0
) {
this.setState({
errorMessage: 'At least one source service is required.',
saving: 'todo',
});
return 1;
}

if (!this.state.sourcePort || this.state.sourcePort === '') {
this.setState({
errorMessage: 'Source port is required.',
Expand Down Expand Up @@ -573,18 +562,6 @@ export default class AddSegmentation extends React.Component {
return 1;
}

if (
this.state.destinationServiceMembers.length <= 0 &&
this.state.members.length == 0
) {
this.setState({
errorMessage:
'At least one destination service is required.',
saving: 'todo',
});
return 1;
}

if (
!this.state.destinationPort ||
this.state.destinationPort === ''
Expand Down Expand Up @@ -628,6 +605,7 @@ export default class AddSegmentation extends React.Component {
sourcePort,
destinationPort,
protocol,
assertionId,
skipValidation
) {
return new Promise((resolve, reject) => {
Expand All @@ -642,6 +620,7 @@ export default class AddSegmentation extends React.Component {
destinationPort,
protocol,
this.props.domain,
assertionId,
this.props._csrf
)
.then((data) => {
Expand Down Expand Up @@ -783,6 +762,8 @@ export default class AddSegmentation extends React.Component {
// check if validation of policy has been enabled
// if enabled then validate microsegmentation policy against network policy

let assertionId = -1;

this.validateMicrosegmentationPolicy(
this.state.category,
role.roleMembers,
Expand All @@ -791,6 +772,7 @@ export default class AddSegmentation extends React.Component {
sourcePort,
destinationPort,
this.state.protocol,
assertionId,
skipValidation
)
.then(() => {
Expand Down Expand Up @@ -925,6 +907,8 @@ export default class AddSegmentation extends React.Component {
}
}

let assertionId = this.state.data.assertionIdx;

this.validateMicrosegmentationPolicy(
this.state.category,
this.state.members,
Expand All @@ -933,6 +917,7 @@ export default class AddSegmentation extends React.Component {
source.port,
destination.port,
this.state.protocol,
assertionId,
skipValidation
)
.then(() => {
Expand Down
4 changes: 4 additions & 0 deletions ui/src/server/handlers/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -2584,6 +2584,10 @@ Fetchr.registerService({
trafficDirection: trafficDirection,
};

if (params.assertionId != -1) {
transportPolicy.id = params.assertionId;
}

req.clients.msd.validateTransportPolicy(
{ transportPolicy: transportPolicy },
(err, data) => {
Expand Down

0 comments on commit 913fad9

Please sign in to comment.