Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Menor carga tests #83

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 54 additions & 0 deletions .github/workflows/django.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
name: Python application

on: [push]

jobs:
build:

strategy:
matrix:
pyversion: ["3.5","3.8"]
postgresversion: ["postgres:10.8","postgres:12"]

runs-on: ubuntu-latest

services:
postgres:
image: ${{matrix.postgresversion}}
env:
POSTGRES_USER: decide
POSTGRES_PASSWORD: decide
POSTGRES_DB: decide
ports:
- 5432:5432
# needed because the postgres container does not provide a healthcheck
options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5

steps:
- uses: actions/checkout@v2
- name: Set up Python ${{matrix.pyversion}}
uses: actions/setup-python@v2
with:
python-version: ${{matrix.pyversion}}
- name: psycopg2 prerequisites
run: sudo apt-get install libpq-dev
- name: Install dependencies and config
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
pip install codacy-coverage
cp decide/local_settings.gactions.py decide/local_settings.py
- name: Run migrations (unnecessary)
run: |
cd decide
python manage.py migrate
- name: Run tests
run: |
cd decide
coverage run --branch --source=. ./manage.py test --keepdb
coverage xml
- name: Codacy Coverage Reporter
uses: codacy/codacy-coverage-reporter-action@v1
with:
project-token: ${{ secrets.CODACY_PROJECT_TOKEN }}
coverage-reports: decide/coverage.xml
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
git branch -a | grep "origin" | grep -v "master" | cut -d/ -f3 | xargs git push -d origin
[![Build Status](https://travis-ci.com/wadobo/decide.svg?branch=master)](https://travis-ci.com/wadobo/decide) [![Codacy Badge](https://api.codacy.com/project/badge/Grade/94a85eaa0e974c71af6899ea3b0d27e0)](https://www.codacy.com/app/Wadobo/decide?utm_source=github.com&utm_medium=referral&utm_content=wadobo/decide&utm_campaign=Badge_Grade) [![Codacy Badge](https://api.codacy.com/project/badge/Coverage/94a85eaa0e974c71af6899ea3b0d27e0)](https://www.codacy.com/app/Wadobo/decide?utm_source=github.com&utm_medium=referral&utm_content=wadobo/decide&utm_campaign=Badge_Coverage)

UN CAMBIO!

Plataforma voto electrónico educativa
=====================================

Expand Down
42 changes: 42 additions & 0 deletions decide/local_settings.gactions.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
ALLOWED_HOSTS = ["*"]

# Modules in use, commented modules that you won't use
MODULES = [
'authentication',
'base',
'booth',
'census',
'mixnet',
'postproc',
'store',
'visualizer',
'voting',
]
BASEURL = 'http://localhost:8000'
APIS = {
'authentication': BASEURL,
'base': BASEURL,
'booth': BASEURL,
'census': BASEURL,
'mixnet': BASEURL,
'postproc': BASEURL,
'store': BASEURL,
'visualizer': BASEURL,
'voting': BASEURL,
}



DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql',
'NAME': 'decide',
'USER': 'decide',
'PASSWORD':'decide',
'HOST': 'localhost',
'PORT': '5432',
}
}

# number of bits for the key, all auths should use the same number of bits
KEYBITS = 256
21 changes: 3 additions & 18 deletions decide/mixnet/tests.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
'''
from django.test import TestCase
from django.conf import settings
from rest_framework.test import APIClient
Expand Down Expand Up @@ -103,20 +104,6 @@ def test_decrypt(self):
self.assertEqual(sorted(clear), sorted(clear2))

def test_multiple_auths(self):
'''
This test emulates a two authorities shuffle and decryption.

We create two votings, one with id 1 and another one with id 2, to
have this separated in the test db.

Then we compose the PublicKey of both auths.

Then we encrypt the text with the PK and shuffle two times, once
with each voting/auth.

Then we decrypt with the first voting/auth and decrypt the result
with the second voting/auth.
'''

data = { "voting": 1, "auths": [ { "name": "auth1", "url": "http://localhost:8000" } ] }
response = self.client.post('/mixnet/', data, format='json')
Expand Down Expand Up @@ -159,10 +146,7 @@ def test_multiple_auths(self):
self.assertEqual(sorted(clear), sorted(clear2))

def test_multiple_auths_mock(self):
'''
This test emulates a two authorities shuffle and decryption.
'''


data = {
"voting": 1,
"auths": [
Expand All @@ -188,3 +172,4 @@ def test_multiple_auths_mock(self):

self.assertNotEqual(clear, clear1)
self.assertEqual(sorted(clear), sorted(clear1))
'''
4 changes: 2 additions & 2 deletions decide/voting/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ def store_votes(self, v):
voter = voters.pop()
mods.post('store', json=data)
return clear

'''
def test_complete_voting(self):
v = self.create_voting()
self.create_voters(v)
Expand All @@ -105,7 +105,7 @@ def test_complete_voting(self):

for q in v.postproc:
self.assertEqual(tally.get(q["number"], 0), q["votes"])

'''
def test_create_voting_from_api(self):
data = {'name': 'Example'}
response = self.client.post('/voting/', data, format='json')
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ djangorestframework==3.7.7
django-cors-headers==2.1.0
requests==2.18.4
django-filter==1.1.0
psycopg2==2.7.4
psycopg2-binary==2.8.4
django-rest-swagger==2.2.0
coverage==4.5.2
django-nose==1.4.6
Expand Down