def register_extensions(): from sentry.plugins import plugins from sentry.plugins.utils import TestIssuePlugin2 plugins.register(TestIssuePlugin2) from sentry import integrations from sentry.integrations.bitbucket import BitbucketIntegrationProvider from sentry.integrations.example import ExampleIntegrationProvider from sentry.integrations.github import GitHubIntegrationProvider from sentry.integrations.github_enterprise import GitHubEnterpriseIntegrationProvider from sentry.integrations.jira import JiraIntegrationProvider from sentry.integrations.slack import SlackIntegrationProvider from sentry.integrations.vsts import VSTSIntegrationProvider integrations.register(BitbucketIntegrationProvider) integrations.register(ExampleIntegrationProvider) integrations.register(GitHubIntegrationProvider) integrations.register(GitHubEnterpriseIntegrationProvider) integrations.register(JiraIntegrationProvider) integrations.register(SlackIntegrationProvider) integrations.register(VSTSIntegrationProvider) from sentry.plugins import bindings from sentry.plugins.providers.dummy import DummyRepositoryProvider bindings.add('repository.provider', DummyRepositoryProvider, id='dummy')
def register_plugins(settings): from pkg_resources import iter_entry_points from sentry.plugins import plugins # entry_points={ # 'sentry.plugins': [ # 'phabricator = sentry_phabricator.plugins:PhabricatorPlugin' # ], # }, for ep in iter_entry_points('sentry.plugins'): try: plugin = ep.load() except Exception: import traceback click.echo("Failed to load plugin %r:\n%s" % (ep.name, traceback.format_exc()), err=True) else: plugins.register(plugin) for plugin in plugins.all(version=None): init_plugin(plugin) from sentry import integrations from sentry.utils.imports import import_string for integration_path in settings.SENTRY_DEFAULT_INTEGRATIONS: try: integration_cls = import_string(integration_path) except Exception: import traceback click.echo("Failed to load integration %r:\n%s" % (integration_path, traceback.format_exc()), err=True) else: integrations.register(integration_cls)
def register_extensions(): from sentry.plugins import plugins from sentry.plugins.utils import TestIssuePlugin2 plugins.register(TestIssuePlugin2) from sentry import integrations from sentry.integrations.bitbucket import BitbucketIntegrationProvider from sentry.integrations.example import ExampleIntegrationProvider from sentry.integrations.github import GitHubIntegrationProvider from sentry.integrations.github_enterprise import GitHubEnterpriseIntegrationProvider from sentry.integrations.jira import JiraIntegrationProvider from sentry.integrations.slack import SlackIntegrationProvider from sentry.integrations.vsts import VstsIntegrationProvider integrations.register(BitbucketIntegrationProvider) integrations.register(ExampleIntegrationProvider) integrations.register(GitHubIntegrationProvider) integrations.register(GitHubEnterpriseIntegrationProvider) integrations.register(JiraIntegrationProvider) integrations.register(SlackIntegrationProvider) integrations.register(VstsIntegrationProvider) from sentry.plugins import bindings from sentry.plugins.providers.dummy import DummyRepositoryProvider bindings.add('repository.provider', DummyRepositoryProvider, id='dummy')
def setUp(self): super(PluginTestCase, self).setUp() # Old plugins, plugin is a class, new plugins, it's an instance # New plugins don't need to be registered if isinstance(self.plugin, (type, types.ClassType)): plugins.register(self.plugin) self.addCleanup(plugins.unregister, self.plugin)
def pytest_configure(config): settings.INSTALLED_APPS = tuple(settings.INSTALLED_APPS) + ( 'sentry_zendesk', ) from sentry.plugins import plugins from sentry_zendesk.plugin import ZendeskPlugin plugins.register(ZendeskPlugin)
def register_extensions(): from sentry.plugins import plugins from sentry.plugins.utils import TestIssuePlugin2 plugins.register(TestIssuePlugin2) from sentry import integrations from sentry.integrations.example import ExampleIntegration from sentry.integrations.slack import SlackIntegration integrations.register(ExampleIntegration) integrations.register(SlackIntegration) from sentry.plugins import bindings from sentry.plugins.providers.dummy import DummyRepositoryProvider bindings.add('repository.provider', DummyRepositoryProvider, id='dummy')
def register_plugins(settings): from pkg_resources import iter_entry_points from sentry.plugins import plugins # entry_points={ # 'sentry.plugins': [ # 'phabricator = sentry_phabricator.plugins:PhabricatorPlugin' # ], # }, for ep in iter_entry_points('sentry.plugins'): try: plugin = ep.load() except Exception: import traceback click.echo( "Failed to load plugin %r:\n%s" % (ep.name, traceback.format_exc()), err=True ) else: plugins.register(plugin) for plugin in plugins.all(version=None): init_plugin(plugin) from sentry import integrations from sentry.utils.imports import import_string for integration_path in settings.SENTRY_DEFAULT_INTEGRATIONS: try: integration_cls = import_string(integration_path) except Exception: import traceback click.echo( "Failed to load integration %r:\n%s" % (integration_path, traceback.format_exc()), err=True ) else: integrations.register(integration_cls) for integration in integrations.all(): try: integration.setup() except AttributeError: pass
def register_plugins(settings): from pkg_resources import iter_entry_points from sentry.plugins import plugins # entry_points={ # 'sentry.plugins': [ # 'phabricator = sentry_phabricator.plugins:PhabricatorPlugin' # ], # }, for ep in iter_entry_points('sentry.plugins'): try: plugin = ep.load() except Exception: import traceback click.echo("Failed to load plugin %r:\n%s" % (ep.name, traceback.format_exc()), err=True) else: plugins.register(plugin) for plugin in plugins.all(version=None): init_plugin(plugin)
def register_plugins(settings): from pkg_resources import iter_entry_points from sentry.plugins import bindings, plugins # entry_points={ # 'sentry.plugins': [ # 'phabricator = sentry_phabricator.plugins:PhabricatorPlugin' # ], # }, for ep in iter_entry_points('sentry.plugins'): try: plugin = ep.load() except Exception: import traceback click.echo("Failed to load plugin %r:\n%s" % (ep.name, traceback.format_exc()), err=True) else: plugins.register(plugin) for plugin in plugins.all(version=None): plugin.setup(bindings)
def register_extensions(): from sentry.plugins import plugins from sentry.plugins.utils import TestIssuePlugin2 plugins.register(TestIssuePlugin2) from sentry import integrations from sentry.integrations.bitbucket import BitbucketIntegrationProvider from sentry.integrations.example import ( ExampleIntegrationProvider, AliasedIntegrationProvider, ExampleRepositoryProvider, ) from sentry.integrations.github import GitHubIntegrationProvider from sentry.integrations.github_enterprise import GitHubEnterpriseIntegrationProvider from sentry.integrations.gitlab import GitlabIntegrationProvider from sentry.integrations.jira import JiraIntegrationProvider from sentry.integrations.jira_server import JiraServerIntegrationProvider from sentry.integrations.slack import SlackIntegrationProvider from sentry.integrations.vsts import VstsIntegrationProvider from sentry.integrations.vsts_extension import VstsExtensionIntegrationProvider integrations.register(BitbucketIntegrationProvider) integrations.register(ExampleIntegrationProvider) integrations.register(AliasedIntegrationProvider) integrations.register(GitHubIntegrationProvider) integrations.register(GitHubEnterpriseIntegrationProvider) integrations.register(GitlabIntegrationProvider) integrations.register(JiraIntegrationProvider) integrations.register(JiraServerIntegrationProvider) integrations.register(SlackIntegrationProvider) integrations.register(VstsIntegrationProvider) integrations.register(VstsExtensionIntegrationProvider) from sentry.plugins import bindings from sentry.plugins.providers.dummy import DummyRepositoryProvider bindings.add("repository.provider", DummyRepositoryProvider, id="dummy") bindings.add("integration-repository.provider", ExampleRepositoryProvider, id="integrations:example")
def pytest_configure(config): settings.INSTALLED_APPS = tuple( settings.INSTALLED_APPS) + ('sentry_openproject', ) from sentry.plugins import plugins from sentry_openproject.plugin import OpenProjectPlugin plugins.register(OpenProjectPlugin)
def register_mock_plugins(): plugins.register(VstsPlugin) plugins.register(GitHubPlugin) plugins.register(BitbucketPlugin)
def setUp(self): super(PluginTestCase, self).setUp() plugins.register(self.plugin) self.addCleanup(plugins.unregister, self.plugin)
from __future__ import absolute_import from sentry.integrations.example import ExampleIntegrationProvider from sentry.mediators.plugins import Migrator from sentry.models import Integration, Repository from sentry.plugins import plugins from sentry.plugins.bases.issue2 import IssuePlugin2 from sentry.testutils import TestCase class ExamplePlugin(IssuePlugin2): slug = 'example' plugins.register(ExamplePlugin) class MigratorTest(TestCase): def setUp(self): super(MigratorTest, self).setUp() self.organization = self.create_organization() self.project = self.create_project(organization=self.organization) self.integration = Integration.objects.create( provider=ExampleIntegrationProvider.key, ) self.migrator = Migrator( integration=self.integration, organization=self.organization,
def pytest_configure(config): settings.INSTALLED_APPS = tuple(settings.INSTALLED_APPS) + ( 'sentry_plugins.amazon_sqs', 'sentry_plugins.asana', 'sentry_plugins.bitbucket', 'sentry_plugins.heroku', 'sentry_plugins.hipchat_ac', 'sentry_plugins.github', 'sentry_plugins.gitlab', 'sentry_plugins.pagerduty', 'sentry_plugins.pivotal', 'sentry_plugins.pushover', 'sentry_plugins.jira', 'sentry_plugins.segment', 'sentry_plugins.sessionstack', 'sentry_plugins.slack', 'sentry_plugins.splunk', 'sentry_plugins.victorops', ) # TODO(dcramer): we need a PluginAPITestCase that can do register/unregister from sentry.plugins import plugins from sentry_plugins.amazon_sqs.plugin import AmazonSQSPlugin from sentry_plugins.asana.plugin import AsanaPlugin from sentry_plugins.bitbucket.plugin import BitbucketPlugin from sentry_plugins.github.plugin import GitHubPlugin from sentry_plugins.gitlab.plugin import GitLabPlugin from sentry_plugins.heroku.plugin import HerokuPlugin from sentry_plugins.hipchat_ac.plugin import HipchatPlugin from sentry_plugins.jira.plugin import JiraPlugin from sentry_plugins.pagerduty.plugin import PagerDutyPlugin from sentry_plugins.pivotal.plugin import PivotalPlugin from sentry_plugins.pushover.plugin import PushoverPlugin from sentry_plugins.segment.plugin import SegmentPlugin from sentry_plugins.sessionstack.plugin import SessionStackPlugin from sentry_plugins.slack.plugin import SlackPlugin from sentry_plugins.splunk.plugin import SplunkPlugin from sentry_plugins.victorops.plugin import VictorOpsPlugin from sentry_plugins.vsts.plugin import VstsPlugin plugins.register(AmazonSQSPlugin) plugins.register(AsanaPlugin) plugins.register(BitbucketPlugin) plugins.register(GitHubPlugin) plugins.register(GitLabPlugin) plugins.register(HerokuPlugin) plugins.register(HipchatPlugin) plugins.register(JiraPlugin) plugins.register(PagerDutyPlugin) plugins.register(PivotalPlugin) plugins.register(PushoverPlugin) plugins.register(SegmentPlugin) plugins.register(SessionStackPlugin) plugins.register(SlackPlugin) plugins.register(SplunkPlugin) plugins.register(VictorOpsPlugin) plugins.register(VstsPlugin) settings.ASANA_CLIENT_ID = 'abc' settings.ASANA_CLIENT_SECRET = '123' settings.BITBUCKET_CONSUMER_KEY = 'abc' settings.BITBUCKET_CONSUMER_SECRET = '123' settings.GITHUB_APP_ID = 'abc' settings.GITHUB_API_SECRET = '123' settings.GITHUB_APPS_APP_ID = 'abc' settings.GITHUB_APPS_API_SECRET = '123' # this isn't the real secret settings.SENTRY_OPTIONS[ 'github.integration-hook-secret'] = 'b3002c3e321d4b7880360d397db2ccfd'
def pytest_configure(config): # HACK: Only needed for testing! os.environ.setdefault('_SENTRY_SKIP_CONFIGURATION', '1') os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'sentry.conf.server') if not settings.configured: # only configure the db if its not already done test_db = os.environ.get('DB', 'postgres') if test_db == 'mysql': settings.DATABASES['default'].update({ 'ENGINE': 'django.db.backends.mysql', 'NAME': 'sentry', 'USER': '******', 'HOST': '127.0.0.1', }) # mysql requires running full migration all the time settings.SOUTH_TESTS_MIGRATE = True elif test_db == 'postgres': settings.DATABASES['default'].update({ 'ENGINE': 'sentry.db.postgres', 'USER': '******', 'NAME': 'sentry', }) # postgres requires running full migration all the time # since it has to install stored functions which come from # an actual migration. settings.SOUTH_TESTS_MIGRATE = True elif test_db == 'sqlite': settings.DATABASES['default'].update({ 'ENGINE': 'django.db.backends.sqlite3', 'NAME': ':memory:', }) settings.SOUTH_TESTS_MIGRATE = os.environ.get( 'SENTRY_SOUTH_TESTS_MIGRATE', '1') == '1' else: raise RuntimeError('oops, wrong database: %r' % test_db) settings.TEMPLATE_DEBUG = True # Disable static compiling in tests settings.STATIC_BUNDLES = {} # override a few things with our test specifics settings.INSTALLED_APPS = tuple(settings.INSTALLED_APPS) + ('tests', ) # Need a predictable key for tests that involve checking signatures settings.SENTRY_PUBLIC = False if not settings.SENTRY_CACHE: settings.SENTRY_CACHE = 'sentry.cache.django.DjangoCache' settings.SENTRY_CACHE_OPTIONS = {} # This speeds up the tests considerably, pbkdf2 is by design, slow. settings.PASSWORD_HASHERS = [ 'django.contrib.auth.hashers.MD5PasswordHasher', ] # Replace real sudo middleware with our mock sudo middleware # to assert that the user is always in sudo mode middleware = list(settings.MIDDLEWARE_CLASSES) sudo = middleware.index('sentry.middleware.sudo.SudoMiddleware') middleware[sudo] = 'sentry.testutils.middleware.SudoMiddleware' settings.MIDDLEWARE_CLASSES = tuple(middleware) # enable draft features settings.SENTRY_OPTIONS['mail.enable-replies'] = True settings.SENTRY_ALLOW_ORIGIN = '*' settings.SENTRY_TSDB = 'sentry.tsdb.inmemory.InMemoryTSDB' settings.SENTRY_TSDB_OPTIONS = {} settings.BROKER_BACKEND = 'memory' settings.BROKER_URL = None settings.CELERY_ALWAYS_EAGER = False settings.CELERY_EAGER_PROPAGATES_EXCEPTIONS = True settings.DEBUG_VIEWS = True settings.DISABLE_RAVEN = True settings.CACHES = { 'default': { 'BACKEND': 'django.core.cache.backends.locmem.LocMemCache', } } if not hasattr(settings, 'SENTRY_OPTIONS'): settings.SENTRY_OPTIONS = {} settings.SENTRY_OPTIONS.update({ 'redis.clusters': { 'default': { 'hosts': { 0: { 'db': 9, }, }, }, }, 'mail.backend': 'django.core.mail.backends.locmem.EmailBackend', 'system.url-prefix': 'http://testserver', }) # django mail uses socket.getfqdn which doesn't play nice if our # networking isn't stable patcher = mock.patch('socket.getfqdn', return_value='localhost') patcher.start() from sentry.runner.initializer import (bootstrap_options, configure_structlog, initialize_receivers, fix_south, bind_cache_to_option_store) bootstrap_options(settings) configure_structlog() fix_south(settings) bind_cache_to_option_store() initialize_receivers() from sentry.plugins import plugins from sentry.plugins.utils import TestIssuePlugin2 plugins.register(TestIssuePlugin2) from sentry.utils.redis import clusters with clusters.get('default').all() as client: client.flushdb() # force celery registration from sentry.celery import app # NOQA # disable DISALLOWED_IPS from sentry import http http.DISALLOWED_IPS = set()
def pytest_configure(config): settings.INSTALLED_APPS = tuple(settings.INSTALLED_APPS) + ( 'sentry_plugins.asana', 'sentry_plugins.bitbucket', 'sentry_plugins.hipchat_ac', 'sentry_plugins.github', 'sentry_plugins.gitlab', 'sentry_plugins.pagerduty', 'sentry_plugins.pivotal', 'sentry_plugins.pushover', 'sentry_plugins.jira', 'sentry_plugins.segment', 'sentry_plugins.sessionstack', 'sentry_plugins.slack', 'sentry_plugins.victorops', ) # TODO(dcramer): we need a PluginAPITestCase that can do register/unregister from sentry.plugins import plugins from sentry_plugins.asana.plugin import AsanaPlugin from sentry_plugins.bitbucket.plugin import BitbucketPlugin from sentry_plugins.github.plugin import GitHubPlugin from sentry_plugins.gitlab.plugin import GitLabPlugin from sentry_plugins.hipchat_ac.plugin import HipchatPlugin from sentry_plugins.jira.plugin import JiraPlugin from sentry_plugins.pagerduty.plugin import PagerDutyPlugin from sentry_plugins.pivotal.plugin import PivotalPlugin from sentry_plugins.pushover.plugin import PushoverPlugin from sentry_plugins.segment.plugin import SegmentPlugin from sentry_plugins.sessionstack.plugin import SessionStackPlugin from sentry_plugins.slack.plugin import SlackPlugin from sentry_plugins.victorops.plugin import VictorOpsPlugin plugins.register(AsanaPlugin) plugins.register(BitbucketPlugin) plugins.register(GitHubPlugin) plugins.register(GitLabPlugin) plugins.register(HipchatPlugin) plugins.register(JiraPlugin) plugins.register(PagerDutyPlugin) plugins.register(PivotalPlugin) plugins.register(PushoverPlugin) plugins.register(SegmentPlugin) plugins.register(SessionStackPlugin) plugins.register(SlackPlugin) plugins.register(VictorOpsPlugin) settings.ASANA_CLIENT_ID = 'abc' settings.ASANA_CLIENT_SECRET = '123' settings.BITBUCKET_CONSUMER_KEY = 'abc' settings.BITBUCKET_CONSUMER_SECRET = '123' settings.GITHUB_APP_ID = 'abc' settings.GITHUB_API_SECRET = '123'
def pytest_configure(config): # HACK: Only needed for testing! os.environ.setdefault('_SENTRY_SKIP_CONFIGURATION', '1') os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'sentry.conf.server') if not settings.configured: # only configure the db if its not already done test_db = os.environ.get('DB', 'postgres') if test_db == 'mysql': settings.DATABASES['default'].update({ 'ENGINE': 'django.db.backends.mysql', 'NAME': 'sentry', 'USER': '******', 'HOST': '127.0.0.1', }) # mysql requires running full migration all the time settings.SOUTH_TESTS_MIGRATE = True elif test_db == 'postgres': settings.DATABASES['default'].update({ 'ENGINE': 'sentry.db.postgres', 'USER': '******', 'NAME': 'sentry', }) # postgres requires running full migration all the time # since it has to install stored functions which come from # an actual migration. settings.SOUTH_TESTS_MIGRATE = True elif test_db == 'sqlite': settings.DATABASES['default'].update({ 'ENGINE': 'django.db.backends.sqlite3', 'NAME': ':memory:', }) settings.SOUTH_TESTS_MIGRATE = os.environ.get('SENTRY_SOUTH_TESTS_MIGRATE', '1') == '1' else: raise RuntimeError('oops, wrong database: %r' % test_db) settings.TEMPLATE_DEBUG = True # Disable static compiling in tests settings.STATIC_BUNDLES = {} # override a few things with our test specifics settings.INSTALLED_APPS = tuple(settings.INSTALLED_APPS) + ( 'tests', ) # Need a predictable key for tests that involve checking signatures settings.SENTRY_PUBLIC = False if not settings.SENTRY_CACHE: settings.SENTRY_CACHE = 'sentry.cache.django.DjangoCache' settings.SENTRY_CACHE_OPTIONS = {} # This speeds up the tests considerably, pbkdf2 is by design, slow. settings.PASSWORD_HASHERS = [ 'django.contrib.auth.hashers.MD5PasswordHasher', ] settings.AUTH_PASSWORD_VALIDATORS = [] # Replace real sudo middleware with our mock sudo middleware # to assert that the user is always in sudo mode middleware = list(settings.MIDDLEWARE_CLASSES) sudo = middleware.index('sentry.middleware.sudo.SudoMiddleware') middleware[sudo] = 'sentry.testutils.middleware.SudoMiddleware' settings.MIDDLEWARE_CLASSES = tuple(middleware) # enable draft features settings.SENTRY_OPTIONS['mail.enable-replies'] = True settings.SENTRY_ALLOW_ORIGIN = '*' settings.SENTRY_TSDB = 'sentry.tsdb.inmemory.InMemoryTSDB' settings.SENTRY_TSDB_OPTIONS = {} settings.BROKER_BACKEND = 'memory' settings.BROKER_URL = None settings.CELERY_ALWAYS_EAGER = False settings.CELERY_EAGER_PROPAGATES_EXCEPTIONS = True settings.DEBUG_VIEWS = True settings.SENTRY_ENCRYPTION_SCHEMES = () settings.DISABLE_RAVEN = True settings.CACHES = { 'default': { 'BACKEND': 'django.core.cache.backends.locmem.LocMemCache', } } if not hasattr(settings, 'SENTRY_OPTIONS'): settings.SENTRY_OPTIONS = {} settings.SENTRY_OPTIONS.update({ 'redis.clusters': { 'default': { 'hosts': { 0: { 'db': 9, }, }, }, }, 'mail.backend': 'django.core.mail.backends.locmem.EmailBackend', 'system.url-prefix': 'http://testserver', }) # django mail uses socket.getfqdn which doesn't play nice if our # networking isn't stable patcher = mock.patch('socket.getfqdn', return_value='localhost') patcher.start() from sentry.runner.initializer import ( bootstrap_options, configure_structlog, initialize_receivers, fix_south, bind_cache_to_option_store) bootstrap_options(settings) configure_structlog() fix_south(settings) bind_cache_to_option_store() initialize_receivers() from sentry.plugins import plugins from sentry.plugins.utils import TestIssuePlugin2 plugins.register(TestIssuePlugin2) from sentry.plugins import bindings from sentry.plugins.providers.dummy import DummyRepositoryProvider bindings.add('repository.provider', DummyRepositoryProvider, id='dummy') from sentry.utils.redis import clusters with clusters.get('default').all() as client: client.flushdb() # force celery registration from sentry.celery import app # NOQA # disable DISALLOWED_IPS from sentry import http http.DISALLOWED_IPS = set()
from sentry.models import Identity, Integration, OrganizationIntegration from sentry.testutils import IntegrationTestCase from sentry.integrations.example import ( ExampleIntegrationProvider, AliasedIntegrationProvider, ) from sentry.models import Repository from sentry.plugins import plugins from sentry.plugins.bases.issue2 import IssuePlugin2 class ExamplePlugin(IssuePlugin2): slug = 'example' plugins.register(ExamplePlugin) def naive_build_integration(data): return data @patch('sentry.integrations.example.ExampleIntegrationProvider.build_integration', side_effect=naive_build_integration) class FinishPipelineTestCase(IntegrationTestCase): provider = ExampleIntegrationProvider def setUp(self): super(FinishPipelineTestCase, self).setUp() self.external_id = 'dummy_id-123' self.provider.needs_default_identity = False
from __future__ import absolute_import from sentry.plugins import plugins, IssueTrackingPlugin2 class VstsPlugin(IssueTrackingPlugin2): slug = 'vsts' conf_key = slug class GitHubPlugin(IssueTrackingPlugin2): slug = 'github' conf_key = slug class BitbucketPlugin(IssueTrackingPlugin2): slug = 'bitbucket' conf_key = slug plugins.register(VstsPlugin) plugins.register(GitHubPlugin) plugins.register(BitbucketPlugin)