kopia lustrzana https://github.com/wagtail/wagtail
Fix TestExplorablePages for EmailUser
rodzic
537c4fb216
commit
391bfc0a43
|
@ -46,22 +46,22 @@ class TestExplorablePages(TestCase, WagtailTestUtils):
|
|||
|
||||
def test_admins_see_all_pages(self):
|
||||
User = get_user_model()
|
||||
user = User.objects.get(username='superman')
|
||||
user = User.objects.get(email='superman@example.com')
|
||||
self.assertEqual(get_explorable_root_page(user).id, 1)
|
||||
|
||||
def test_nav_root_for_nonadmin_is_closest_common_ancestor(self):
|
||||
User = get_user_model()
|
||||
user = User.objects.get(username='jane')
|
||||
user = User.objects.get(email='jane@example.com')
|
||||
self.assertEqual(get_explorable_root_page(user).id, 2)
|
||||
|
||||
def test_nonadmin_sees_leaf_page_at_root_level(self):
|
||||
User = get_user_model()
|
||||
user = User.objects.get(username='bob')
|
||||
user = User.objects.get(email='bob@example.com')
|
||||
self.assertEqual(get_explorable_root_page(user).id, 6)
|
||||
|
||||
def test_nonadmin_sees_pages_below_closest_common_ancestor(self):
|
||||
User = get_user_model()
|
||||
user = User.objects.get(username='josh')
|
||||
user = User.objects.get(email='josh@example.com')
|
||||
# Josh has permissions for /example-home/content/page-1 and /example-home/other-content,
|
||||
# of which the closest common ancestor is /example-home.
|
||||
self.assertEqual(get_explorable_root_page(user).id, 4)
|
||||
|
@ -74,12 +74,12 @@ class TestExplorablePages(TestCase, WagtailTestUtils):
|
|||
# of 'home' and 'example-home' (but not the sibling 'home-2', which Sam doesn't have
|
||||
# permission on)
|
||||
User = get_user_model()
|
||||
user = User.objects.get(username='sam')
|
||||
user = User.objects.get(email='sam@example.com')
|
||||
self.assertEqual(get_explorable_root_page(user).id, 1)
|
||||
for page in get_pages_with_direct_explore_permission(user):
|
||||
self.assertIn(page.id, [2, 6])
|
||||
|
||||
def test_nonadmin_with_no_page_perms_cannot_explore(self):
|
||||
User = get_user_model()
|
||||
user = User.objects.get(username='mary')
|
||||
user = User.objects.get(email='mary@example.com')
|
||||
self.assertEqual(get_explorable_root_page(user), None)
|
||||
|
|
|
@ -0,0 +1,112 @@
|
|||
[
|
||||
{
|
||||
"pk": 1,
|
||||
"model": "customuser.customuser",
|
||||
"fields": {
|
||||
"username": "superman",
|
||||
"first_name": "Clark",
|
||||
"last_name": "Kent",
|
||||
"is_active": true,
|
||||
"is_superuser": true,
|
||||
"is_staff": true,
|
||||
"groups": [
|
||||
],
|
||||
"user_permissions": [],
|
||||
"password": "md5$seasalt$1e9bf2bf5606aa5c39852cc30f0f6f22",
|
||||
"email": "superman@example.com"
|
||||
}
|
||||
},
|
||||
{
|
||||
"pk": 2,
|
||||
"model": "customuser.customuser",
|
||||
"fields": {
|
||||
"username": "jane",
|
||||
"first_name": "Jane",
|
||||
"last_name": "Smith",
|
||||
"is_active": true,
|
||||
"is_superuser": false,
|
||||
"is_staff": true,
|
||||
"groups": [
|
||||
["Group 1"]
|
||||
],
|
||||
"user_permissions": [],
|
||||
"password": "md5$seasalt$1e9bf2bf5606aa5c39852cc30f0f6f22",
|
||||
"email": "jane@example.com"
|
||||
}
|
||||
},
|
||||
{
|
||||
"pk": 3,
|
||||
"model": "customuser.customuser",
|
||||
"fields": {
|
||||
"username": "bob",
|
||||
"first_name": "Bob",
|
||||
"last_name": "Smith",
|
||||
"is_active": true,
|
||||
"is_superuser": false,
|
||||
"is_staff": true,
|
||||
"groups": [
|
||||
["Group 2"]
|
||||
],
|
||||
"user_permissions": [],
|
||||
"password": "md5$seasalt$1e9bf2bf5606aa5c39852cc30f0f6f22",
|
||||
"email": "bob@example.com"
|
||||
}
|
||||
},
|
||||
{
|
||||
"pk": 4,
|
||||
"model": "customuser.customuser",
|
||||
"fields": {
|
||||
"username": "sam",
|
||||
"first_name": "Sam",
|
||||
"last_name": "Smith",
|
||||
"is_active": true,
|
||||
"is_superuser": false,
|
||||
"is_staff": true,
|
||||
"groups": [
|
||||
["Group 1"],
|
||||
["Group 2"]
|
||||
],
|
||||
"user_permissions": [],
|
||||
"password": "md5$seasalt$1e9bf2bf5606aa5c39852cc30f0f6f22",
|
||||
"email": "sam@example.com"
|
||||
}
|
||||
},
|
||||
{
|
||||
"pk": 5,
|
||||
"model": "customuser.customuser",
|
||||
"fields": {
|
||||
"username": "mary",
|
||||
"first_name": "Mary",
|
||||
"last_name": "Smith",
|
||||
"is_active": true,
|
||||
"is_superuser": false,
|
||||
"is_staff": true,
|
||||
"groups": [
|
||||
],
|
||||
"user_permissions": [
|
||||
["access_admin", "wagtailadmin", "admin"]
|
||||
],
|
||||
"password": "md5$seasalt$1e9bf2bf5606aa5c39852cc30f0f6f22",
|
||||
"email": "mary@example.com"
|
||||
}
|
||||
},
|
||||
{
|
||||
"pk": 6,
|
||||
"model": "customuser.customuser",
|
||||
"fields": {
|
||||
"username": "josh",
|
||||
"first_name": "Josh",
|
||||
"last_name": "Smith",
|
||||
"is_active": true,
|
||||
"is_superuser": false,
|
||||
"is_staff": true,
|
||||
"groups": [
|
||||
["Group 2"],
|
||||
["Group 3"]
|
||||
],
|
||||
"user_permissions": [],
|
||||
"password": "md5$seasalt$1e9bf2bf5606aa5c39852cc30f0f6f22",
|
||||
"email": "josh@example.com"
|
||||
}
|
||||
}
|
||||
]
|
|
@ -0,0 +1,106 @@
|
|||
[
|
||||
{
|
||||
"pk": 1,
|
||||
"model": "emailuser.emailuser",
|
||||
"fields": {
|
||||
"first_name": "Clark",
|
||||
"last_name": "Kent",
|
||||
"is_active": true,
|
||||
"is_superuser": true,
|
||||
"is_staff": true,
|
||||
"groups": [
|
||||
],
|
||||
"user_permissions": [],
|
||||
"password": "md5$seasalt$1e9bf2bf5606aa5c39852cc30f0f6f22",
|
||||
"email": "superman@example.com"
|
||||
}
|
||||
},
|
||||
{
|
||||
"pk": 2,
|
||||
"model": "emailuser.emailuser",
|
||||
"fields": {
|
||||
"first_name": "Jane",
|
||||
"last_name": "Smith",
|
||||
"is_active": true,
|
||||
"is_superuser": false,
|
||||
"is_staff": true,
|
||||
"groups": [
|
||||
["Group 1"]
|
||||
],
|
||||
"user_permissions": [],
|
||||
"password": "md5$seasalt$1e9bf2bf5606aa5c39852cc30f0f6f22",
|
||||
"email": "jane@example.com"
|
||||
}
|
||||
},
|
||||
{
|
||||
"pk": 3,
|
||||
"model": "emailuser.emailuser",
|
||||
"fields": {
|
||||
"first_name": "Bob",
|
||||
"last_name": "Smith",
|
||||
"is_active": true,
|
||||
"is_superuser": false,
|
||||
"is_staff": true,
|
||||
"groups": [
|
||||
["Group 2"]
|
||||
],
|
||||
"user_permissions": [],
|
||||
"password": "md5$seasalt$1e9bf2bf5606aa5c39852cc30f0f6f22",
|
||||
"email": "bob@example.com"
|
||||
}
|
||||
},
|
||||
{
|
||||
"pk": 4,
|
||||
"model": "emailuser.emailuser",
|
||||
"fields": {
|
||||
"first_name": "Sam",
|
||||
"last_name": "Smith",
|
||||
"is_active": true,
|
||||
"is_superuser": false,
|
||||
"is_staff": true,
|
||||
"groups": [
|
||||
["Group 1"],
|
||||
["Group 2"]
|
||||
],
|
||||
"user_permissions": [],
|
||||
"password": "md5$seasalt$1e9bf2bf5606aa5c39852cc30f0f6f22",
|
||||
"email": "sam@example.com"
|
||||
}
|
||||
},
|
||||
{
|
||||
"pk": 5,
|
||||
"model": "emailuser.emailuser",
|
||||
"fields": {
|
||||
"first_name": "Mary",
|
||||
"last_name": "Smith",
|
||||
"is_active": true,
|
||||
"is_superuser": false,
|
||||
"is_staff": true,
|
||||
"groups": [
|
||||
],
|
||||
"user_permissions": [
|
||||
["access_admin", "wagtailadmin", "admin"]
|
||||
],
|
||||
"password": "md5$seasalt$1e9bf2bf5606aa5c39852cc30f0f6f22",
|
||||
"email": "mary@example.com"
|
||||
}
|
||||
},
|
||||
{
|
||||
"pk": 6,
|
||||
"model": "emailuser.emailuser",
|
||||
"fields": {
|
||||
"first_name": "Josh",
|
||||
"last_name": "Smith",
|
||||
"is_active": true,
|
||||
"is_superuser": false,
|
||||
"is_staff": true,
|
||||
"groups": [
|
||||
["Group 2"],
|
||||
["Group 3"]
|
||||
],
|
||||
"user_permissions": [],
|
||||
"password": "md5$seasalt$1e9bf2bf5606aa5c39852cc30f0f6f22",
|
||||
"email": "josh@example.com"
|
||||
}
|
||||
}
|
||||
]
|
|
@ -406,117 +406,5 @@
|
|||
"page": 8,
|
||||
"permission_type": "choose"
|
||||
}
|
||||
},
|
||||
|
||||
{
|
||||
"pk": 1,
|
||||
"model": "customuser.customuser",
|
||||
"fields": {
|
||||
"username": "superman",
|
||||
"first_name": "Clark",
|
||||
"last_name": "Kent",
|
||||
"is_active": true,
|
||||
"is_superuser": true,
|
||||
"is_staff": true,
|
||||
"groups": [
|
||||
],
|
||||
"user_permissions": [],
|
||||
"password": "md5$seasalt$1e9bf2bf5606aa5c39852cc30f0f6f22",
|
||||
"email": "ckent@dailyplanet.com"
|
||||
}
|
||||
},
|
||||
{
|
||||
"pk": 2,
|
||||
"model": "customuser.customuser",
|
||||
"fields": {
|
||||
"username": "jane",
|
||||
"first_name": "Jane",
|
||||
"last_name": "Smith",
|
||||
"is_active": true,
|
||||
"is_superuser": false,
|
||||
"is_staff": true,
|
||||
"groups": [
|
||||
["Group 1"]
|
||||
],
|
||||
"user_permissions": [],
|
||||
"password": "md5$seasalt$1e9bf2bf5606aa5c39852cc30f0f6f22",
|
||||
"email": "jane@example.com"
|
||||
}
|
||||
},
|
||||
{
|
||||
"pk": 3,
|
||||
"model": "customuser.customuser",
|
||||
"fields": {
|
||||
"username": "bob",
|
||||
"first_name": "Bob",
|
||||
"last_name": "Smith",
|
||||
"is_active": true,
|
||||
"is_superuser": false,
|
||||
"is_staff": true,
|
||||
"groups": [
|
||||
["Group 2"]
|
||||
],
|
||||
"user_permissions": [],
|
||||
"password": "md5$seasalt$1e9bf2bf5606aa5c39852cc30f0f6f22",
|
||||
"email": "bob@example.com"
|
||||
}
|
||||
},
|
||||
{
|
||||
"pk": 4,
|
||||
"model": "customuser.customuser",
|
||||
"fields": {
|
||||
"username": "sam",
|
||||
"first_name": "Sam",
|
||||
"last_name": "Smith",
|
||||
"is_active": true,
|
||||
"is_superuser": false,
|
||||
"is_staff": true,
|
||||
"groups": [
|
||||
["Group 1"],
|
||||
["Group 2"]
|
||||
],
|
||||
"user_permissions": [],
|
||||
"password": "md5$seasalt$1e9bf2bf5606aa5c39852cc30f0f6f22",
|
||||
"email": "sam@example.com"
|
||||
}
|
||||
},
|
||||
{
|
||||
"pk": 5,
|
||||
"model": "customuser.customuser",
|
||||
"fields": {
|
||||
"username": "mary",
|
||||
"first_name": "Mary",
|
||||
"last_name": "Smith",
|
||||
"is_active": true,
|
||||
"is_superuser": false,
|
||||
"is_staff": true,
|
||||
"groups": [
|
||||
],
|
||||
"user_permissions": [
|
||||
["access_admin", "wagtailadmin", "admin"]
|
||||
],
|
||||
"password": "md5$seasalt$1e9bf2bf5606aa5c39852cc30f0f6f22",
|
||||
"email": "mary@example.com"
|
||||
}
|
||||
},
|
||||
{
|
||||
"pk": 6,
|
||||
"model": "customuser.customuser",
|
||||
"fields": {
|
||||
"username": "josh",
|
||||
"first_name": "Josh",
|
||||
"last_name": "Smith",
|
||||
"is_active": true,
|
||||
"is_superuser": false,
|
||||
"is_staff": true,
|
||||
"groups": [
|
||||
["Group 2"],
|
||||
["Group 3"]
|
||||
],
|
||||
"user_permissions": [],
|
||||
"password": "md5$seasalt$1e9bf2bf5606aa5c39852cc30f0f6f22",
|
||||
"email": "josh@example.com"
|
||||
}
|
||||
}
|
||||
|
||||
]
|
||||
|
|
Ładowanie…
Reference in New Issue