Skip to content

Commit

Permalink
Use email exact text as username (#208)
Browse files Browse the repository at this point in the history
* Use email exact text as username
* Remove dockle and hadolint
  • Loading branch information
wg102 authored Jun 17, 2024
1 parent e62fd3d commit a2e109a
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 55 deletions.
24 changes: 16 additions & 8 deletions .github/workflows/build-centraldashboard.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ env:
CLUSTER_RESOURCE_GROUP: k8s-cancentral-01-covid-aks
TRIVY_VERSION: "v0.43.1"
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
HADOLINT_VERSION: "2.12.0"

jobs:
build-push:
Expand Down Expand Up @@ -73,14 +74,21 @@ jobs:
trivy image localhost:5000/kubeflow/centraldashboard-aaw2:${{ github.sha }} --exit-code 1 --timeout=20m --security-checks vuln --severity CRITICAL
# Run Dockle
- name: Run dockle
uses: goodwithtech/dockle-action@main
with:
image: localhost:5000/kubeflow/centraldashboard-aaw2:${{ github.sha }}
format: 'list'
exit-code: '0'
exit-level: 'fatal'
ignore: 'DKL-DI-0006'
# - name: Run dockle
# uses: goodwithtech/dockle-action@main
# with:
# image: localhost:5000/kubeflow/centraldashboard-aaw2:${{ github.sha }}
# format: 'list'
# exit-code: '0'
# exit-level: 'fatal'
# ignore: 'DKL-DI-0006'

# On hold to replace dockle
# - name: Run Hadolint
# run: |
# sudo curl -L https://github.com/hadolint/hadolint/releases/download/v${{ env.HADOLINT_VERSION }}/hadolint-Linux-x86_64 --output hadolint
# sudo chmod +x hadolint
# ./hadolint localhost:5000/kubeflow/centraldashboard-aaw2 --no-fail

# Pushes if this is a push to master or an update to a PR that has auto-deploy label
- name: Test if we should push to ACR
Expand Down
15 changes: 15 additions & 0 deletions components/centraldashboard/cypress/e2e/landing-page.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,21 @@ describe('Landing Page', () => {
cy.get('main-page').shadow().find('landing-page').shadow().find('#MainCard > neon-animatable > div > #emailDisplay').find('span').should('exist').and('have.text', '[email protected]');
cy.get('main-page').shadow().find('landing-page').shadow().find('#MainCard > neon-animatable > div > #namespaceDisplay').find('span').should('exist').and('have.text', 'user-name');
});
it('Email number should stay in namespace', ()=>{
cy.intercept('GET', `/api/workgroup/exists`, {
"hasAuth":true,
"user":"[email protected]",
"email": "[email protected]",
"hasWorkgroup":false,
"registrationFlowAllowed": true,
"isAllowed": true
}).as('mockWorkgroupRequest');
cy.visit('/');

cy.wait(['@mockWorkgroupRequest', '@mockDashboardLinksRequest']);
cy.get('main-page').shadow().find('landing-page').shadow().find('#MainCard > neon-animatable > div > #emailDisplay').find('span').should('exist').and('have.text', '[email protected]');
cy.get('main-page').shadow().find('landing-page').shadow().find('#MainCard > neon-animatable > div > #namespaceDisplay').find('span').should('exist').and('have.text', 'user-name1');
});

it('should create new namespace and notebook', ()=>{
//Not asserting landing page username and namespace values since it's asserted in the test above
Expand Down
2 changes: 0 additions & 2 deletions components/centraldashboard/public/assets/i18n/languages.json
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,6 @@
"landingPage.errCreateNS": "An error occured while creating the workspace",
"landingPage.errGetNS": "An error occured while trying to retrieve the workspace",
"landingPage.errCreateDefaultNotebook": "An error occured while trying to create the default notebook",
"landingPage.errGeneral": "An unexpected error occured, details available in English:",
"blockedUserPage.text": "The dev environment is only accessible to developers.",
"notebookDefaultCard.goto": "Go to Notebooks",
"notebookDefaultCard.create": "Create",
Expand Down Expand Up @@ -222,7 +221,6 @@
"landingPage.errCreateNS": "Une erreur s'est produite lors de la création de l'espace de travail",
"landingPage.errGetNS": "Une erreur s'est produite lors de la tentative de récupération de l'espace de travail",
"landingPage.errCreateDefaultNotebook": "Une erreur s'est produite lors de la tentative de création du notebook par défaut",
"landingPage.errGeneral": "Une erreur inattendue s'est produite, détails disponibles en anglais :",
"blockedUserPage.text": "L'environment Dev est seulement pour les développeurs.",
"registrationPage.btnNext": "Suivant",
"registrationPage.btnStartSetup": "Commencer",
Expand Down
51 changes: 6 additions & 45 deletions components/centraldashboard/public/components/landing-page.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,8 @@ export class LandingPage extends mixinBehaviors([AppLocalizeBehavior], utilities
emailAddress: {type: String, observer: '_onEmailAddress'},
namespaceName: String,
errorText: {type: String, value: ''},
errorDetail: {type: String, value: ''},
flowComplete: {type: Boolean, value: false},
loading: {type: Boolean, value: false},
showAPIText: {type: Boolean, value: false},
isStatcanEmail: {type: Boolean, value: false},
};
}
Expand All @@ -67,41 +65,8 @@ export class LandingPage extends mixinBehaviors([AppLocalizeBehavior], utilities
ns = ns
.replace(/[^\w]|\./g, '-')
.replace(/^-+|-+$|_/g, '')
.replace(/[0-9]/g, '')
.toLowerCase();

this.getNamespaces(ns);
}

async getNamespaces(ns) {
await fetch(
`/api/namespaces/`, {
method: 'GET',
headers: {
'Content-Type': 'application/json',
},
}
)
.then((res) => res.json())
.then((data) => {
const namespaceNames = [];
data.forEach((element) => {
namespaceNames.push(element.metadata.name);
});
let counter = 1;
// Remove any numbers at the end
const originalNs = ns.replace(/\d+/g, '');
if (namespaceNames.includes(originalNs)) {
while (namespaceNames.includes(originalNs + counter)) {
counter++;
}
ns = originalNs + counter;
}
this.namespaceName = ns;
}).catch((e)=> {
this.showError('landingPage.errGeneral');
this.errorDetail= e;
});
this.namespaceName = ns;
}

logout() {
Expand All @@ -119,17 +84,15 @@ export class LandingPage extends mixinBehaviors([AppLocalizeBehavior], utilities

async handleMakeNamespace() {
/*
* Poll for profile over a span of 20 seconds (every 300ms)
* Waits for the new profile to be available
* if still not there, let the user click next again!
*/
* Poll for profile over a span of 20 seconds (every 300ms* max 66 times)
* Waits for the new profile to be available
*/
const success = await this.pollProfile(66, 300);
if (success) this._successSetup();

// Create the default notebook
const APICreateDefault = this.$.CreateDefaultNotebook;

APICreateDefault.generateRequest();
const APICreateDefaultNotebook = this.$.CreateDefaultNotebook;
APICreateDefaultNotebook.generateRequest();
}

async pollProfile(times, delay) {
Expand All @@ -153,12 +116,10 @@ export class LandingPage extends mixinBehaviors([AppLocalizeBehavior], utilities
showError(err) {
this.loading = false;
this.errorText = err;
this.errorDetail = '';
}

closeError() {
this.errorText = '';
this.errorDetail = '';
}

_onCreateNamespaceError() {
Expand Down

0 comments on commit a2e109a

Please sign in to comment.