diff --git a/client/cypress/integration/e2e/email-verification.spec.js b/client/cypress/integration/e2e/email-verification.spec.js deleted file mode 100644 index 257b940f..00000000 --- a/client/cypress/integration/e2e/email-verification.spec.js +++ /dev/null @@ -1,89 +0,0 @@ -const schema = require('../../fixtures/schema_public.json'); - -describe('Email Verifcation', () => { - beforeEach(() => { - cy.server(); - }); - - it('forwards to homepage if confirmation key is correct', () => { - cy.viewport('macbook-15'); - cy.mockGraphql({ - schema: schema, - operations: { - Registration: { - registration: { - message: 'success', - success: true - } - }, - } - }); - - cy.visit('/verify-email?confirmation=abcd1234&id=12'); - - // user should be logged in at that stage. As the cookie cannot be set at the right time - // we just check if the user gets redirected to the login page as we can't log her in - cy.url().should('include', 'hello?redirect=%2F'); - }); - - it('displays error if key is incorrect', () => { - cy.viewport('macbook-15'); - cy.mockGraphql({ - schema: schema, - // endpoint: '/api/graphql' - operations: { - Registration: { - registration: { - message: 'invalid_key', - success: false - } - }, - } - }); - - cy.visit('/verify-email?confirmation=abcd1234&id=12'); - cy.get('[data-cy="code-nok-msg"]').contains('Der angegebene Verifizierungscode ist ungültig oder abgelaufen.'); - cy.get('[data-cy="code-ok-msg"]').should('not.exist'); - }); - - it('displays error if an error occured', () => { - cy.viewport('macbook-15'); - cy.mockGraphql({ - schema: schema, - // endpoint: '/api/graphql' - operations: { - Registration: { - registration: { - message: 'unkown_error', - success: false - } - }, - } - }); - - cy.visit('/verify-email?confirmation=abcd1234&id=12'); - cy.get('[data-cy="code-nok-msg"]').contains('Ein Fehler ist aufgetreten. Bitte kontaktieren Sie den Administrator.'); - }); - - it('forwards to coupon page if user has no valid license', () => { - cy.viewport('macbook-15'); - cy.mockGraphql({ - schema: schema, - // endpoint: '/api/graphql' - operations: { - Registration: { - registration: { - message: 'no_valid_license', - success: false - } - }, - } - }); - - cy.visit('/verify-email?confirmation=abcd1234&id=12'); - - // user should be logged in at that stage. As the cookie cannot be set at the right time - // we just check if the user gets redirected to the coupon page as we can't log her in - cy.url().should('include', 'hello?redirect=%2Flicense-activation'); - }); -}); diff --git a/client/cypress/integration/e2e/registration.spec.js b/client/cypress/integration/e2e/registration.spec.js deleted file mode 100644 index b9f89ae1..00000000 --- a/client/cypress/integration/e2e/registration.spec.js +++ /dev/null @@ -1,164 +0,0 @@ -const isEmailAvailableUrl = 'https://stage.hep-verlag.ch/rest/deutsch/V1/customers/isEmailAvailable'; -const registerUrl = '/api/proxy/registration/'; - -let registrationResponse = { - id: 84215, - group_id: 1, - confirmation: "91cf39007547feae7e33778d89fc71db", - created_at: "2020-02-06 13:56:54", - updated_at: "2020-02-06 13:56:54", - created_in: "hep verlag", - email: "feuz@aebi.ch", - firstname: "Kari", - lastname: "Feuz", - prefix: "Herr", - gender: 1, - store_id: 1, - website_id: 1, - addresses: [] -}; - -describe('Registration', () => { - beforeEach(() => { - cy.viewport('macbook-15'); - cy.server(); - }); - - // it('works with valid data', () => { - // cy.route('POST', isEmailAvailableUrl, "true"); - // cy.route('POST', registerUrl, registrationResponse); - - // cy.visit('/hello'); - // cy.checkEmailAvailable(registrationResponse.email); - - // cy.get('[data-cy="registration-title"]').contains('Damit Sie mySkillbox verwenden können, müssen Sie ein Konto erstellen.'); - // cy.register(registrationResponse.gender, registrationResponse.firstname, registrationResponse.lastname, 'Weg 1', 'Bern', '3001', 'Abcd1234!', 'Abcd1234!', true); - // cy.get('[data-cy="email-check"]').contains('Eine Email ist auf dem Weg, bitte überprüfen sie ihre E-mail Konto.'); - // }); - - it('displays error if firstname is missing', () => { - cy.route('POST', isEmailAvailableUrl, "true"); - cy.route('POST', registerUrl, registrationResponse); - - cy.visit('/hello'); - cy.checkEmailAvailable(registrationResponse.email); - - cy.get('[data-cy="registration-title"]').contains('Damit Sie mySkillbox verwenden können, müssen Sie ein Konto erstellen.'); - cy.register(registrationResponse.gender, '', registrationResponse.lastname, 'Weg 1', 'Bern', '3001', 'Abcd1234!', 'Abcd1234!', true); - cy.get('[data-cy="firstname-local-errors"]').contains('Vorname ist ein Pflichtfeld'); - }); - - it('displays error if lastname is missing', () => { - cy.route('POST', isEmailAvailableUrl, "true"); - cy.route('POST', registerUrl, registrationResponse); - - cy.visit('/hello'); - cy.checkEmailAvailable(registrationResponse.email); - - cy.get('[data-cy="registration-title"]').contains('Damit Sie mySkillbox verwenden können, müssen Sie ein Konto erstellen.'); - cy.register(registrationResponse.gender, registrationResponse.firstname, '', 'Weg 1', 'Bern', '3001', 'Abcd1234!', 'Abcd1234!', true); - cy.get('[data-cy="lastname-local-errors"]').contains('Nachname ist ein Pflichtfeld'); - }); - - it('displays error if street is missing', () => { - cy.route('POST', isEmailAvailableUrl, 'true'); - cy.route('POST', registerUrl, registrationResponse); - - cy.visit('/hello'); - cy.checkEmailAvailable(registrationResponse.email); - - cy.get('[data-cy="registration-title"]').contains('Damit Sie mySkillbox verwenden können, müssen Sie ein Konto erstellen.'); - cy.register(registrationResponse.gender, registrationResponse.firstname, registrationResponse.lastname, '', 'Bern', '3001', 'Abcd1234!', 'Abcd1234!', true); - cy.get('[data-cy="street-local-errors"]').contains('Strasse ist ein Pflichtfeld'); - }); - - it('displays error if city is missing', () => { - cy.route('POST', isEmailAvailableUrl, 'true'); - cy.route('POST', registerUrl, registrationResponse); - - cy.visit('/hello'); - cy.checkEmailAvailable(registrationResponse.email); - - cy.get('[data-cy="registration-title"]').contains('Damit Sie mySkillbox verwenden können, müssen Sie ein Konto erstellen.'); - cy.register(registrationResponse.gender, registrationResponse.firstname, registrationResponse.lastname, 'Weg 1', '', '3001', 'Abcd1234!', 'Abcd1234!', true); - cy.get('[data-cy="city-local-errors"]').contains('Ort ist ein Pflichtfeld'); - }); - - it('displays error if postcode is missing', () => { - cy.route('POST', isEmailAvailableUrl, 'true'); - cy.route('POST', registerUrl, registrationResponse); - - cy.visit('/hello'); - cy.checkEmailAvailable(registrationResponse.email); - - cy.get('[data-cy="registration-title"]').contains('Damit Sie mySkillbox verwenden können, müssen Sie ein Konto erstellen.'); - cy.register(registrationResponse.gender, registrationResponse.firstname, registrationResponse.lastname, 'Weg 1', 'Bern', '', 'Abcd1234!', 'Abcd1234!', true); - cy.get('[data-cy="postcode-local-errors"]').contains('Postleitzahl ist ein Pflichtfeld'); - }); - - it('displays error if password is missing', () => { - cy.route('POST', isEmailAvailableUrl, "true"); - cy.route('POST', registerUrl, registrationResponse); - - cy.visit('/hello'); - cy.checkEmailAvailable(registrationResponse.email); - - cy.get('[data-cy="registration-title"]').contains('Damit Sie mySkillbox verwenden können, müssen Sie ein Konto erstellen.'); - cy.register(registrationResponse.gender, registrationResponse.firstname, registrationResponse.lastname, 'Weg 1', 'Bern', '3001', '', 'Abcd1234!', true); - cy.get('[data-cy="password-local-errors"]').contains('Passwort ist ein Pflichtfeld'); - }); - - it('displays error if passwords are not secure', () => { - cy.route('POST', isEmailAvailableUrl, "true"); - cy.route('POST', registerUrl, registrationResponse); - - cy.visit('/hello'); - cy.checkEmailAvailable(registrationResponse.email); - - cy.get('[data-cy="registration-title"]').contains('Damit Sie mySkillbox verwenden können, müssen Sie ein Konto erstellen.'); - cy.register(registrationResponse.gender, registrationResponse.firstname, registrationResponse.lastname, 'Weg 1', 'Bern', '3001', 'Abcd1234', 'Abcd1234', true); - cy.get('[data-cy="password-local-errors"]').contains('Das Passwort muss Grossbuchstaben, Zahlen und Sonderzeichen beinhalten und mindestens 8 Zeichen lang sein'); - }); - - it('displays error if passwords are too short', () => { - cy.route('POST', isEmailAvailableUrl, "true"); - cy.route('POST', registerUrl, registrationResponse); - - cy.visit('/hello'); - cy.checkEmailAvailable(registrationResponse.email); - - cy.get('[data-cy="registration-title"]').contains('Damit Sie mySkillbox verwenden können, müssen Sie ein Konto erstellen.'); - cy.register(registrationResponse.gender, registrationResponse.firstname, registrationResponse.lastname, 'Weg 1', 'Bern', '3001', 'Abcd12!', 'Abcd12!', true); - cy.get('[data-cy="password-local-errors"]').contains('Das Passwort muss Grossbuchstaben, Zahlen und Sonderzeichen beinhalten und mindestens 8 Zeichen lang sein'); - }); - - it('displays error if passwords are not matching', () => { - cy.route('POST', isEmailAvailableUrl, "true"); - cy.route('POST', registerUrl, registrationResponse); - - cy.visit('/hello'); - cy.checkEmailAvailable(registrationResponse.email); - - cy.get('[data-cy="registration-title"]').contains('Damit Sie mySkillbox verwenden können, müssen Sie ein Konto erstellen.'); - cy.register(registrationResponse.gender, registrationResponse.firstname, registrationResponse.lastname, 'Weg 1', 'Bern', '3001', 'Abcd1234!', 'Abcd129999!', true); - cy.get('[data-cy="passwordConfirmation-local-errors"]').contains('Die Bestätigung von Passwort wiederholen stimmt nicht überein'); - }); - - it('displays error if terms are not accepted', () => { - cy.route('POST', isEmailAvailableUrl, "true"); - cy.route('POST', registerUrl, registrationResponse); - - cy.visit('/hello'); - cy.checkEmailAvailable(registrationResponse.email); - - cy.get('[data-cy="registration-title"]').contains('Damit Sie mySkillbox verwenden können, müssen Sie ein Konto erstellen.'); - cy.register(registrationResponse.gender, registrationResponse.firstname, registrationResponse.lastname, 'Weg 1', 'Bern', '3001', 'Abcd1234!', 'Abcd1234!', false); - cy.get('[data-cy="acceptedTerms-local-errors"]').contains('Sie müssen hier zustimmen, damit Sie sich registrieren können.'); - }); - - it('redirects to hello if email is missing', () => { - cy.visit('/register'); - cy.get('[data-cy="hello-title"]').contains('Wollen Sie mySkillbox jetzt im Unterricht verwenden?'); - }); - -}); diff --git a/client/cypress/integration/e2e/users/login.spec.js b/client/cypress/integration/e2e/users/login.spec.js deleted file mode 100644 index 678852fc..00000000 --- a/client/cypress/integration/e2e/users/login.spec.js +++ /dev/null @@ -1,73 +0,0 @@ -const schema = require('../../../fixtures/schema_public.json'); -const isEmailAvailableUrl = '**/rest/deutsch/V1/customers/isEmailAvailable'; -const checkPasswordUrl = '**/rest/deutsch/V1/integration/customer/token'; - -describe('Login', () => { - beforeEach(() => { - cy.server(); - }); - - it('works with valid email and password', () => { - cy.viewport('macbook-15'); - - cy.mockGraphql({ - schema: schema, - operations: { - Login: variables => { - return { - login: { - errors: [], - message: 'success', - success: true - } - }; - }, - } - }); - - cy.route('POST', isEmailAvailableUrl, 'false'); - cy.route({ - method: 'POST', - url: checkPasswordUrl, - response: 'token12345ABCD+', - }); - - cy.visit('/hello'); - cy.checkEmailAvailable('feuz@aebi.ch'); - - cy.get('[data-cy="login-title"]').contains('Bitte geben Sie das passende Passwort ein'); - cy.enterPassword('abcd1234'); - // As we cannot set the cookie in the right manner, we just check for the absence of errors. - // In real world the user gets redirect to another page - cy.get('[data-cy="email-local-errors"]').should('not.exist'); - }); - - it('displays error message if password is wrong', () => { - cy.viewport('macbook-15'); - cy.route('POST', isEmailAvailableUrl, 'false'); - cy.route({ - method: 'POST', - status: 401, - response: { - message: 'Sie haben sich nicht korrekt eingeloggt oder Ihr Konto ist vor\u00fcbergehend deaktiviert.' - }, - url: checkPasswordUrl - }); - - cy.visit('/hello'); - - cy.checkEmailAvailable('feuz@aebi.ch'); - cy.get('[data-cy="login-title"]').contains('Bitte geben Sie das passende Passwort ein'); - - cy.enterPassword('abcd1234'); - cy.get('[data-cy="password-errors"]').contains('Die von Ihnen eingegebene E-Mail-Adresse und das Passwort passen nicht zusammen.'); - }); - - it('displays error message if input is not an email address', () => { - cy.viewport('macbook-15'); - cy.visit('/hello'); - - cy.checkEmailAvailable('feuzaebi.ch'); - cy.get('[data-cy="email-local-errors"]').contains('Bitte geben Sie eine gülitge E-Mail an'); - }); -}); diff --git a/server/oauth/tests/__init__.py b/server/oauth/tests/__init__.py new file mode 100644 index 00000000..e69de29b