diff --git a/cypress/e2e/pasteUrlLoginRedirect.cy.js b/cypress/e2e/pasteUrlLoginRedirect.cy.js index 94e2846..475c048 100644 --- a/cypress/e2e/pasteUrlLoginRedirect.cy.js +++ b/cypress/e2e/pasteUrlLoginRedirect.cy.js @@ -1,17 +1,37 @@ -const urlUnderTest = `https://REDACTED-HOST/login?return-to=aHR0cHM6Ly9sdWNpYS1kZXYuZHNwLmltL2Rpc2NvdmVyL2NvbmZvcm1hbmNlL2xvZy8xODU1MjQ3OTcvY29uZm9ybWFuY2U=`; -describe('Conformance', ()=>{ - beforeEach(() => { - cy.visit(urlUnderTest); - }); - - it('After pasting discover/conformance/log/ page, frontend should redirect to corresponding\ - page, not login page', () => { - cy.get('#account').clear().type(` ${Cypress.env('user').username} `); - cy.get('#password').clear().type(` ${Cypress.env('user').password} `); - cy.get('.btn-lg').click(); - cy.get('form').submit(); - - cy.contains('Conformance Checking Results').should('be.visible'); - }) - +const conformanceExampleUrl = "https://REDACTED-HOST/discover/conformance/log/185524797/conformance"; +const urlUnderTestNotEncoded = `https://REDACTED-HOST/login?return-to=${conformanceExampleUrl}`; +const urlsUnderTest = [urlUnderTestNotEncoded,]; +describe('Conformance url pastetd', ()=>{ + urlsUnderTest.forEach((curUrl) => { + context(`Testing with URL: ${curUrl}`, () => { + beforeEach(() => { + cy.visit(curUrl); + }); + + it('Positive case: After pasting discover/conformance/log/ page, frontend should redirect to corresponding\ + page, not login page', () => { + cy.get('#account').clear().type(`${Cypress.env('user').username}`); + cy.get('#password').clear().type(`${Cypress.env('user').password}`); + cy.get('.btn-lg').click(); + cy.get('form').submit(); + + cy.contains('Conformance Checking Results').should('be.visible'); + }); + + it('Negative case: User who is logged out cannout access inner pages', () => { + cy.get('#account').clear().type(`${Cypress.env('user').username}`); + cy.get('#password').clear().type(`${Cypress.env('user').password}`); + cy.get('.btn-lg').click(); + cy.get('form').submit(); + + cy.get('#logout_btn').click(); + + cy.visit(curUrl); + + cy.contains('Account').should('be.visible'); + cy.contains('Password').should('be.visible'); + cy.contains('Conformance Checking Results').should('not.exist'); + }); + }); }); +}); diff --git a/gamunu.vscode-yarn b/gamunu.vscode-yarn new file mode 160000 index 0000000..6f18600 --- /dev/null +++ b/gamunu.vscode-yarn @@ -0,0 +1 @@ +Subproject commit 6f18600396dfb5aba4e3829453a743f37ba2c0ad diff --git a/src/views/Login/index.vue b/src/views/Login/index.vue index ac4ce78..ba4f267 100644 --- a/src/views/Login/index.vue +++ b/src/views/Login/index.vue @@ -105,7 +105,8 @@ export default { }, created() { // 考慮到使用者可能在未登入的情況下貼入一個頁面網址連結過來瀏覽器 - this.setRememberedReturnToUrl(this.$route.query['return-to']); + // btoa: 對字串進行 Base64 編碼 + this.setRememberedReturnToUrl(btoa(this.$route.query['return-to'])); }, };