Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Debian New Member Process
nm.debian.org
Commits
92e3d4d8
Commit
92e3d4d8
authored
Jun 02, 2016
by
Enrico Zini
Browse files
process_req_* tests pass
parent
ccc933a2
Changes
5
Expand all
Hide whitespace changes
Inline
Side-by-side
backend/unittest.py
View file @
92e3d4d8
...
@@ -219,9 +219,10 @@ class BaseFixtureMixin(TestBase):
...
@@ -219,9 +219,10 @@ class BaseFixtureMixin(TestBase):
cls
.
fingerprints
=
NamedObjects
(
Fingerprint
)
cls
.
fingerprints
=
NamedObjects
(
Fingerprint
)
cls
.
keys
=
TestKeys
()
cls
.
keys
=
TestKeys
()
# Preload
two
keys
# Preload keys
cls
.
keys
.
create
(
"66B4DFB68CB24EBBD8650BC4F4B4B0CC797EBFAB"
)
cls
.
keys
.
create
(
"66B4DFB68CB24EBBD8650BC4F4B4B0CC797EBFAB"
)
cls
.
keys
.
create
(
"1793D6AB75663E6BF104953A634F4BD1E7AD5568"
)
cls
.
keys
.
create
(
"1793D6AB75663E6BF104953A634F4BD1E7AD5568"
)
cls
.
keys
.
create
(
"0EED77DC41D760FDE44035FF5556A34E04A3610B"
)
@
classmethod
@
classmethod
def
tearDownClass
(
cls
):
def
tearDownClass
(
cls
):
...
...
process/models.py
View file @
92e3d4d8
...
@@ -69,7 +69,8 @@ class RequirementVisitorPermissions(ProcessVisitorPermissions):
...
@@ -69,7 +69,8 @@ class RequirementVisitorPermissions(ProcessVisitorPermissions):
pass
pass
elif
self
.
visitor
.
is_admin
:
elif
self
.
visitor
.
is_admin
:
if
not
self
.
process
.
closed
:
if
not
self
.
process
.
closed
:
self
.
add
(
"edit_statements"
)
if
self
.
requirement
.
type
!=
"keycheck"
:
self
.
add
(
"edit_statements"
)
self
.
add
(
"req_unapprove"
if
self
.
requirement
.
approved_by
else
"req_approve"
)
self
.
add
(
"req_unapprove"
if
self
.
requirement
.
approved_by
else
"req_approve"
)
elif
not
self
.
process_frozen
:
elif
not
self
.
process_frozen
:
if
self
.
requirement
.
type
==
"intent"
:
if
self
.
requirement
.
type
==
"intent"
:
...
...
process/tests/common.py
View file @
92e3d4d8
...
@@ -9,6 +9,7 @@ import process.models as pmodels
...
@@ -9,6 +9,7 @@ import process.models as pmodels
test_fingerprint1
=
"1793D6AB75663E6BF104953A634F4BD1E7AD5568"
test_fingerprint1
=
"1793D6AB75663E6BF104953A634F4BD1E7AD5568"
test_fingerprint2
=
"66B4DFB68CB24EBBD8650BC4F4B4B0CC797EBFAB"
test_fingerprint2
=
"66B4DFB68CB24EBBD8650BC4F4B4B0CC797EBFAB"
test_fingerprint3
=
"0EED77DC41D760FDE44035FF5556A34E04A3610B"
# Signed with key 1793D6AB75663E6BF104953A634F4BD1E7AD5568
# Signed with key 1793D6AB75663E6BF104953A634F4BD1E7AD5568
test_fpr1_signed_invalid_text
=
"""
test_fpr1_signed_invalid_text
=
"""
...
@@ -88,6 +89,32 @@ vEKSopp/HEL4wBq8JYlvA0DuHTB7+X91XI6LreJQAe+6Jo07iuqmeZd9/pl1Anch
...
@@ -88,6 +89,32 @@ vEKSopp/HEL4wBq8JYlvA0DuHTB7+X91XI6LreJQAe+6Jo07iuqmeZd9/pl1Anch
"""
"""
# Signed with key 0EED77DC41D760FDE44035FF5556A34E04A3610B
test_fpr3_signed_valid_text
=
"""
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256
I agree to uphold the Social Contract and the Debian Free Software Guidelines in my Debian work.
I have read the Debian Machine Usage Policy and I accept them.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2
iQIcBAEBCAAGBQJXPZKwAAoJEOjTeuLwn0hy1McP/iZPp6N/ng+P5jXGpuVoAJOa
Fn5b4RHAVZoQ+6k4NruN56bzn4NysAD4KMaMOOO5Wbu8Q+3CYlA1Kc6sVCHCTK47
34/oOszvW6WKD4Lf0H8KEiUcpdTMvVktiLjyCHlZDnnydWPG+72KzDm/TqoTxFW9
mFB1KIbYe2kJPV8yZOoxIEvmyrV4SgwZwG2FkdBn/0JFfJCbE7cXt0KKP0lUctka
ymB2mLLikXpJepd32ehUs15UAQZMbUSVbyLq28176og6lSWPVpEEeEdUmVuaii99
qNIKEA0k4UJPmgtJZxnPiGUgIMB9wRarnoZb2rAP0RhQ1lFYfIEz2tAMZ1o9c+Ia
5KEYnoLEHsF6nWZhrKKFm7TjaseQ5tcYCoZmG6pgraVnjdpUavH54mneQFmO5B7l
etrcCic0zb2/gDovjFPqJ2xDK+K0LOapUXrrLSOvdwB6tm3e7sGCSOZbibVpIrvC
WpgKnjrntfADnPx44xRS/RvAqr3TUUICbJq/czKr1+mDKwV/WKCYOWwe8GXRR0IR
uxODvexBbPuPeImQbpUVPvuIL7gyoxvdlNQwzKX12/GI5CZOEWx87MemRMB0r5oh
XD3vxTAcdhGDNK+LdTichQxp8nUs1IX5ziPP92jRXF2LjE58a9O4XC2vtEwm8wLm
kFBhaqNexUs/V1sIBuY5
=tMbR
-----END PGP SIGNATURE-----
"""
class
TestProcesses
(
NamedObjects
):
class
TestProcesses
(
NamedObjects
):
def
__init__
(
self
,
**
defaults
):
def
__init__
(
self
,
**
defaults
):
super
(
TestProcesses
,
self
).
__init__
(
pmodels
.
Process
,
**
defaults
)
super
(
TestProcesses
,
self
).
__init__
(
pmodels
.
Process
,
**
defaults
)
...
...
process/tests/test_process_req.py
View file @
92e3d4d8
...
@@ -10,24 +10,25 @@ from backend import const
...
@@ -10,24 +10,25 @@ from backend import const
from
backend
import
models
as
bmodels
from
backend
import
models
as
bmodels
from
backend.unittest
import
PersonFixtureMixin
,
ExpectedSets
,
TestSet
,
PageElements
from
backend.unittest
import
PersonFixtureMixin
,
ExpectedSets
,
TestSet
,
PageElements
import
process.models
as
pmodels
import
process.models
as
pmodels
from
.common
import
ProcessFixtureMixin
,
get_all_process_types
,
test_fingerprint1
,
test_fpr1_signed_valid_text
from
.common
import
(
ProcessFixtureMixin
,
get_all_process_types
,
test_fingerprint1
,
test_fpr1_signed_valid_text
,
test_fingerprint2
,
test_fpr2_signed_valid_text
,
test_fingerprint3
,
test_fpr3_signed_valid_text
)
class
TestProcessReq
(
ProcessFixtureMixin
,
TestCase
):
class
TestProcessReq
(
ProcessFixtureMixin
,
TestCase
):
@
classmethod
@
classmethod
def
__add_extra_tests__
(
cls
):
def
__add_extra_tests__
(
cls
):
for
src
,
tgt
in
get_all_process_types
():
for
src
,
tgt
in
get_all_process_types
():
reqs
=
pmodels
.
Process
.
objects
.
compute_requirements
(
src
,
tgt
)
want_am
=
"am_ok"
in
pmodels
.
Process
.
objects
.
compute_requirements
(
src
,
tgt
)
want_am
=
"am_ok"
in
reqs
visitors
=
[
None
,
"pending"
,
"dc"
,
"dc_ga"
,
"dm"
,
"dm_ga"
,
"dd_nu"
,
"dd_u"
,
"dd_e"
,
"dd_r"
,
"activeam"
,
"fd"
,
"dam"
,
"app"
]
visitors
=
[
None
,
"pending"
,
"dc"
,
"dc_ga"
,
"dm"
,
"dm_ga"
,
"dd_nu"
,
"dd_u"
,
"dd_e"
,
"dd_r"
,
"activeam"
,
"fd"
,
"dam"
,
"app"
]
if
want_am
:
visitors
.
append
(
"am"
)
if
want_am
:
visitors
.
append
(
"am"
)
for
type
in
reqs
:
for
visitor
in
visitors
:
for
visitor
in
visitors
:
if
want_am
:
if
want_am
:
cls
.
_add_method
(
cls
.
_test_perms
,
src
,
tgt
,
visitor
,
am
=
"dd_nu"
)
cls
.
_add_method
(
cls
.
_test_perms
,
type
,
src
,
tgt
,
visitor
,
am
=
"dd_nu"
)
cls
.
_add_method
(
cls
.
_test_perms
,
src
,
tgt
,
visitor
,
am
=
"dd_u"
)
cls
.
_add_method
(
cls
.
_test_perms
,
type
,
src
,
tgt
,
visitor
,
am
=
"dd_u"
)
else
:
else
:
cls
.
_add_method
(
cls
.
_test_perms
,
src
,
tgt
,
visitor
)
cls
.
_add_method
(
cls
.
_test_perms
,
type
,
src
,
tgt
,
visitor
)
@
classmethod
@
classmethod
def
setUpClass
(
cls
):
def
setUpClass
(
cls
):
...
@@ -57,31 +58,60 @@ class TestProcessReq(ProcessFixtureMixin, TestCase):
...
@@ -57,31 +58,60 @@ class TestProcessReq(ProcessFixtureMixin, TestCase):
wanted
.
append
(
"statement_delete"
)
wanted
.
append
(
"statement_delete"
)
self
.
assertContainsElements
(
response
,
self
.
page_elements
,
*
wanted
)
self
.
assertContainsElements
(
response
,
self
.
page_elements
,
*
wanted
)
def
_test_perms
(
self
,
type
,
src
,
tgt
,
visitor
,
am
=
None
):
def
_test_requirement_generic
(
self
,
req
,
visitor
):
view
=
"process_req_"
+
type
client
=
self
.
make_test_client
(
visitor
)
response
=
client
.
get
(
req
.
get_absolute_url
())
self
.
assertEqual
(
response
.
status_code
,
200
)
visit_perms
=
req
.
permissions_of
(
self
.
persons
[
visitor
])
self
.
assertPageElements
(
response
,
visit_perms
)
def
_test_requirement_intent
(
self
,
visitor
):
req
=
pmodels
.
Requirement
.
objects
.
get
(
process
=
self
.
processes
.
app
,
type
=
"intent"
)
pmodels
.
Statement
.
objects
.
create
(
requirement
=
req
,
fpr
=
self
.
fingerprints
.
app
,
statement
=
test_fpr1_signed_valid_text
,
uploaded_by
=
self
.
persons
.
app
,
uploaded_time
=
now
())
self
.
_test_requirement_generic
(
req
,
visitor
)
def
_test_requirement_sc_dmup
(
self
,
visitor
):
req
=
pmodels
.
Requirement
.
objects
.
get
(
process
=
self
.
processes
.
app
,
type
=
"sc_dmup"
)
pmodels
.
Statement
.
objects
.
create
(
requirement
=
req
,
fpr
=
self
.
fingerprints
.
app
,
statement
=
test_fpr1_signed_valid_text
,
uploaded_by
=
self
.
persons
.
app
,
uploaded_time
=
now
())
self
.
_test_requirement_generic
(
req
,
visitor
)
def
_test_requirement_advocate
(
self
,
visitor
):
req
=
pmodels
.
Requirement
.
objects
.
get
(
process
=
self
.
processes
.
app
,
type
=
"advocate"
)
pmodels
.
Statement
.
objects
.
create
(
requirement
=
req
,
fpr
=
self
.
fingerprints
.
dd_nu
,
statement
=
test_fpr2_signed_valid_text
,
uploaded_by
=
self
.
persons
.
dd_nu
,
uploaded_time
=
now
())
self
.
_test_requirement_generic
(
req
,
visitor
)
def
_test_requirement_keycheck
(
self
,
visitor
):
req
=
pmodels
.
Requirement
.
objects
.
get
(
process
=
self
.
processes
.
app
,
type
=
"keycheck"
)
self
.
_test_requirement_generic
(
req
,
visitor
)
def
_test_requirement_am_ok
(
self
,
visitor
):
req
=
pmodels
.
Requirement
.
objects
.
get
(
process
=
self
.
processes
.
app
,
type
=
"am_ok"
)
pmodels
.
Statement
.
objects
.
create
(
requirement
=
req
,
fpr
=
self
.
fingerprints
.
am
,
statement
=
test_fpr3_signed_valid_text
,
uploaded_by
=
self
.
persons
.
am
,
uploaded_time
=
now
())
self
.
_test_requirement_generic
(
req
,
visitor
)
def
_test_perms
(
self
,
src
,
tgt
,
visitor
,
am
=
None
):
# Create process
self
.
persons
.
create
(
"app"
,
status
=
src
)
self
.
persons
.
create
(
"app"
,
status
=
src
)
self
.
fingerprints
.
create
(
"app"
,
person
=
self
.
persons
.
app
,
fpr
=
test_fingerprint1
,
is_active
=
True
,
audit_skip
=
True
)
self
.
fingerprints
.
create
(
"app"
,
person
=
self
.
persons
.
app
,
fpr
=
test_fingerprint1
,
is_active
=
True
,
audit_skip
=
True
)
self
.
processes
.
create
(
"app"
,
person
=
self
.
persons
.
app
,
applying_for
=
tgt
,
fd_comment
=
"test"
)
self
.
processes
.
create
(
"app"
,
person
=
self
.
persons
.
app
,
applying_for
=
tgt
,
fd_comment
=
"test"
)
self
.
fingerprints
.
create
(
"dd_nu"
,
person
=
self
.
persons
.
dd_nu
,
fpr
=
test_fingerprint2
,
is_active
=
True
,
audit_skip
=
True
)
if
am
is
not
None
:
if
am
is
not
None
:
self
.
persons
.
create
(
"am"
,
status
=
am
)
self
.
persons
.
create
(
"am"
,
status
=
am
)
self
.
fingerprints
.
create
(
"am"
,
person
=
self
.
persons
.
am
,
fpr
=
test_fingerprint3
,
is_active
=
True
,
audit_skip
=
True
)
self
.
ams
.
create
(
"am"
,
person
=
self
.
persons
.
am
)
self
.
ams
.
create
(
"am"
,
person
=
self
.
persons
.
am
)
req
=
pmodels
.
Requirement
.
objects
.
get
(
process
=
self
.
processes
.
app
,
type
=
type
)
reqs
=
pmodels
.
Process
.
objects
.
compute_requirements
(
src
,
tgt
)
if
type
in
(
"intent"
,
"sc_dmup"
,
"advocate"
,
"am_ok"
):
if
"intent"
in
reqs
:
self
.
_test_requirement_intent
(
visitor
)
pmodels
.
Statement
.
objects
.
create
(
requirement
=
req
,
fpr
=
self
.
fingerprints
.
app
,
statement
=
test_fpr1_signed_valid_text
,
uploaded_by
=
self
.
persons
.
app
,
uploaded_time
=
now
())
if
"sc_dmup"
in
reqs
:
self
.
_test_requirement_sc_dmup
(
visitor
)
if
"advocate"
in
reqs
:
self
.
_test_requirement_advocate
(
visitor
)
client
=
self
.
make_test_client
(
visitor
)
if
"keycheck"
in
reqs
:
self
.
_test_requirement_keycheck
(
visitor
)
response
=
client
.
get
(
reverse
(
view
,
args
=
[
self
.
processes
.
app
.
pk
]))
if
"am_ok"
in
reqs
:
self
.
_test_requirement_am_ok
(
visitor
)
self
.
assertEqual
(
response
.
status_code
,
200
)
visit_perms
=
req
.
permissions_of
(
self
.
persons
[
visitor
])
self
.
assertPageElements
(
response
,
visit_perms
)
# Assign am and repeat visit
# Assign am and repeat visit
if
am
:
if
am
:
pmodels
.
AMAssignment
.
objects
.
create
(
process
=
self
.
processes
.
app
,
am
=
self
.
ams
.
am
,
assigned_by
=
self
.
persons
[
"fd"
],
assigned_time
=
now
())
pmodels
.
AMAssignment
.
objects
.
create
(
process
=
self
.
processes
.
app
,
am
=
self
.
ams
.
am
,
assigned_by
=
self
.
persons
[
"fd"
],
assigned_time
=
now
())
if
"intent"
in
reqs
:
self
.
_test_requirement_intent
(
visitor
)
response
=
client
.
get
(
reverse
(
view
,
args
=
[
self
.
processes
.
app
.
pk
]))
if
"sc_dmup"
in
reqs
:
self
.
_test_requirement_sc_dmup
(
visitor
)
self
.
assertEqual
(
response
.
status_code
,
200
)
if
"advocate"
in
reqs
:
self
.
_test_requirement_advocate
(
visitor
)
visit_perms
=
req
.
permissions_of
(
self
.
persons
[
visitor
])
if
"keycheck"
in
reqs
:
self
.
_test_requirement_keycheck
(
visitor
)
self
.
assertPageElements
(
response
,
visit_perms
)
if
"am_ok"
in
reqs
:
self
.
_test_requirement_am_ok
(
visitor
)
test_data/0EED77DC41D760FDE44035FF5556A34E04A3610B.txt
0 → 100644
View file @
92e3d4d8
This diff is collapsed.
Click to expand it.
Write
Preview
Supports
Markdown
0%
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!
Cancel
Please
register
or
sign in
to comment