Fakultas Ilmu Komputer UI

Commit 43b4bb68 authored by Ryan Karyadiputera's avatar Ryan Karyadiputera
Browse files

test

parent b7fd9fca
Pipeline #73834 failed with stages
in 8 minutes and 16 seconds
......@@ -5,7 +5,10 @@ stages:
- deploy
variables:
DOCKER_HOST: tcp://docker:2375
DOCKER_TLS_CERTDIR: ""
PIP_CACHE_DIR: "$CI_PROJECT_DIR/.cache/pip"
DOCKER_DRIVER: overlay2
image: python:latest
......
# pull official base image
FROM python:3.9.1-alpine
FROM python:3.8
# set work directory
WORKDIR /usr/src/app
ENV PYTHONUNBUFFERED 1
# set environment variables
ENV PYTHONDONTWRITEBYTECODE 1
ENV PYTHONUNBUFFERED 1
# install dependencies
RUN pip install --upgrade pip
COPY ./requirements.txt .
RUN pip install -r requirements.txt
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/
# copy project
COPY . .
# RUN chmod +x docker-entrypoint.sh
CMD [ "gunicorn", "sip.wsgi:application", "--bind", "0.0.0.0:8000" ]
\ No newline at end of file
# ENTRYPOINT [ "/app/docker-entrypoint.sh" ]
......@@ -557,17 +557,11 @@ 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_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_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_profile_can_save_attributes_if_user_mahasiswa_not_yet_registered(self):
# """Test if Profile Mahasiswa model can save the attributes from CAS."""
......
......@@ -5,7 +5,8 @@ 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/', APILogoutView.as_view(), name='logout'),
path('logout/', views.ManualLogoutView.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'),
......@@ -19,5 +20,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,8 +21,10 @@ 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
from django.http import JsonResponse, HttpResponseRedirect
from django.contrib.auth.models import update_last_login
from django.shortcuts import render
from rest_framework import status
from rest_framework.decorators import api_view
......@@ -105,6 +107,14 @@ 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,6 +214,14 @@ 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,6 +60,7 @@ 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
......
......@@ -2,9 +2,3 @@ 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
......@@ -105,13 +105,9 @@ REST_FRAMEWORK = {
# https://docs.djangoproject.com/en/3.0/ref/settings/#databases
DATABASES = {
"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"),
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
}
}
......
......@@ -120,7 +120,7 @@ if os.environ.get('DATABASE_URL') is not None:
# DOMAIN='https://ppl2020a1.cs.ui.ac.id'
# else:
# DOMAIN='http://si-praktikum-backend.herokuapp.com'
# DOMAIN='http://sipraktikum-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.production')
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'sip.settings')
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