kfet/test_views: more eloquent test names
This commit is contained in:
parent
a4ecd344d0
commit
d37c41e99f
1 changed files with 32 additions and 24 deletions
|
@ -209,14 +209,14 @@ class AccountReadViewTests(ViewTestCaseMixin, TestCase):
|
|||
auth_user = "team"
|
||||
auth_forbidden = [None, "user"]
|
||||
|
||||
# Forbidden users should get a 404 here, to avoid leaking trigrams
|
||||
# Users with forbidden access users should get a 404 here, to avoid leaking trigrams
|
||||
# See issue #224
|
||||
def test_forbidden(self):
|
||||
for user in self.auth_forbidden:
|
||||
self.check_forbidden(user, self.url_expected)
|
||||
self.check_forbidden(user, "/k-fet/accounts/NEX")
|
||||
self.assertRedirectsToLoginOr404(user, self.url_expected)
|
||||
self.assertRedirectsToLoginOr404(user, "/k-fet/accounts/NEX")
|
||||
|
||||
def check_forbidden(self, user, url):
|
||||
def assertRedirectsToLoginOr404(self, user, url):
|
||||
client = Client()
|
||||
if user is None:
|
||||
response = client.get(url)
|
||||
|
@ -315,15 +315,17 @@ class AccountUpdateViewTests(ViewTestCaseMixin, TestCase):
|
|||
"team1": create_team("team1", "101", perms=["kfet.change_account"]),
|
||||
}
|
||||
|
||||
# Forbidden users should get a 404 here, to avoid leaking trigrams
|
||||
# Users with forbidden access users should get a 404 here, to avoid leaking trigrams
|
||||
# See issue #224
|
||||
def test_forbidden(self):
|
||||
for method in ["get", "post"]:
|
||||
for user in self.auth_forbidden:
|
||||
self.check_forbidden(user, method, self.url_expected)
|
||||
self.check_forbidden(user, method, "/k-fet/accounts/NEX/edit")
|
||||
self.assertRedirectsToLoginOr404(user, method, self.url_expected)
|
||||
self.assertRedirectsToLoginOr404(
|
||||
user, method, "/k-fet/accounts/NEX/edit"
|
||||
)
|
||||
|
||||
def check_forbidden(self, user, method, url):
|
||||
def assertRedirectsToLoginOr404(self, user, method, url):
|
||||
client = Client()
|
||||
meth = getattr(client, method)
|
||||
if user is None:
|
||||
|
@ -595,14 +597,16 @@ class AccountStatOperationListViewTests(ViewTestCaseMixin, TestCase):
|
|||
def get_users_extra(self):
|
||||
return {"user1": create_user("user1", "001")}
|
||||
|
||||
# Forbidden users should get a 404 here, to avoid leaking trigrams
|
||||
# Users with forbidden access users should get a 404 here, to avoid leaking trigrams
|
||||
# See issue #224
|
||||
def test_forbidden(self):
|
||||
for user in self.auth_forbidden:
|
||||
self.check_forbidden(user, self.url_expected)
|
||||
self.check_forbidden(user, "/k-fet/accounts/NEX/stat/operations/list")
|
||||
self.assertRedirectsToLoginOr404(user, self.url_expected)
|
||||
self.assertRedirectsToLoginOr404(
|
||||
user, "/k-fet/accounts/NEX/stat/operations/list"
|
||||
)
|
||||
|
||||
def check_forbidden(self, user, url):
|
||||
def assertRedirectsToLoginOr404(self, user, url):
|
||||
client = Client()
|
||||
if user is None:
|
||||
response = client.get(url)
|
||||
|
@ -675,14 +679,16 @@ class AccountStatOperationViewTests(ViewTestCaseMixin, TestCase):
|
|||
auth_user = "user1"
|
||||
auth_forbidden = [None, "user", "team"]
|
||||
|
||||
# Forbidden users should get a 404 here, to avoid leaking trigrams
|
||||
# Users with forbidden access users should get a 404 here, to avoid leaking trigrams
|
||||
# See issue #224
|
||||
def test_forbidden(self):
|
||||
for user in self.auth_forbidden:
|
||||
self.check_forbidden(user, self.url_expected)
|
||||
self.check_forbidden(user, "/k-fet/accounts/NEX/stat/operations")
|
||||
self.assertRedirectsToLoginOr404(user, self.url_expected)
|
||||
self.assertRedirectsToLoginOr404(
|
||||
user, "/k-fet/accounts/NEX/stat/operations"
|
||||
)
|
||||
|
||||
def check_forbidden(self, user, url):
|
||||
def assertRedirectsToLoginOr404(self, user, url):
|
||||
client = Client()
|
||||
if user is None:
|
||||
response = client.get(url)
|
||||
|
@ -710,14 +716,16 @@ class AccountStatBalanceListViewTests(ViewTestCaseMixin, TestCase):
|
|||
auth_user = "user1"
|
||||
auth_forbidden = [None, "user", "team"]
|
||||
|
||||
# Forbidden users should get a 404 here, to avoid leaking trigrams
|
||||
# Users with forbidden access users should get a 404 here, to avoid leaking trigrams
|
||||
# See issue #224
|
||||
def test_forbidden(self):
|
||||
for user in self.auth_forbidden:
|
||||
self.check_forbidden(user, self.url_expected)
|
||||
self.check_forbidden(user, "/k-fet/accounts/NEX/stat/balance/list")
|
||||
self.assertRedirectsToLoginOr404(user, self.url_expected)
|
||||
self.assertRedirectsToLoginOr404(
|
||||
user, "/k-fet/accounts/NEX/stat/balance/list"
|
||||
)
|
||||
|
||||
def check_forbidden(self, user, url):
|
||||
def assertRedirectsToLoginOr404(self, user, url):
|
||||
client = Client()
|
||||
if user is None:
|
||||
response = client.get(url)
|
||||
|
@ -774,14 +782,14 @@ class AccountStatBalanceViewTests(ViewTestCaseMixin, TestCase):
|
|||
auth_user = "user1"
|
||||
auth_forbidden = [None, "user", "team"]
|
||||
|
||||
# Forbidden users should get a 404 here, to avoid leaking trigrams
|
||||
# Users with forbidden access users should get a 404 here, to avoid leaking trigrams
|
||||
# See issue #224
|
||||
def test_forbidden(self):
|
||||
for user in self.auth_forbidden:
|
||||
self.check_forbidden(user, self.url_expected)
|
||||
self.check_forbidden(user, "/k-fet/accounts/NEX/stat/balance")
|
||||
self.assertRedirectsToLoginOr404(user, self.url_expected)
|
||||
self.assertRedirectsToLoginOr404(user, "/k-fet/accounts/NEX/stat/balance")
|
||||
|
||||
def check_forbidden(self, user, url):
|
||||
def assertRedirectsToLoginOr404(self, user, url):
|
||||
client = Client()
|
||||
if user is None:
|
||||
response = client.get(url)
|
||||
|
|
Loading…
Reference in a new issue