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
Mattia Rizzolo
nm.debian.org
Commits
bd61f3ca
Unverified
Commit
bd61f3ca
authored
Apr 21, 2020
by
Enrico Zini
Browse files
Fixed authentication handling for wizard for new processes. Closes:
#9
parents
2aae357f
b95be09c
Changes
6
Hide whitespace changes
Inline
Side-by-side
nm2/urls.py
View file @
bd61f3ca
from
django.urls
import
include
,
path
,
re_path
from
django.urls
import
include
,
path
from
django.views.generic
import
TemplateView
from
django.views.generic
import
TemplateView
from
backend.mixins
import
VisitorTemplateView
from
backend.mixins
import
VisitorTemplateView
from
django.conf
import
settings
from
django.conf
import
settings
...
@@ -24,43 +24,43 @@ django.conf.urls.handler500 = nmviews.Error500.as_view()
...
@@ -24,43 +24,43 @@ django.conf.urls.handler500 = nmviews.Error500.as_view()
urlpatterns
=
[
urlpatterns
=
[
path
(
'robots.txt'
,
TemplateView
.
as_view
(
path
(
'robots.txt'
,
TemplateView
.
as_view
(
template_name
=
'robots.txt'
,
content_type
=
"text/plain"
),
name
=
"root_robots_txt"
),
template_name
=
'robots.txt'
,
content_type
=
"text/plain"
),
name
=
"root_robots_txt"
),
re_
path
(
r
'^
i18n/'
,
include
(
'django.conf.urls.i18n'
)),
path
(
'
i18n/'
,
include
(
'django.conf.urls.i18n'
)),
re_
path
(
r
'
^$
'
,
VisitorTemplateView
.
as_view
(
template_name
=
'index.html'
),
name
=
"home"
),
path
(
r
''
,
VisitorTemplateView
.
as_view
(
template_name
=
'index.html'
),
name
=
"home"
),
re_
path
(
r
'^
license/
$
'
,
VisitorTemplateView
.
as_view
(
template_name
=
'license.html'
),
name
=
"root_license"
),
path
(
'
license/'
,
VisitorTemplateView
.
as_view
(
template_name
=
'license.html'
),
name
=
"root_license"
),
re_
path
(
r
'^
faq/
$
'
,
VisitorTemplateView
.
as_view
(
template_name
=
'faq.html'
),
name
=
"root_faq"
),
path
(
'
faq/'
,
VisitorTemplateView
.
as_view
(
template_name
=
'faq.html'
),
name
=
"root_faq"
),
re_
path
(
r
'^
members/
$
'
,
public_views
.
Members
.
as_view
(),
name
=
"members"
),
path
(
'
members/'
,
public_views
.
Members
.
as_view
(),
name
=
"members"
),
re_
path
(
r
'^
legacy/'
,
include
(
"legacy.urls"
)),
path
(
'
legacy/'
,
include
(
"legacy.urls"
)),
re_
path
(
r
'^
person/'
,
include
(
"person.urls"
)),
path
(
'
person/'
,
include
(
"person.urls"
)),
re_
path
(
r
'^
public/'
,
include
(
"public.urls"
)),
path
(
'
public/'
,
include
(
"public.urls"
)),
re_
path
(
r
'^
am/'
,
include
(
"restricted.urls"
)),
path
(
'
am/'
,
include
(
"restricted.urls"
)),
re_
path
(
r
'^
fprs/'
,
include
(
"fprs.urls"
)),
path
(
'
fprs/'
,
include
(
"fprs.urls"
)),
re_
path
(
r
'^
process/'
,
include
(
"process.urls"
)),
path
(
'
process/'
,
include
(
"process.urls"
)),
re_
path
(
r
'^
dm/'
,
include
(
"dm.urls"
)),
path
(
'
dm/'
,
include
(
"dm.urls"
)),
re_
path
(
r
'^
api/'
,
include
(
"api.urls"
)),
path
(
'
api/'
,
include
(
"api.urls"
)),
re_
path
(
r
'^
apikeys/'
,
include
(
"apikeys.urls"
)),
path
(
'
apikeys/'
,
include
(
"apikeys.urls"
)),
re_
path
(
r
'^
keyring/'
,
include
(
"keyring.urls"
)),
path
(
'
keyring/'
,
include
(
"keyring.urls"
)),
re_
path
(
r
'^
wizard/'
,
include
(
"wizard.urls"
)),
path
(
'
wizard/'
,
include
(
"wizard.urls"
)),
re_
path
(
r
'^
mia/'
,
include
(
"mia.urls"
)),
path
(
'
mia/'
,
include
(
"mia.urls"
)),
re_
path
(
r
'^
minechangelogs/'
,
include
(
"minechangelogs.urls"
)),
path
(
'
minechangelogs/'
,
include
(
"minechangelogs.urls"
)),
re_
path
(
r
'^
sitechecks/'
,
include
(
"sitechecks.urls"
)),
path
(
'
sitechecks/'
,
include
(
"sitechecks.urls"
)),
re_
path
(
r
'^
deploy/'
,
include
(
"deploy.urls"
)),
path
(
'
deploy/'
,
include
(
"deploy.urls"
)),
re_
path
(
r
'^
rest/api/'
,
include
(
router
.
urls
)),
path
(
'
rest/api/'
,
include
(
router
.
urls
)),
path
(
r
'signon/'
,
include
(
"signon.urls"
)),
path
(
'signon/'
,
include
(
"signon.urls"
)),
# Uncomment the admin/doc line below to enable admin documentation:
# Uncomment the admin/doc line below to enable admin documentation:
re_
path
(
r
'^
admin/doc/'
,
include
(
'django.contrib.admindocs.urls'
)),
path
(
'
admin/doc/'
,
include
(
'django.contrib.admindocs.urls'
)),
# Uncomment the next line to enable the admin:
# Uncomment the next line to enable the admin:
re_
path
(
r
'^
admin/'
,
admin
.
site
.
urls
),
path
(
'
admin/'
,
admin
.
site
.
urls
),
]
]
if
settings
.
DEBUG
:
if
settings
.
DEBUG
:
try
:
try
:
import
debug_toolbar
import
debug_toolbar
urlpatterns
+=
[
urlpatterns
+=
[
re_
path
(
r
'^
__debug__/'
,
include
(
debug_toolbar
.
urls
)),
path
(
'
__debug__/'
,
include
(
debug_toolbar
.
urls
)),
]
]
except
ImportError
:
except
ImportError
:
pass
pass
wizard/templates/wizard/newprocess.html
View file @
bd61f3ca
...
@@ -6,35 +6,13 @@
...
@@ -6,35 +6,13 @@
<h1>
{{target_desc}}
</h1>
<h1>
{{target_desc}}
</h1>
{% if not request.sso_username %}
{% if not visitor %}
<p>
{% blocktrans %}You are not currently logged in. See the
<p
class=
"lead"
>
{% trans "This wizard only works when you are logged into the site" %}
</p>
<a
href=
"https://wiki.debian.org/DebianSingleSignOn"
>
Single Sign-On page
</a>
for details.{% endblocktrans %}
</p>
{% elif not visitor %}
<p>
{% blocktrans with request_user_username=request.user.username %}You are
currently logged in with
<a
href=
"https://wiki.debian.org/DebianSingleSignOn"
>
SSO username
</a>
<b>
{{request_user_username}}
</b>
, but you cannot be matched
to any person in the site.{% endblocktrans %}
</p>
<p>
{% url 'dm_claim' as dm_claim_url %}
{% blocktrans %}If you are already in the site, for example as a Debian
Maintainer, you can try to correct the situation using the
<a
href=
"{{dm_claim_url}}"
>
claim interface
</a>
.{% endblocktrans %}
</p>
<p>
{% url 'dm_claim' as dm_claim_url %}
{% blocktrans %}If you are already in the site, for example as a Debian
Maintainer, you can try to correct the situation using the
<a
href=
"{{dm_claim_url}}"
>
claim interface
</a>
.{% endblocktrans %}
</p>
<p>
{% url 'public_newnm' as public_newnm_url %}
{% blocktrans %}If you are not yet in the site,
<a
href=
"{{public_newnm_url}}"
>
visit the 'Join the NM process' page
</a>
to can create an entry for yourself.{% endblocktrans %}
</p>
{% else %}
{% else %}
{% for c in comments %}
<p>
{{c}}
</p>
{% endfor %}
{% for c in comments %}
<p
class=
"lead"
>
{{c}}
</p>
{% endfor %}
{% if allowed %}
{% if allowed %}
<p>
<p
class=
"lead"
>
{% url 'process_create' key=visitor.lookup_key as process_create_url %}
{% url 'process_create' key=visitor.lookup_key as process_create_url %}
{% blocktrans %}Just
<a
href=
"{{process_create_url}}"
>
visit this page
</a>
{% blocktrans %}Just
<a
href=
"{{process_create_url}}"
>
visit this page
</a>
and follow the instructions.{% endblocktrans %}
and follow the instructions.{% endblocktrans %}
...
...
wizard/templates/wizard/whoami.html
View file @
bd61f3ca
...
@@ -17,6 +17,11 @@ are currently logged in, but not mapped to any person in the site.
...
@@ -17,6 +17,11 @@ are currently logged in, but not mapped to any person in the site.
If you are a Debian Maintainer, you can try to correct the situation using the
If you are a Debian Maintainer, you can try to correct the situation using the
<a
href=
"{{dm_claim}}"
>
claim interface
</a>
.{% endblocktrans %}
<a
href=
"{{dm_claim}}"
>
claim interface
</a>
.{% endblocktrans %}
{% url 'public_newnm' as public_newnm_url %}
{% blocktrans %}If you are not yet in the site,
<a
href=
"{{public_newnm_url}}"
>
visit the 'Join the NM process' page
</a>
to create an entry for yourself.{% endblocktrans %}
</p>
<p>
{% trans "You are logged in as:" %}
</p>
<p>
{% trans "You are logged in as:" %}
</p>
<ul>
<ul>
...
...
wizard/tests/test_newproc.py
0 → 100644
View file @
bd61f3ca
from
__future__
import
annotations
from
django.test
import
TestCase
from
django.urls
import
reverse
from
backend.unittest
import
PersonFixtureMixin
from
backend
import
const
from
signon.models
import
Identity
class
NewProcTests
(
PersonFixtureMixin
,
TestCase
):
@
classmethod
def
__add_extra_tests__
(
cls
):
targets
=
[
"dm"
,
"ga"
,
"return"
,
"invalid"
]
targets
.
extend
(
const
.
ALL_STATUS_DESCS
.
keys
())
for
target
in
targets
:
cls
.
_add_method
(
cls
.
_test_notlogged
,
target
)
cls
.
_add_method
(
cls
.
_test_active_unbound
,
target
)
def
_test_notlogged
(
self
,
target
):
# Check that the new person is listed on the page
client
=
self
.
make_test_client
(
None
)
response
=
client
.
get
(
reverse
(
'wizard_newprocess'
,
args
=
[
target
]))
self
.
assertEqual
(
response
.
status_code
,
200
)
self
.
assertContains
(
response
,
"This wizard only works when you are logged into the site"
)
def
_test_active_unbound
(
self
,
target
):
# Check that the new person is listed on the page
identity
=
Identity
.
objects
.
create
(
issuer
=
"debsso"
,
subject
=
"test@debian.org"
,
username
=
"test@debian.org"
,
audit_skip
=
True
)
client
=
self
.
make_test_client
(
None
,
[
identity
])
response
=
client
.
get
(
reverse
(
'wizard_newprocess'
,
args
=
[
target
]))
self
.
assertEqual
(
response
.
status_code
,
200
)
self
.
assertContains
(
response
,
"This wizard only works when you are logged into the site"
)
def
test_dc_to_dm
(
self
):
client
=
self
.
make_test_client
(
self
.
persons
.
dc
)
response
=
client
.
get
(
reverse
(
'wizard_newprocess'
,
args
=
[
"dm"
]))
self
.
assertEqual
(
response
.
status_code
,
200
)
self
.
assertTrue
(
response
.
context
[
"allowed"
])
self
.
assertContains
(
response
,
"and follow the instructions"
)
def
test_dcga_to_dm
(
self
):
client
=
self
.
make_test_client
(
self
.
persons
.
dc_ga
)
response
=
client
.
get
(
reverse
(
'wizard_newprocess'
,
args
=
[
"dm"
]))
self
.
assertEqual
(
response
.
status_code
,
200
)
self
.
assertTrue
(
response
.
context
[
"allowed"
])
self
.
assertContains
(
response
,
"and follow the instructions"
)
def
test_dm_to_dm
(
self
):
client
=
self
.
make_test_client
(
self
.
persons
.
dm
)
response
=
client
.
get
(
reverse
(
'wizard_newprocess'
,
args
=
[
"dm"
]))
self
.
assertEqual
(
response
.
status_code
,
200
)
self
.
assertFalse
(
response
.
context
[
"allowed"
])
self
.
assertNotContains
(
response
,
"and follow the instructions"
)
self
.
assertContains
(
response
,
"You are already a Debian Maintainer"
)
def
test_dmga_to_dm
(
self
):
client
=
self
.
make_test_client
(
self
.
persons
.
dm_ga
)
response
=
client
.
get
(
reverse
(
'wizard_newprocess'
,
args
=
[
"dm"
]))
self
.
assertEqual
(
response
.
status_code
,
200
)
self
.
assertFalse
(
response
.
context
[
"allowed"
])
self
.
assertNotContains
(
response
,
"and follow the instructions"
)
self
.
assertContains
(
response
,
"You are already a Debian Maintainer"
)
def
test_ddnu_to_dm
(
self
):
client
=
self
.
make_test_client
(
self
.
persons
.
dd_nu
)
response
=
client
.
get
(
reverse
(
'wizard_newprocess'
,
args
=
[
"dm"
]))
self
.
assertEqual
(
response
.
status_code
,
200
)
self
.
assertFalse
(
response
.
context
[
"allowed"
])
self
.
assertNotContains
(
response
,
"and follow the instructions"
)
self
.
assertContains
(
response
,
"You are already"
)
wizard/tests/test_whoami.py
View file @
bd61f3ca
from
__future__
import
annotations
from
__future__
import
annotations
from
django.test
import
TestCase
from
django.test
import
TestCase
from
django.urls
import
reverse
from
django.urls
import
reverse
from
backend
import
const
from
backend.unittest
import
PersonFixtureMixin
from
backend.unittest
import
PersonFixtureMixin
from
signon.models
import
Identity
from
signon.models
import
Identity
...
...
wizard/urls.py
View file @
bd61f3ca
from
django.
conf.
urls
import
url
from
django.urls
import
path
from
backend.mixins
import
VisitorTemplateView
from
backend.mixins
import
VisitorTemplateView
from
.
import
views
from
.
import
views
urlpatterns
=
[
urlpatterns
=
[
url
(
r
'^$'
,
VisitorTemplateView
.
as_view
(
template_name
=
"wizard/home.html"
),
name
=
"wizard_home"
),
path
(
""
,
VisitorTemplateView
.
as_view
(
template_name
=
"wizard/home.html"
),
name
=
"wizard_home"
),
url
(
r
'^
advocate
$'
,
views
.
Advocate
.
as_view
(),
name
=
"wizard_advocate"
),
path
(
"
advocate
/"
,
views
.
Advocate
.
as_view
(),
name
=
"wizard_advocate"
),
url
(
r
'^
process/
(?P
<applying_for>
[^/]+)$'
,
views
.
NewProcess
.
as_view
(),
name
=
"wizard_newprocess"
),
path
(
"
process/<applying_for>
/"
,
views
.
NewProcess
.
as_view
(),
name
=
"wizard_newprocess"
),
]
]
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