Skip to content

Commit

Permalink
Merge pull request #1085 from bcgov/feature/ns-to-gw-validation-error
Browse files Browse the repository at this point in the history
Validation error messages namespace to gateway
  • Loading branch information
rustyjux authored Jul 22, 2024
2 parents 08127d1 + 8ceb7af commit a4c48ab
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 11 deletions.
4 changes: 2 additions & 2 deletions src/controllers/v2/NamespaceController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ export class NamespaceController extends Controller {
result.errors.forEach((err: any, ind: number) => {
errors[`d${ind}`] = { message: err.message };
});
throw new ValidateError(errors, 'Unable to create namespace');
throw new ValidateError(errors, 'Unable to create gateway');
}
return {
name: result.data.createNamespace.name,
Expand Down Expand Up @@ -201,7 +201,7 @@ export class NamespaceController extends Controller {
result.errors.forEach((err: any, ind: number) => {
errors[`d${ind}`] = { message: err.message };
});
throw new ValidateError(errors, 'Unable to delete namespace');
throw new ValidateError(errors, 'Unable to delete gateway');
}
return result.data.forceDeleteNamespace;
}
Expand Down
2 changes: 1 addition & 1 deletion src/lists/extensions/Namespace.ts
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ module.exports = {
assert.strictEqual(
re.test(args.namespace),
true,
'Namespace name must be between 5 and 15 alpha-numeric lowercase characters and begin with an alphabet.'
'Gateway name must be between 5 and 15 alpha-numeric lowercase characters and begin with an alphabet.'
);
const noauthContext = context.createContext({
skipAccessControl: true,
Expand Down
6 changes: 3 additions & 3 deletions src/services/workflow/delete-namespace.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,22 +36,22 @@ export const DeleteNamespaceValidate = async (
messages.push(
`${accessList.length} ${
accessList.length == 1 ? 'consumer has' : 'consumers have'
} access to products in this namespace.`
} access to products in this gateway.`
);
}
if (gwServices.length > 0) {
messages.push(
`${gwServices.length} ${
gwServices.length == 1 ? 'service has' : 'services have'
} been configured in this namespace.`
} been configured in this gateway.`
);
}

// Even when force=true, if there are consumers then do not proceed
if (accessList.length != 0) {
const msg = `${accessList.length} ${
accessList.length == 1 ? 'consumer has' : 'consumers have'
} access to products in this namespace.`;
} access to products in this gateway.`;
assert.strictEqual(accessList.length == 0, true, msg);
}
if (!force) {
Expand Down
2 changes: 1 addition & 1 deletion src/services/workflow/validate-access-request.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ export const Validate = async (
'Can not mark a new request approved'
);

// assert that either the Product is Active or it belongs to the authorized Subject namespace
// assert that either the Product is Active or it belongs to the authorized Subject gateway
assert.strictEqual(
prodEnv.active === true ||
prodEnv.product.namespace === context.authedItem.namespace,
Expand Down
6 changes: 3 additions & 3 deletions src/services/workflow/validate-active-environment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,19 +71,19 @@ export const ValidateActiveEnvironment = async (
envServices.product.namespace
);
addValidationError(
`[dataset] Unexpected error finding namespace. Unable to complete request.`
`[dataset] Unexpected error finding gateway. Unable to complete request.`
);
} else if (nsOrgDetails.enabled === false) {
addValidationError(
`[dataset] Namespace must be assigned to an Organization before an Environment can be active.`
`[dataset] Gateway must be assigned to an Organization before an Environment can be active.`
);
} else if (
nsOrgDetails.name === envDataset?.organization?.name &&
nsOrgDetails.orgUnit === envDataset?.organizationUnit?.name
) {
} else {
addValidationError(
`[dataset] Namespace and Dataset must belong to the same Organization Unit (ns:${nsOrgDetails.orgUnit}, dataset:${envDataset?.organizationUnit?.name})`
`[dataset] Gateway and Dataset must belong to the same Organization Unit (ns:${nsOrgDetails.orgUnit}, dataset:${envDataset?.organizationUnit?.name})`
);
}

Expand Down
2 changes: 1 addition & 1 deletion src/services/workflow/validate-issuer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ export const ValidateIssuer = async (
resolvedData['namespace']
);
addValidationError(
'Setting shared is only available in privileged namespaces'
'Setting shared is only available in privileged gateways'
);
}
}
Expand Down

0 comments on commit a4c48ab

Please sign in to comment.