test_plugin.py 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. from functools import cached_property
  2. import orjson
  3. import responses
  4. from django.urls import reverse
  5. from sentry.testutils.cases import PluginTestCase
  6. from sentry_plugins.redmine.plugin import RedminePlugin
  7. class RedminePluginTest(PluginTestCase):
  8. @cached_property
  9. def plugin(self):
  10. return RedminePlugin()
  11. def test_conf_key(self):
  12. assert self.plugin.conf_key == "redmine"
  13. def test_entry_point(self):
  14. self.assertPluginInstalled("redmine", self.plugin)
  15. self.assertAppInstalled("redmine", "sentry_plugins.redmine")
  16. @responses.activate
  17. def test_config_validation(self):
  18. responses.add(responses.GET, "https://bugs.redmine.org")
  19. config = {
  20. "host": "https://bugs.redmine.org",
  21. "key": "supersecret",
  22. }
  23. self.plugin.validate_config(self.project, config)
  24. def test_no_secrets(self):
  25. self.login_as(self.user)
  26. self.plugin.set_option("key", "supersecret", self.project)
  27. url = reverse(
  28. "sentry-api-0-project-plugin-details",
  29. args=[self.organization.slug, self.project.slug, "redmine"],
  30. )
  31. res = self.client.get(url)
  32. config = orjson.loads(res.content)["config"]
  33. key_config = [item for item in config if item["name"] == "key"][0]
  34. assert key_config.get("type") == "secret"
  35. assert key_config.get("value") is None