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

feat: UI pass change #2035

Merged
merged 18 commits into from
Jan 26, 2022
Merged
Show file tree
Hide file tree
Changes from all 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
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"messages": [
{
"messageType": "ERROR",
"messageNumber": "ZWEAT413E",
"messageContent": "The new password is not valid",
"messageKey": "org.zowe.apiml.security.platform.errno.EMVSPASSWORD"
}
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"messages": [
{
"messageType": "ERROR",
"messageNumber": "ZWEAT412E",
"messageContent": "The password for the specified identity has expired",
"messageKey": "org.zowe.apiml.security.platform.errno.EMVSEXPIRE"
}
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"messages": [
{
"messageType": "ERROR",
"messageNumber": "ZWEAT414E",
"messageContent": "Account suspended",
"messageKey": "org.zowe.apiml.security.platform.errno.EMVSSAFEXTRERR"
}
]
}
32 changes: 28 additions & 4 deletions api-catalog-ui/frontend/mocked-backend/routes/routes.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,31 @@ const testinson = require('../assets/services/testinson');
const cademoapps = require('../assets/services/cademoapps');
const loginSuccess = require('../assets/services/login_success');
const invalidCredentials = require('../assets/services/user-name-invalid.json');

const passwordExpired = require('../assets/services/password-expired.json');
const apiCatalog = require('../assets/apidoc/apicatalog.json');
const discoverableClient = require('../assets/apidoc/discoverableclient');
const sampleClient = require('../assets/apidoc/sample');
const userSuspended = require('../assets/services/user-suspended.json');
const newPassNotValid = require('../assets/services/new-pass-not-valid.json');

let allUP = false;

function validateCredentials({ username, password }) {
return username === 'user' && password === 'user';
}
function isUserSuspended({ username, password }) {
return username === 'susp' && password === 'user';
}
function validateExpiredCredentials({ username, password }) {
return username === 'user' && password === 'exp';
}
function isNewPasswordInvalid({newPassword}) {
return newPassword === 'invalid';
}

function validatePasswordUpdate({ username, password, newPassword }) {
return username === 'user' && password === 'exp' && newPassword !== undefined && newPassword !== password && newPassword !== 'invalid';
}

const appRouter = app => {
// NOTE: The root route
Expand All @@ -26,11 +41,20 @@ const appRouter = app => {

app.post('/apicatalog/api/v1/auth/login', async (req, res) => {
const credentials = req.body;

if (validateCredentials(credentials)) {
if (validatePasswordUpdate(credentials)) {
console.log('PASSWORD UPDATE');
setTimeout(() => res.status(204).send(loginSuccess), 2000);
} else if (isNewPasswordInvalid(credentials)){
res.status(401).send(newPassNotValid);
} else if (validateCredentials(credentials)) {
console.log('LOGIN');
setTimeout(() => res.status(204).send(loginSuccess), 2000);
} else {
} else if(validateExpiredCredentials(credentials)){
res.status(401).send(passwordExpired);
} else if(isUserSuspended(credentials)){
res.status(401).send(userSuspended);
}
else {
console.log(invalidCredentials);
res.status(401).send(invalidCredentials);
}
Expand Down
Loading