|
36 | 36 |
|
37 | 37 | TEST_PASSWORD = str(uuid.uuid4()) |
38 | 38 |
|
| 39 | +APIToken = apps.get_model("scanpipe", "APIToken") |
39 | 40 | login_url = reverse("login") |
40 | 41 | project_list_url = reverse("project_list") |
41 | 42 | logout_url = reverse("logout") |
@@ -112,12 +113,22 @@ def test_scancodeio_auth_logout_view(self): |
112 | 113 |
|
113 | 114 | def test_scancodeio_account_profile_view(self): |
114 | 115 | self.client.login(username=self.basic_user.username, password=TEST_PASSWORD) |
115 | | - APIToken = apps.get_model("scanpipe", "APIToken") |
| 116 | + |
| 117 | + expected1 = "No API key created." |
| 118 | + expected2 = "Generate API key" |
| 119 | + expected3 = "Revoke API key" |
| 120 | + |
| 121 | + response = self.client.get(profile_url) |
| 122 | + self.assertContains(response, expected1) |
| 123 | + self.assertContains(response, expected2) |
| 124 | + self.assertNotContains(response, expected3) |
| 125 | + |
116 | 126 | APIToken.create_token(user=self.basic_user) |
117 | 127 | response = self.client.get(profile_url) |
118 | | - expected = '<label class="label">API Key</label>' |
119 | | - self.assertContains(response, expected, html=True) |
120 | | - # self.assertContains(response, self.basic_user.auth.key) |
| 128 | + self.assertNotContains(response, expected1) |
| 129 | + self.assertContains(response, expected2) |
| 130 | + self.assertContains(response, expected3) |
| 131 | + self.assertContains(response, self.basic_user.api_token.prefix) |
121 | 132 |
|
122 | 133 | def test_scancodeio_auth_views_are_protected(self): |
123 | 134 | a_uuid = uuid.uuid4() |
|
0 commit comments