Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Validation error messages namespace to gateway #1085

Merged
merged 4 commits into from
Jul 22, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions e2e/cypress/pageObjects/home.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class HomePage {
cy.get(this.nsDropdownCreateNsBtn).click()
cy.get(this.namespaceNameInput).type(name) // using `platform` as a default ns as its being seeding through feeder
cy.get(this.nsCreateBtn).click()
cy.verifyToastMessage("Namespace "+name+" created!")
cy.verifyToastMessage("Gateway "+name+" created!")
cy.wait(5000) // wait for dropdown to have latest text
cy.get(this.nsDropdown).then(($el) => {
expect($el).contain(name)
Expand Down Expand Up @@ -56,7 +56,7 @@ class HomePage {
cy.wait(1000)
cy.get(this.namespaceNameInput).next('div').then(($ele) => {
let validationMessage = $ele.text()
assert.equal(validationMessage,"Namespace name must be between 5 and 15 alpha-numeric lowercase characters and start and end with an alphabet.")
assert.equal(validationMessage,"Gateway name must be between 5 and 15 alpha-numeric lowercase characters and start and end with an alphabet.")
})
// cy.verifyToastMessage("Namespace create failed")
})
Expand Down
2 changes: 1 addition & 1 deletion src/auth/auth-oauth2-proxy.js
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ class Oauth2ProxyAuthStrategy {

res.json({ switch: switched });
} catch (err) {
logger.error('Error clearing namespace %s', err);
logger.error('Error clearing gateway %s', err);
res.status(400).json({ switch: false, error: 'ns_cleared_fail' });
}
}
Expand Down
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
12 changes: 6 additions & 6 deletions src/services/workflow/delete-namespace.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export const DeleteNamespaceValidate = async (
ns: string,
force: boolean
): Promise<void> => {
logger.debug('Validate Deleting Namespace ns=%s', ns);
logger.debug('Validate Deleting Gateway ns=%s', ns);

const gwServices = await lookupServicesByNamespace(context, ns);

Expand All @@ -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 All @@ -63,7 +63,7 @@ export const DeleteNamespaceRecordActivity = async (
context: any,
ns: string
): Promise<{ id: string }> => {
logger.debug('Record Activity for Deleting Namespace ns=%s', ns);
logger.debug('Record Activity for Deleting Gateway ns=%s', ns);

const envs = await lookupEnvironmentsByNS(context, ns);

Expand Down Expand Up @@ -98,7 +98,7 @@ export const DeleteNamespace = async (
subjectToken: string,
ns: string
) => {
logger.debug('Deleting Namespace ns=%s', ns);
logger.debug('Deleting Gateway ns=%s', ns);
assert.strictEqual(
typeof ns === 'string' && ns.length > 0,
true,
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
8 changes: 4 additions & 4 deletions src/services/workflow/validate-active-environment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,23 +67,23 @@ export const ValidateActiveEnvironment = async (
);
} else if (typeof nsOrgDetails === 'undefined') {
logger.error(
'[dataset] Namespace not found %s',
'[dataset] Gateway not found %s',
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
4 changes: 2 additions & 2 deletions src/services/workflow/validate-issuer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,11 @@ export const ValidateIssuer = async (
);
if (!privileged) {
logger.warn(
'[%s] Setting shared is only available in privileged namespaces',
'[%s] Setting shared is only available in privileged gateways',
resolvedData['namespace']
);
addValidationError(
'Setting shared is only available in privileged namespaces'
'Setting shared is only available in privileged gateways'
);
}
}
Expand Down
Loading