Skip to content

Role Management #2705

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

Merged
merged 27 commits into from
Jan 22, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
9e70f47
Add 'manage' permission
di Dec 15, 2017
54b8f32
Always store principals as strings
di Dec 15, 2017
c623660
Split profile and project management
di Dec 20, 2017
f8d179e
Put the gravatar link on the 'Manage Profile' page
di Dec 20, 2017
b16bdc3
Role management
di Dec 20, 2017
b7af24b
Some really rudimentary styling, please revert
di Dec 20, 2017
8c0a453
Update logged in information architecture, begin styling
nlhkabu Jan 8, 2018
66ed62f
Make collaborator form more simple
nlhkabu Jan 8, 2018
a118bd8
Allow stacking flash messages
nlhkabu Jan 8, 2018
16d6d90
Reuse dropdown SCSS
nlhkabu Jan 9, 2018
efd7854
Style releases table
nlhkabu Jan 9, 2018
518a39e
Update management UI based on meeting feedback
nlhkabu Jan 10, 2018
5615f8b
Fix linter errors
di Jan 10, 2018
5f9f080
Hide 'duplicate' roles
di Jan 10, 2018
e0ce027
Break management forms into mixins
di Jan 13, 2018
56f4dd5
Simplify delete view
di Jan 13, 2018
6315e1f
Add ability to change existing roles
di Jan 13, 2018
9f26e6a
Add JournalEntries when adding/removing roles
di Jan 15, 2018
8f9cd2c
Add labels for screen readers
nlhkabu Jan 12, 2018
b2e6ad1
Add delete modals, tabs, clean up UI
nlhkabu Jan 17, 2018
9e29b7b
Put TODOs in comments
di Jan 17, 2018
283e582
Namespace manage routes
di Jan 17, 2018
837bf2d
Hide draft UIs in templates
nlhkabu Jan 18, 2018
9a1f4fe
Properly comment out Edit Project link
di Jan 18, 2018
60d1144
Change 'Preview' to 'View'
di Jan 18, 2018
9f39491
Fix more linting errors
di Jan 18, 2018
65c59d9
Merge branch 'master' into role-management
nlhkabu Jan 22, 2018
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
5 changes: 3 additions & 2 deletions tests/unit/accounts/test_auth_policy.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
# limitations under the License.

import pretend
import uuid

from pyramid import authentication
from pyramid.interfaces import IAuthenticationPolicy
Expand Down Expand Up @@ -74,7 +75,7 @@ def test_unauthenticated_userid_with_userid(self, monkeypatch):
add_vary_cb = pretend.call_recorder(lambda *v: vary_cb)
monkeypatch.setattr(auth_policy, "add_vary_callback", add_vary_cb)

userid = pretend.stub()
userid = uuid.uuid4()
service = pretend.stub(
find_userid=pretend.call_recorder(lambda username: userid),
)
Expand All @@ -83,7 +84,7 @@ def test_unauthenticated_userid_with_userid(self, monkeypatch):
add_response_callback=pretend.call_recorder(lambda cb: None),
)

assert policy.unauthenticated_userid(request) is userid
assert policy.unauthenticated_userid(request) == str(userid)
assert extract_http_basic_credentials.calls == [pretend.call(request)]
assert request.find_service.calls == [
pretend.call(IUserService, context=None),
Expand Down
9 changes: 0 additions & 9 deletions tests/unit/accounts/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -559,15 +559,6 @@ def test_reset_password(self, db_request, user_service, token_service):
]


class TestClientSideIncludes:

def test_edit_gravatar_csi_returns_user(self, db_request):
user = UserFactory.create()
assert views.edit_gravatar_csi(user, db_request) == {
"user": user,
}


class TestProfileCallout:

def test_profile_callout_returns_user(self):
Expand Down
11 changes: 11 additions & 0 deletions tests/unit/manage/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
71 changes: 71 additions & 0 deletions tests/unit/manage/test_forms.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

import pretend
import pytest
import wtforms

from webob.multidict import MultiDict

from warehouse.manage import forms


class TestCreateRoleForm:

def test_creation(self):
user_service = pretend.stub()
form = forms.CreateRoleForm(user_service=user_service)

assert form.user_service is user_service

def test_validate_username_with_no_user(self):
user_service = pretend.stub(
find_userid=pretend.call_recorder(lambda userid: None),
)
form = forms.CreateRoleForm(user_service=user_service)
field = pretend.stub(data="my_username")

with pytest.raises(wtforms.validators.ValidationError):
form.validate_username(field)

assert user_service.find_userid.calls == [pretend.call("my_username")]

def test_validate_username_with_user(self):
user_service = pretend.stub(
find_userid=pretend.call_recorder(lambda userid: 1),
)
form = forms.CreateRoleForm(user_service=user_service)
field = pretend.stub(data="my_username")

form.validate_username(field)

assert user_service.find_userid.calls == [pretend.call("my_username")]

@pytest.mark.parametrize(("value", "expected"), [
("", "Must select a role"),
("invalid", "Not a valid choice"),
(None, "Not a valid choice"),
])
def test_validate_role_name_fails(self, value, expected):
user_service = pretend.stub(
find_userid=pretend.call_recorder(lambda userid: 1),
)
form = forms.CreateRoleForm(
MultiDict({
'role_name': value,
'username': 'valid_username',
}),
user_service=user_service,
)

assert not form.validate()
assert form.role_name.errors == [expected]
Loading