Fakultas Ilmu Komputer UI

Commit b7fd9fca authored by Ryan Karyadiputera's avatar Ryan Karyadiputera
Browse files

test

parent 9329b5d0
Pipeline #73833 failed with stages
in 6 minutes and 57 seconds
......@@ -2,14 +2,10 @@ stages:
- test
- flake8
- build
# - sonarqube
- deploy
variables:
DOCKER_HOST: tcp://docker:2375
DOCKER_TLS_CERTDIR: ""
PIP_CACHE_DIR: "$CI_PROJECT_DIR/.cache/pip"
DOCKER_DRIVER: overlay2
image: python:latest
......@@ -59,36 +55,6 @@ lint:
except:
- CI-CD
# sonarqube:
# image: nuga99/sonar-scanner-python
# stage: sonarqube
# cache:
# key: sonarqube
# paths:
# - .cache/pip
# before_script:
# - python3 -V
# - pip3 install -r requirements.txt
# - echo "DJANGO_SECRET_KEY=$DJANGO_SECRET_KEY" > sip/settings/.env
# - echo "AWS_ACCESS_KEY_ID=$AWS_ACCESS_KEY_ID" >> sip/settings/.env
# - echo "AWS_SECRET_ACCESS_KEY=$AWS_SECRET_ACCESS_KEY" >> sip/settings/.env
# - echo "AWS_STORAGE_BUCKET_NAME=$AWS_STORAGE_BUCKET_NAME" >> sip/settings/.env
# script:
# - if [[ $CI_COMMIT_REF_NAME == staging ]]; then ENVIRON="sip.settings.staging"; else ENVIRON="sip.settings.dev"; fi
# - coverage run --omit='manage.py,**/venv/*,**/python3*/**,core/**,laporan_praktikum/error_message/**,laporan_praktikum/custom_module/**,authentication/cas_wrapper.py,/usr/**' manage.py test --settings=${ENVIRON}
# - coverage report -m
# - coverage xml -i
# - sonar-scanner
# -Dsonar.host.url=https://pmpl.cs.ui.ac.id/sonarqube
# -Dsonar.projectKey=$SONARQUBE_PROJECT_KEY
# -Dsonar.login=$SONARQUBE_TOKEN
# -Dsonar.branch.name=$CI_COMMIT_REF_NAME
# only:
# - master
# - staging
# - development
# - /^.*PBI-.*$/
heroku-deploy:
image: ruby:2.4
stage: deploy
......
FROM python:3.8
# pull official base image
FROM python:3.9.1-alpine
ENV PYTHONUNBUFFERED 1
# set work directory
WORKDIR /usr/src/app
# set environment variables
ENV PYTHONDONTWRITEBYTECODE 1
ENV PYTHONUNBUFFERED 1
ENV http_proxy=http://proxy.cs.ui.ac.id:8080/
ENV https_proxy=http://proxy.cs.ui.ac.id:8080/
ENV ftp_proxy=http://proxy.cs.ui.ac.id:8080/
RUN mkdir /app
WORKDIR /app
COPY requirements.txt /app/
RUN pip install -r requirements.txt
COPY .env .env.production
COPY . /app/
# install dependencies
RUN pip install --upgrade pip
COPY ./requirements.txt .
RUN pip install -r requirements.txt
# RUN chmod +x docker-entrypoint.sh
# copy project
COPY . .
# ENTRYPOINT [ "/app/docker-entrypoint.sh" ]
CMD [ "gunicorn", "sip.wsgi:application", "--bind", "0.0.0.0:8000" ]
\ No newline at end of file
......@@ -557,11 +557,17 @@ class SSOUITest(TestCase):
supervisor_sekolah=None
)
# def test_login_url_exists(self):
# """Test if login url exists and redirects to CAS server (response code 302)."""
# response = self.client.get(reverse('authentication:login-sivitas'))
# self.assertEqual(response.status_code, 302)
# self.assertTrue(response.url.startswith(settings.CAS_SERVER_URL))
def test_login_url_exists(self):
"""Test if login url exists and redirects to CAS server (response code 302)."""
response = self.client.get(reverse('authentication:login-sivitas'))
self.assertEqual(response.status_code, 302)
self.assertTrue(response.url.startswith(settings.CAS_SERVER_URL))
def test_logout_url_exists(self):
"""Test if logout url exists and redirects to CAS server (response code 302)."""
response = self.client.get(reverse('authentication:logout'))
self.assertEqual(response.status_code, 302)
self.assertTrue(response.url.startswith(settings.CAS_SERVER_URL))
# def test_profile_can_save_attributes_if_user_mahasiswa_not_yet_registered(self):
# """Test if Profile Mahasiswa model can save the attributes from CAS."""
......
......@@ -5,8 +5,7 @@ from django.urls import include, path
app_name = 'authentication'
urlpatterns = [
path('login/sivitas/', APILoginView.as_view(), name='login-sivitas'),
# path('logout/', APILogoutView.as_view(), name='logout'),
path('logout/', views.ManualLogoutView.as_view(), name='logout'),
path('logout/', APILogoutView.as_view(), name='logout'),
path('register/supervisor-lembaga/', views.UserRegistrationView.as_view(), name='register-supervisor-lembaga'),
path('login/supervisor-lembaga/', views.UserLoginView.as_view(), name='login-supervisor-lembaga'),
path('register/supervisor-lembaga/', views.UserRegistrationView.as_view(), name='register-supervisor-lembaga'),
......@@ -20,5 +19,5 @@ urlpatterns = [
path('profile/administrator', views.UserProfileAdministratorView.as_view(), name='profile-administrator'),
path('profile/user', views.UserProfileUserView.as_view(), name='profile-user'),
path('periode/list', views.PeriodeListView.as_view(), name='periode-list'),
path('login/sso/', views.ManualSSOLoginView.as_view(), name='login-sso'),
path('login/sso/', views.ManualSSOLoginView.as_view(), name='login-sso')
]
......@@ -21,10 +21,8 @@ from .serializers import (
AdministratorLoginSerializer
)
from .role import Role
from datetime import datetime
from django.contrib.auth.decorators import login_required
from django.http import JsonResponse, HttpResponseRedirect
from django.contrib.auth.models import update_last_login
from django.http import JsonResponse
from django.shortcuts import render
from rest_framework import status
from rest_framework.decorators import api_view
......@@ -107,14 +105,6 @@ class ManualSSOLoginView(RetrieveAPIView):
return Response(response, status=status.HTTP_200_OK)
class ManualLogoutView(RetrieveAPIView):
permission_classes = (AllowAny,)
def get(self, request):
update_last_login(datetime.now(), request.user)
return HttpResponseRedirect("http://sipraktikum-frontend-2020-a.herokuapp.com")
class UserProfileMahasiswaView(RetrieveAPIView): # pragma: no cover
permission_classes = (IsAuthenticated,)
......
......@@ -214,14 +214,6 @@ def get_list_laporan_praktikum_detail(request):
response_field[1]: status_code,
response_field[2]: error_message_404_praktikum
}
except TemplateBorangPenilaianPraktikum.DoesNotExist:
status_code = status.HTTP_404_NOT_FOUND
response = {
response_field[0]: 'False',
response_field[1]: status_code,
response_field[2]: "Your Supervisor Sekolah hasn't been uploaded the Template Borang"
}
return Response(response, status=status_code)
......
......@@ -60,7 +60,6 @@ pdfkit==0.6.1
Pillow==8.0.1
pipenv==2018.11.26
pluggy==0.13.1
psycopg2==2.8.6
psycopg2-binary==2.8.6
py==1.8.1
pycodestyle==2.6.0
......
DJANGO_SECRET_KEY="s3cr3t_k3y_c4nn0t_h4ck3d_by_l33t_1337"
\ No newline at end of file
......@@ -2,3 +2,9 @@ DJANGO_SECRET_KEY
AWS_ACCESS_KEY_ID
AWS_SECRET_ACCESS_KEY
AWS_STORAGE_BUCKET_NAME
SQL_ENGINE
SQL_DATABASE
SQL_USER
SQL_PASSWORD
SQL_HOST
SQL_PORT
\ No newline at end of file
DJANGO_SECRET_KEY
AWS_ACCESS_KEY_ID
AWS_SECRET_ACCESS_KEY
AWS_STORAGE_BUCKET_NAME
SQL_ENGINE
SQL_DATABASE
SQL_USER
SQL_PASSWORD
SQL_HOST
SQL_PORT
\ No newline at end of file
DJANGO_SECRET_KEY="s3cr3t_k3y_c4nn0t_h4ck3d_by_l33t_1337"
AWS_ACCESS_KEY_ID="AKIAZQWXBKG5M6KKHZSP"
AWS_SECRET_ACCESS_KEY="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"
AWS_STORAGE_BUCKET_NAME="sipraktikum-storage"
\ No newline at end of file
......@@ -105,9 +105,13 @@ REST_FRAMEWORK = {
# https://docs.djangoproject.com/en/3.0/ref/settings/#databases
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
"default": {
"ENGINE": env("SQL_ENGINE"),
"NAME": env("SQL_DATABASE"),
"USER": env("SQL_USER"),
"PASSWORD": env("SQL_PASSWORD"),
"HOST": env("SQL_HOST"),
"PORT": env("SQL_PORT"),
}
}
......
......@@ -120,7 +120,7 @@ if os.environ.get('DATABASE_URL') is not None:
# DOMAIN='https://ppl2020a1.cs.ui.ac.id'
# else:
# DOMAIN='http://sipraktikum-backend.herokuapp.com'
# DOMAIN='http://si-praktikum-backend.herokuapp.com'
# Password validation
......
......@@ -11,6 +11,6 @@ import os
from django.core.wsgi import get_wsgi_application
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'sip.settings')
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'sip.settings.production')
application = get_wsgi_application()
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment