Пример #1
0
 def setup(self):
     from sentry.plugins import bindings
     bindings.add(
         'integration-repository.provider',
         BitbucketRepositoryProvider,
         id='integrations:%s' % self.key,
     )
Пример #2
0
 def setup(self):
     from sentry.plugins import bindings
     bindings.add(
         'integration-repository.provider',
         GitHubRepositoryProvider,
         id='integrations:github',
     )
Пример #3
0
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')
Пример #4
0
 def setup(self):
     from sentry.plugins import bindings
     bindings.add(
         'integration-repository.provider',
         VstsRepositoryProvider,
         id='integrations:vsts',
     )
Пример #5
0
 def setup(self):
     from sentry.plugins import bindings
     bindings.add(
         'integration-repository.provider',
         GitHubRepositoryProvider,
         id='integrations:github',
     )
Пример #6
0
 def setup(self):
     from sentry.plugins import bindings
     bindings.add(
         'integration-repository.provider',
         BitbucketRepositoryProvider,
         id='integrations:bitbucket',
     )
Пример #7
0
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')
Пример #8
0
 def setup(self):
     from sentry.plugins import bindings
     bindings.add(
         'integration-repository.provider',
         VstsRepositoryProvider,
         id='integrations:vsts',
     )
Пример #9
0
    def setup(self):
        from sentry.plugins import bindings

        bindings.add(
            "integration-repository.provider",
            GitHubEnterpriseRepositoryProvider,
            id="integrations:github_enterprise",
        )
Пример #10
0
    def setup(self):
        from sentry.plugins import bindings

        bindings.add(
            "integration-repository.provider",
            BitbucketRepositoryProvider,
            id="integrations:%s" % self.key,
        )
Пример #11
0
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')
Пример #12
0
    def test_integration_repository(self):
        # Add binding in case they aren't set.
        bindings.add(
            'integration-repository.provider',
            GitHubRepositoryProvider,
            id='integrations:github',
        )

        user = self.create_user()
        project = self.create_project()
        release = Release.objects.create(
            organization_id=project.organization_id,
            version=uuid4().hex,
        )
        release.add_project(project)
        repository = Repository.objects.create(
            organization_id=project.organization_id,
            name='test/test',
            provider='integrations:github',
            url='https://github.com/test/test')
        commit_author = CommitAuthor.objects.create(
            name='stebe',
            email='*****@*****.**',
            organization_id=project.organization_id,
        )
        pull_request = PullRequest.objects.create(
            organization_id=project.organization_id,
            repository_id=repository.id,
            key='9',
            author=commit_author,
            message='waddap',
            title="cool pr")

        result = serialize(pull_request, user)

        assert result['externalUrl'] == 'https://github.com/test/test/pulls/9'
        assert result['message'] == 'waddap'
        assert result['title'] == 'cool pr'
        assert result['repository']['name'] == 'test/test'
        assert result['author'] == {
            'name': 'stebe',
            'email': '*****@*****.**'
        }
Пример #13
0
    def test_integration_repository(self):
        # Add binding in case they aren't set.
        bindings.add(
            'integration-repository.provider',
            GitHubRepositoryProvider,
            id='integrations:github',
        )

        user = self.create_user()
        project = self.create_project()
        release = Release.objects.create(
            organization_id=project.organization_id,
            version=uuid4().hex,
        )
        release.add_project(project)
        repository = Repository.objects.create(
            organization_id=project.organization_id,
            name='test/test',
            provider='integrations:github',
            url='https://github.com/test/test'
        )
        commit_author = CommitAuthor.objects.create(
            name='stebe',
            email='*****@*****.**',
            organization_id=project.organization_id,
        )
        pull_request = PullRequest.objects.create(
            organization_id=project.organization_id,
            repository_id=repository.id,
            key='9',
            author=commit_author,
            message='waddap',
            title="cool pr"
        )

        result = serialize(pull_request, user)

        assert result['externalUrl'] == 'https://github.com/test/test/pull/9'
        assert result['message'] == 'waddap'
        assert result['title'] == 'cool pr'
        assert result['repository']['name'] == 'test/test'
        assert result['author'] == {'name': 'stebe', 'email': '*****@*****.**'}
Пример #14
0
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")
Пример #15
0
    def test_integration_repository(self):
        # Add binding in case they aren't set.
        bindings.add("integration-repository.provider",
                     GitHubRepositoryProvider,
                     id="integrations:github")

        user = self.create_user()
        project = self.create_project()
        release = Release.objects.create(
            organization_id=project.organization_id, version=uuid4().hex)
        release.add_project(project)
        repository = Repository.objects.create(
            organization_id=project.organization_id,
            name="test/test",
            provider="integrations:github",
            url="https://github.com/test/test",
        )
        commit_author = CommitAuthor.objects.create(
            name="stebe",
            email="*****@*****.**",
            organization_id=project.organization_id)
        pull_request = PullRequest.objects.create(
            organization_id=project.organization_id,
            repository_id=repository.id,
            key="9",
            author=commit_author,
            message="waddap",
            title="cool pr",
        )

        result = serialize(pull_request, user)

        assert result["externalUrl"] == "https://github.com/test/test/pull/9"
        assert result["message"] == "waddap"
        assert result["title"] == "cool pr"
        assert result["repository"]["name"] == "test/test"
        assert result["author"] == {
            "name": "stebe",
            "email": "*****@*****.**"
        }
Пример #16
0
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()
Пример #17
0
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()
Пример #18
0
    def setup(self):
        from sentry.plugins import bindings

        bindings.add("integration-repository.provider",
                     GitlabRepositoryProvider,
                     id="integrations:gitlab")