diff --git a/.github/workflows/docker-hub-latest.yaml b/.github/workflows/docker-hub-latest.yaml index a1f7f10..64b0738 100644 --- a/.github/workflows/docker-hub-latest.yaml +++ b/.github/workflows/docker-hub-latest.yaml @@ -1,9 +1,5 @@ name: Docker Hub -env: - DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }} - DOCKERHUB_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }} - on: push: branches: @@ -25,8 +21,8 @@ jobs: name: Login to Docker Hub uses: docker/login-action@v3 with: - username: $DOCKERHUB_USERNAME - password: $DOCKERHUB_TOKEN + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} - name: Build and push diff --git a/app/tests/classes.py b/app/tests/classes.py deleted file mode 100644 index 924be72..0000000 --- a/app/tests/classes.py +++ /dev/null @@ -1,86 +0,0 @@ -import datetime -import logging - -from django.test import Client, TestCase -from django.conf import settings - -from ..models.app import App -from ..models.conference import Conference -from ..models.organization import Organization -from ..models.participant import Participant -from ..models.subscription import Subscription -from ..models.user import User -from ..logger import log - -log.setLevel(logging.ERROR) - - -class PMTestCase(TestCase): - def setUp(self): - s = 'a9@a.com' - self.user_password = 'password' - self.user = User( - username=s, - email=s, - billing={}, - notifications={}, - is_verified=True, - ) - self.user.set_password(self.user_password) - self.user.save() - self.create_subscription(self.user) - self.org = Organization( - owner=self.user, - name='test org' - ) - self.org.save() - self.org.members.add(self.user) - - self.app_recording = App( - api_key='recb5da75a944da6a0fed919cc21d13c', - organization=self.org, - name='test app', - recording=True, - ) - self.app_recording.save() - - self.app_not_recording = App( - api_key='nrec5da75a944da6a0fed919cc21d13c', - organization=self.org, - name='test app 2', - recording=False, - ) - self.app_not_recording.save() - - self.participant = Participant( - participant_id='test', - participant_name='test', - app_id=self.app_recording.id - ) - self.participant.save() - - self.conference = Conference( - conference_id='test', - conference_name='test', - app_id=self.app_recording.id - ) - self.conference.save() - self.client = Client() - - @staticmethod - def create_subscription(user): - subscription = Subscription( - user=user, - price=1, - currency='EU', - status='active', - subscription_id='sub_id', - customer_id='cus_id', - current_period_end=datetime.datetime.utcnow(), - current_period_start=datetime.datetime.utcnow(), - plan_id=settings.FREE_PLAN_ID, - current_billing_cycle=1, - first_billing_date=datetime.datetime.utcnow(), - ) - - subscription.save() diff --git a/app/tests/test_signin.py b/app/tests/test_signin.py deleted file mode 100644 index d8cb1e7..0000000 --- a/app/tests/test_signin.py +++ /dev/null @@ -1,140 +0,0 @@ -from django.urls import reverse - -from ..models.user import User -from .classes import PMTestCase - - -class SignInViewTestCase(PMTestCase): - - def test_post_redirect_verify(self): - - s = 'a92@a.com' - user_password = 'password' - user = User( - username=s, - email=s, - billing={}, - notifications={}, - is_verified=False, - ) - user.set_password(user_password) - user.save() - - response = self.client.post( - path='/sign-in', - data={ - 'email': user.email, - 'password': user_password, - 'box-1': 'box-1', - }, - ) - - self.assertRedirects(response, reverse('verify-account')) - self.assertTrue('sessionid' in str(response.cookies)) - self.assertTrue('csrftoken' in str(response.cookies)) - - def test_post_redirect_dashboard(self): - response = self.client.post( - path='/sign-in', - data={ - 'email': self.user.email, - 'password': self.user_password, - 'box-1': 'box-1', - }, - ) - - self.assertRedirects(response, reverse('dashboard')) - self.assertTrue('sessionid' in str(response.cookies)) - self.assertTrue('csrftoken' in str(response.cookies)) - - def test_post_redirect_sign_in(self): - - s = 'a92@a.com' - user_password = 'password' - user = User( - username=s, - email=s, - billing={}, - notifications={}, - is_verified=True, - is_active=False, - ) - user.set_password(user_password) - user.save() - - response = self.client.post( - path='/sign-in', - data={ - 'email': user.email, - 'password': user_password, - 'box-1': 'box-1', - }, - ) - - self.assertRedirects(response, reverse('sign-in')) - - def test_post_redirect_invalid_login(self): - - s = 'a92@a.com' - user_password = 'password' - user = User( - username=s, - email=s, - billing={}, - notifications={}, - is_verified=True, - is_active=False, - ) - user.set_password(user_password) - user.save() - - inputs = [ - { - 'email': user.email, - 'password': 'asdad', - }, - { - 'email': user.email, - 'password': '', - }, - { - 'email': user.email, - }, - { - 'email': 'invalid', - 'password': 'asdad', - }, - { - 'password': '', - }, - { - }, - ] - - for inp in inputs: - - response = self.client.post( - path='/sign-in', - data=inp, - ) - - self.assertEqual(response.status_code, 200) - - def test_post_redirect_already_authenticated(self): - - self.assertTrue(self.client.login(username=self.user.username, password=self.user_password)) - - response = self.client.post( - path='/sign-in', - data={ - 'email': self.user.email, - 'password': self.user_password, - 'box-1': 'box-1', - }, - ) - - self.assertRedirects(response, reverse('dashboard')) - self.client.logout() - - self.assertTrue('sessionid' not in str(response.cookies)) - self.assertTrue('csrftoken' not in str(response.cookies)) diff --git a/app/tests/test_signup.py b/app/tests/test_signup.py deleted file mode 100644 index edccc9a..0000000 --- a/app/tests/test_signup.py +++ /dev/null @@ -1,101 +0,0 @@ -from django.contrib.auth.hashers import check_password -from django.urls import reverse -from django.conf import settings - -from ..models.user import User -from ..models.token import Token -from .classes import PMTestCase - - -class SignInViewTestCase(PMTestCase): - - def test_post_redirect_verify(self): - - email = 'owrfewferwfi@oi.com' - firstname = 'ionf' - lastname = 'ionl' - password = 'ionelele' - - response = self.client.post( - path='/sign-up', - data={ - 'firstname': firstname, - 'lastname': lastname, - 'email': email, - 'password': password, - }, - ) - - self.assertRedirects(response, reverse('verify-account')) - self.assertTrue('sessionid' in str(response.cookies)) - self.assertTrue('csrftoken' in str(response.cookies)) - - user = User.objects.filter(email=email).first() - self.assertEqual(user.first_name, firstname) - self.assertEqual(user.last_name, lastname) - self.assertEqual(user.max_usage, settings.PLANS[settings.FREE_PLAN_ID]['max_usage']) - self.assertTrue(check_password(password, user.password)) - - token = Token.objects.filter(user=user).first() - self.assertEqual(token.usage, Token.VERIFY_EMAIL) - - def test_post_redirect_invalid_form(self): - - email = 'owrfewferwfi@oi.com' - firstname = 'ionf' - lastname = 'ionl' - password = 'ionelele' - - inputs = [ - { - 'email': 'd', - 'firstname': firstname, - 'lastname': lastname, - 'password': password, - }, - { - 'email': email, - 'firstname': firstname, - 'lastname': lastname, - 'password': 'short', - }, - { - 'email': email, - 'firstname': 31 * 'r', - 'lastname': lastname, - 'password': password, - }, - { - 'email': email, - 'firstname': firstname, - 'lastname': 65 * 'r', - 'password': password, - }, - { - 'email': email, - 'firstname': firstname, - 'lastname': lastname, - }, - { - 'email': email, - 'firstname': firstname, - 'password': password, - }, - { - 'email': email, - 'lastname': lastname, - 'password': password, - }, - ] - - for inp in inputs: - - response = self.client.post( - path='/sign-up', - data=inp, - ) - - self.assertEqual(response.status_code, 200) - - user = User.objects.filter(email=inp['email']).first() - self.assertFalse(user)