Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Helios Server
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
TO
Helios Server
Commits
25e90ffc
Commit
25e90ffc
authored
14 years ago
by
Ben Adida
Browse files
Options
Downloads
Patches
Plain Diff
fixed edit election and added corresponding test
parent
f3cb8782
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
helios/tests.py
+34
-10
34 additions, 10 deletions
helios/tests.py
helios/views.py
+2
-1
2 additions, 1 deletion
helios/views.py
with
36 additions
and
11 deletions
helios/tests.py
+
34
−
10
View file @
25e90ffc
...
...
@@ -326,6 +326,17 @@ class ElectionBlackboxTests(TestCase):
self
.
election
=
models
.
Election
.
objects
.
all
()[
0
]
self
.
user
=
auth_models
.
User
.
objects
.
get
(
user_id
=
'
ben@adida.net
'
,
user_type
=
'
google
'
)
def
setup_login
(
self
):
# set up the session
session
=
self
.
client
.
session
session
[
'
user
'
]
=
{
'
type
'
:
self
.
user
.
user_type
,
'
user_id
'
:
self
.
user
.
user_id
}
session
.
save
()
def
clear_login
(
self
):
session
=
self
.
client
.
session
del
session
[
'
user
'
]
session
.
save
()
def
test_get_election_shortcut
(
self
):
response
=
self
.
client
.
get
(
"
/helios/e/%s
"
%
self
.
election
.
short_name
,
follow
=
True
)
self
.
assertContains
(
response
,
self
.
election
.
description
)
...
...
@@ -372,14 +383,31 @@ class ElectionBlackboxTests(TestCase):
self
.
assertRedirects
(
response
,
"
/auth/?return_url=/helios/elections/new
"
)
def
test_election_edit
(
self
):
# a bogus call to set up the session
self
.
client
.
get
(
"
/
"
)
self
.
setup_login
()
response
=
self
.
client
.
get
(
"
/helios/elections/%s/edit
"
%
self
.
election
.
uuid
)
response
=
self
.
client
.
post
(
"
/helios/elections/%s/edit
"
%
self
.
election
.
uuid
,
{
"
short_name
"
:
self
.
election
.
short_name
+
"
-2
"
,
"
name
"
:
self
.
election
.
name
,
"
description
"
:
self
.
election
.
description
,
"
election_type
"
:
self
.
election
.
election_type
,
"
use_voter_aliases
"
:
self
.
election
.
use_voter_aliases
,
'
csrf_token
'
:
self
.
client
.
session
[
'
csrf_token
'
]
})
self
.
assertRedirects
(
response
,
"
/helios/elections/%s/view
"
%
self
.
election
.
uuid
)
new_election
=
models
.
Election
.
objects
.
get
(
uuid
=
self
.
election
.
uuid
)
self
.
assertEquals
(
new_election
.
short_name
,
self
.
election
.
short_name
+
"
-2
"
)
def
test_do_complete_election
(
self
):
# a bogus call to set up the session
self
.
client
.
get
(
"
/
"
)
# set up the session
session
=
self
.
client
.
session
session
[
'
user
'
]
=
{
'
type
'
:
self
.
user
.
user_type
,
'
user_id
'
:
self
.
user
.
user_id
}
session
.
save
()
self
.
setup_login
()
# create the election
response
=
self
.
client
.
post
(
"
/helios/elections/new
"
,
{
...
...
@@ -452,9 +480,7 @@ class ElectionBlackboxTests(TestCase):
password
=
re
.
search
(
'
password: (.*)
'
,
email_message
.
body
).
group
(
1
)
# now log out as administrator
session
=
self
.
client
.
session
del
session
[
'
user
'
]
session
.
save
()
self
.
clear_login
()
self
.
assertEquals
(
self
.
client
.
session
.
has_key
(
'
user
'
),
False
)
# vote by preparing a ballot via the server-side encryption
...
...
@@ -499,9 +525,7 @@ class ElectionBlackboxTests(TestCase):
assert
not
self
.
client
.
session
.
has_key
(
'
CURRENT_VOTER
'
)
# log back in as administrator
session
=
self
.
client
.
session
session
[
'
user
'
]
=
{
'
type
'
:
self
.
user
.
user_type
,
'
user_id
'
:
self
.
user
.
user_id
}
session
.
save
()
self
.
setup_login
()
# encrypted tally
response
=
self
.
client
.
post
(
"
/helios/elections/%s/compute_tally
"
%
election_id
,
{
...
...
This diff is collapsed.
Click to expand it.
helios/views.py
+
2
−
1
View file @
25e90ffc
...
...
@@ -216,7 +216,8 @@ def election_new(request):
def
one_election_edit
(
request
,
election
):
error
=
None
RELEVANT_FIELDS
=
[
'
short_name
'
,
'
name
'
,
'
description
'
,
'
use_voter_aliases
'
,
'
election_type
'
,
'
advanced_audit_features
'
,
'
private_p
'
]
RELEVANT_FIELDS
=
[
'
short_name
'
,
'
name
'
,
'
description
'
,
'
use_voter_aliases
'
,
'
election_type
'
]
# RELEVANT_FIELDS += ['use_advanced_audit_features', 'private_p']
if
request
.
method
==
"
GET
"
:
values
=
{}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment