-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
20 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -371,35 +371,36 @@ def test_update_plugin_auth(self, mock_sync_from_plugin_archive, mock_get, mock_ | |
self.assertEqual(response.status_code, 403) | ||
self.assertEqual(mock_sync_from_plugin_archive.call_count, 2) # Not extracted on auth failure | ||
|
||
@freeze_time("2021-08-25T22:09:14.252Z") | ||
def test_delete_plugin_auth(self, mock_get, mock_reload): | ||
repo_url = "https://github.com/PostHog/helloworldplugin" | ||
response = self.client.post("/api/organizations/@current/plugins/", {"url": repo_url}) | ||
self.assertEqual(response.status_code, 201) | ||
with freeze_time("2021-08-25T22:09:14.252Z"): | ||
repo_url = "https://github.com/PostHog/helloworldplugin" | ||
response = self.client.post("/api/organizations/@current/plugins/", {"url": repo_url}) | ||
self.assertEqual(response.status_code, 201) | ||
|
||
plugin_id = response.json()["id"] | ||
with freeze_time("2021-08-25T22:09:14.253Z"): | ||
plugin_id = response.json()["id"] | ||
|
||
api_url = "/api/organizations/@current/plugins/{}".format(response.json()["id"]) | ||
api_url = "/api/organizations/@current/plugins/{}".format(response.json()["id"]) | ||
|
||
for level in ( | ||
Organization.PluginsAccessLevel.NONE, | ||
Organization.PluginsAccessLevel.CONFIG, | ||
): | ||
self.organization.plugins_access_level = level | ||
for level in ( | ||
Organization.PluginsAccessLevel.NONE, | ||
Organization.PluginsAccessLevel.CONFIG, | ||
): | ||
self.organization.plugins_access_level = level | ||
self.organization.save() | ||
response = self.client.delete(api_url) | ||
self.assertEqual(response.status_code, 403) | ||
|
||
self.organization.plugins_access_level = Organization.PluginsAccessLevel.INSTALL | ||
self.organization.save() | ||
response = self.client.delete(api_url) | ||
self.assertEqual(response.status_code, 403) | ||
|
||
self.organization.plugins_access_level = Organization.PluginsAccessLevel.INSTALL | ||
self.organization.save() | ||
response = self.client.delete(api_url) | ||
self.assertEqual(response.status_code, 204) | ||
self.assert_plugin_activity( | ||
[ | ||
{ | ||
"user": {"first_name": "", "email": "[email protected]"}, | ||
"activity": "installed", | ||
"created_at": "2021-08-25T22:09:14.252000Z", | ||
"activity": "uninstalled", | ||
"created_at": "2021-08-25T22:09:14.253000Z", | ||
"scope": "Plugin", | ||
"item_id": str(plugin_id), | ||
"detail": { | ||
|
@@ -412,7 +413,7 @@ def test_delete_plugin_auth(self, mock_get, mock_reload): | |
}, | ||
{ | ||
"user": {"first_name": "", "email": "[email protected]"}, | ||
"activity": "uninstalled", | ||
"activity": "installed", | ||
"created_at": "2021-08-25T22:09:14.252000Z", | ||
"scope": "Plugin", | ||
"item_id": str(plugin_id), | ||
|