diff --git a/bitbucket-pipelines.yml b/bitbucket-pipelines.yml index a2710d35..a15c2238 100644 --- a/bitbucket-pipelines.yml +++ b/bitbucket-pipelines.yml @@ -30,9 +30,12 @@ pipelines: - pip - cypress script: + - export IT_SERVE_VUE=false + - export IT_ALLOW_LOCAL_LOGIN=true - source ./env/bitbucket/prepare_for_test.sh - pip install -r server/requirements/requirements-dev.txt - npm install + - npm run build - ./prepare_server_cypress.sh --start-background - npm run cypress:ci # - npm run build diff --git a/client/src/main.ts b/client/src/main.ts index 0474017f..4361e384 100644 --- a/client/src/main.ts +++ b/client/src/main.ts @@ -1,13 +1,13 @@ import {createApp} from 'vue' import {createPinia} from 'pinia' -import {setupI18n} from './i18n' +// import {setupI18n} from './i18n' import App from './App.vue' import router from './router' import '../tailwind.css' -const i18n = setupI18n() +// const i18n = setupI18n() const app = createApp(App) // todo: define lang setup @@ -15,6 +15,6 @@ const app = createApp(App) app.use(createPinia()) app.use(router) -app.use(i18n) +// app.use(i18n) app.mount('#app') diff --git a/cypress.config.js b/cypress.config.js index f0e2baa4..64b1a5f4 100644 --- a/cypress.config.js +++ b/cypress.config.js @@ -13,7 +13,7 @@ module.exports = defineConfig({ toConsole: true, }, e2e: { - experimentalSessionAndOrigin: true, + // experimentalSessionAndOrigin: true, // We've imported your old cypress plugins here. // You may want to clean this up later by importing these. setupNodeEvents(on, config) { diff --git a/cypress/support/commands.js b/cypress/support/commands.js index 9706678f..2793a069 100644 --- a/cypress/support/commands.js +++ b/cypress/support/commands.js @@ -55,7 +55,14 @@ const _ = Cypress._; Cypress.Commands.add('manageCommand', (command, preCommand = '') => { const execCommand = `${preCommand} python server/manage.py ${command} --settings=config.settings.test_cypress`; console.log(execCommand); - return cy.exec(execCommand); + return cy.exec(execCommand, { failOnNonZeroExit: false }).then(result => { + if(result.code) { + throw new Error(`Execution of "${command}" failed + Exit code: ${result.code} + Stdout:\n${result.stdout} + Stderr:\n${result.stderr}`); + } + }); }); Cypress.Commands.add('manageShellCommand', (command) => { diff --git a/server/config/settings/test.py b/server/config/settings/test.py index bb7e88fc..b1d2b21a 100644 --- a/server/config/settings/test.py +++ b/server/config/settings/test.py @@ -4,7 +4,6 @@ import os os.environ['IT_APP_ENVIRONMENT'] = 'development' from .base import * # noqa -from .base import env # https://docs.djangoproject.com/en/dev/ref/settings/#test-runner TEST_RUNNER = "django.test.runner.DiscoverRunner" diff --git a/server/config/settings/test_cypress.py b/server/config/settings/test_cypress.py index 5f4c706a..339a15d8 100644 --- a/server/config/settings/test_cypress.py +++ b/server/config/settings/test_cypress.py @@ -1,4 +1,7 @@ # pylint: disable=unused-wildcard-import,wildcard-import,wrong-import-position +import os + +os.environ['IT_APP_ENVIRONMENT'] = 'development' from .base import * # noqa diff --git a/server/config/urls.py b/server/config/urls.py index c40bb6d3..3664a946 100644 --- a/server/config/urls.py +++ b/server/config/urls.py @@ -41,18 +41,14 @@ urlpatterns = [ path('learnpath/', include("vbv_lernwelt.learnpath.urls")), path('api/completion/', include("vbv_lernwelt.completion.urls")), re_path(r'api/core/me/$', me_user_view, name='me_user_view'), + re_path(r'core/login/$', django_view_authentication_exempt(vue_login), name='vue_login'), re_path(r'core/logout/$', vue_logout, name='vue_logout'), ] + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT) + if settings.DEBUG: # Static file serving when using Gunicorn + Uvicorn for local web socket development urlpatterns += staticfiles_urlpatterns() -if settings.ALLOW_LOCAL_LOGIN: - urlpatterns += [ - re_path(r'core/login/$', django_view_authentication_exempt(vue_login), name='vue_login'), - ] - - # API URLS urlpatterns += [ # API base url @@ -112,4 +108,3 @@ if settings.DEBUG: # serve everything else via the vue app urlpatterns += [re_path(r'^.*$', vue_home, name='home')] - diff --git a/server/vbv_lernwelt/core/views.py b/server/vbv_lernwelt/core/views.py index 8546d91f..7fbaf728 100644 --- a/server/vbv_lernwelt/core/views.py +++ b/server/vbv_lernwelt/core/views.py @@ -48,20 +48,23 @@ def vue_home(request): @api_view(['POST']) @ensure_csrf_cookie def vue_login(request): - try: - username = request.data.get('username') - password = request.data.get('password') - if username and password: - user = authenticate(request, username=username, password=password) - if user: - login(request, user) - logger.debug('login successful', username=username, email=user.email, label='login') - return Response(UserSerializer(user).data) - except Exception as e: - logger.exception(e) + if settings.ALLOW_LOCAL_LOGIN: + try: + username = request.data.get('username') + password = request.data.get('password') + if username and password: + user = authenticate(request, username=username, password=password) + if user: + login(request, user) + logger.debug('login successful', username=username, email=user.email, label='login') + return Response(UserSerializer(user).data) + except Exception as e: + logger.exception(e) - logger.debug('login failed', username=username, label='login') - return Response({'success': False}, status=401) + logger.debug('login failed', username=username, label='login') + return Response({'success': False}, status=401) + else: + return Response({'success': False, 'message': 'ALLOW_LOCAL_LOGIN=false'}, status=403) @api_view(['GET'])