Browse Source

Fix drone testing with file uploads

master
Joshua Rubingh 12 months ago
parent
commit
8e586f1e6d
  1. 17
      .drone.yml
  2. 68
      VRE/VRE/settings.py
  3. 3
      VRE/requirements.txt

17
.drone.yml

@ -87,24 +87,24 @@ steps: @@ -87,24 +87,24 @@ steps:
exclude:
- tag
---
kind: pipeline
name: django-tests
type: kubernetes
trigger:
event:
exclude:
- tag
event:
exclude:
- tag
steps:
- name: tests
image: registry.webhosting.rug.nl/${DRONE_REPO,,}:${DRONE_SOURCE_BRANCH/\//-}-${DRONE_COMMIT_SHA:0:8}
environment:
# Make sure you have added a secret in Drone called 'SECRET_KEY' with a valid Django secret key value
SECRET_KEY:
from_secret: SECRET_KEY
# We need an upload path for testing...
MEDIA_ROOT: mediafiles
# And a 'dummy' secret key for testing
SECRET_KEY: w@b=#(f4uc0l%e!5*eo+aoflnxb(@!l9!=c5w=4b+x$=!8&vy%a
commands:
- cd VRE
- python manage.py test apps/api
@ -113,7 +113,6 @@ steps: @@ -113,7 +113,6 @@ steps:
depends_on:
- build-docker-image
---
kind: pipeline
name: notify-pipeline-end
@ -145,4 +144,4 @@ depends_on: @@ -145,4 +144,4 @@ depends_on:
trigger:
status:
- success
- failure
- failure

68
VRE/VRE/settings.py

@ -77,16 +77,19 @@ INSTALLED_APPS = [ @@ -77,16 +77,19 @@ INSTALLED_APPS = [
'hawkrest',
'huey.contrib.djhuey',
'django_extensions',
'corsheaders',
]
if DEBUG:
INSTALLED_APPS.append('debug_toolbar')
MIDDLEWARE = [
'corsheaders.middleware.CorsMiddleware',
'django.middleware.security.SecurityMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
"django.middleware.common.CommonMiddleware",
'django.middleware.csrf.CsrfViewMiddleware',
'corsheaders.middleware.CorsPostCsrfMiddleware',
'hawkrest.middleware.HawkResponseMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
@ -95,7 +98,7 @@ MIDDLEWARE = [ @@ -95,7 +98,7 @@ MIDDLEWARE = [
]
if DEBUG:
MIDDLEWARE = ['debug_toolbar.middleware.DebugToolbarMiddleware', ] + MIDDLEWARE
MIDDLEWARE += ['debug_toolbar.middleware.DebugToolbarMiddleware', ]
ROOT_URLCONF = 'VRE.urls'
@ -171,9 +174,9 @@ STATICFILES_DIRS = [ @@ -171,9 +174,9 @@ STATICFILES_DIRS = [
BASE_DIR / 'static',
]
STATIC_ROOT = config('STATIC_ROOT', None)
STATIC_ROOT = config('STATIC_ROOT', 'staticfiles')
MEDIA_ROOT = config('MEDIA_ROOT', None)
MEDIA_ROOT = config('MEDIA_ROOT', 'mediafiles')
MEDIA_URL = '/media/'
INTERNAL_IPS = config('INTERNAL_IPS', default='127.0.0.1', cast=Csv())
@ -243,26 +246,39 @@ DROPOFF_UPLOAD_HOST = config('DROPOFF_UPLOAD_HOST', default='http://localhost:10 @@ -243,26 +246,39 @@ DROPOFF_UPLOAD_HOST = config('DROPOFF_UPLOAD_HOST', default='http://localhost:10
# Which file extensions are **NOT** allowed to be uploaded. By default the extensions exe,com,bat,lnk,sh are not allowed
DROPOFF_NOT_ALLOWED_EXTENSIONS = config('DROPOFF_NOT_ALLOWED_EXTENSIONS', default='exe,com,bat,lnk,sh', cast=Csv())
# CORS Headers setup
CORS_ALLOWED_ORIGINS = config('CORS_ALLOWED_ORIGINS', default='http://0.0.0.0:8080,http://localhost:8080,http://127.0.0.1:8080', cast=Csv())
# LOGGING = {
# 'version': 1,
# 'disable_existing_loggers': False,
# 'handlers': {
# 'file': {
# 'class': 'logging.FileHandler',
# 'filename': f'{BASE_DIR}/../log/debug.log',
# },
# },
# 'loggers': {
# 'django': {
# 'handlers': ['file'],
# 'level': 'DEBUG' if DEBUG else 'INFO',
# 'propagate': True,
# },
# 'hawkrest': {
# 'handlers': ['file'],
# 'level': 'DEBUG' if DEBUG else 'INFO',
# }
# },
# }
# This will overrule the allowed origins setting above when set to True
CORS_ALLOW_ALL_ORIGINS = config('CORS_ALLOW_ALL_ORIGINS', default=False, cast=bool)
if DEBUG:
# Force all domains by default in Debug mode..
CORS_ALLOW_ALL_ORIGINS = True
CORS_ALLOW_METHODS = config('CORS_ALLOW_METHODS', default='DELETE,GET,OPTIONS,PATCH,POST,PUT', cast=Csv())
CORS_ALLOW_HEADERS = config('CORS_ALLOW_HEADERS', default='accept,accept-encoding,authorization,content-type,dnt,origin,user-agent,x-csrftoken,x-requested-with', cast=Csv())
CORS_EXPOSE_HEADERS = CORS_ALLOW_HEADERS
LOGGING = {
'version': 1,
'disable_existing_loggers': False,
'handlers': {
'file': {
'class': 'logging.FileHandler',
'filename': f'{BASE_DIR}/../log/debug.log',
},
},
'loggers': {
'django': {
'handlers': ['file'],
'level': 'DEBUG' if DEBUG else 'INFO',
'propagate': True,
},
'hawkrest': {
'handlers': ['file'],
'level': 'DEBUG' if DEBUG else 'INFO',
}
},
}

3
VRE/requirements.txt

@ -28,4 +28,5 @@ pygraphviz==1.7 @@ -28,4 +28,5 @@ pygraphviz==1.7
django-debug-toolbar==3.2.2
sentry-sdk==1.4.3
Pillow==8.4.0
drf-extra-fields==3.1.1
drf-extra-fields==3.1.1
django-cors-headers==3.10.0
Loading…
Cancel
Save