예제 #1
0
def test_app_delete_eks(aws, app, authz, helm):
    with patch("controlpanel.api.aws.settings.EKS", True):
        cluster.App(app).delete()

    aws.delete_role.assert_called_with(app.iam_role_name)
    authz.delete_group.assert_called_with(group_name=app.slug)
    helm.delete_eks.assert_called_with(cluster.App.APPS_NS, app.release_name)
def test_app_url(k8s_client, app, ingresses, expected_url):
    list_namespaced_ingress = k8s_client.ExtensionsV1beta1Api.list_namespaced_ingress

    list_namespaced_ingress.return_value.items = ingresses
    assert cluster.App(app).url == expected_url
    list_namespaced_ingress.assert_called_once_with(
        "apps-prod", label_selector="repo=test-repo")
예제 #3
0
    def get_context_data(self, **kwargs):
        context = super().get_context_data(**kwargs)
        app = self.get_object()

        # Log data consistency warnings. (Missing Auth0 ID).
        for user in app.admins:
            if not user.auth0_id:
                log.warning(
                    "User without Auth0 ID, {}, is admin for app: {}.".format(
                        user, app))

        context["app_url"] = cluster.App(app).url
        context["admin_options"] = User.objects.filter(
            auth0_id__isnull=False, ).exclude(auth0_id='', ).exclude(
                auth0_id__in=[user.auth0_id for user in app.admins], )

        context["grant_access_form"] = GrantAppAccessForm(
            app=app,
            exclude_connected=True,
        )

        add_customer_form_errors = self.request.session.pop(
            'add_customer_form_errors', None)
        if add_customer_form_errors:
            errors = context.setdefault('errors', {})
            errors['customer_email'] = add_customer_form_errors[
                'customer_email']

        context['kibana_base_url'] = settings.KIBANA_BASE_URL

        return context
예제 #4
0
    def save(self, *args, **kwargs):
        is_create = not self.pk

        super().save(*args, **kwargs)

        if is_create:
            cluster.App(self).create_iam_role()

        return self
예제 #5
0
    def get_context_data(self, **kwargs):
        context = super().get_context_data(**kwargs)
        app = self.get_object()

        # Log data consistency warnings. (Missing Auth0 ID).
        for user in app.admins:
            if not user.auth0_id:
                log.warning(
                    "User without Auth0 ID, {}, is admin for app: {}.".format(
                        user, app))

        context['EKS'] = settings.EKS
        if settings.EKS:
            # TODO: Fix this.
            # THIS IS A TEMPORARY STICKING PLASTER
            # During migration to EKS, just use the hard coded domain with the
            # app's SLUG as the bottom subdomain.
            # The reason for this change is apps will be hosted on our
            # old infrastructure while users migrate to EKS. Once we have our
            # app hosting story figured out, we should do this properly.
            context[
                "app_url"] = f"https://{ app.slug }.apps.alpha.mojanalytics.xyz"
        else:
            context["app_url"] = cluster.App(app).url
        context["admin_options"] = User.objects.filter(
            auth0_id__isnull=False, ).exclude(auth0_id='', ).exclude(
                auth0_id__in=[user.auth0_id for user in app.admins], )

        context["grant_access_form"] = GrantAppAccessForm(
            app=app,
            exclude_connected=True,
        )

        add_customer_form_errors = self.request.session.pop(
            'add_customer_form_errors', None)
        if add_customer_form_errors:
            errors = context.setdefault('errors', {})
            errors['customer_email'] = add_customer_form_errors[
                'customer_email']

        context['kibana_base_url'] = settings.KIBANA_BASE_URL

        return context
def test_app_delete(aws, app, authz, helm):
    cluster.App(app).delete()

    aws.delete_role.assert_called_with(app.iam_role_name)
    authz.delete_group.assert_called_with(group_name=app.slug)
    helm.delete.assert_called_with(True, app.release_name)
def test_app_create_iam_role(aws, app):
    cluster.App(app).create_iam_role()
    aws.create_app_role.assert_called_with(app)
예제 #8
0
    def delete(self, *args, **kwargs):
        cluster.App(self).delete()

        super().delete(*args, **kwargs)
예제 #9
0
 def iam_role_name(self):
     return cluster.App(self).iam_role_name
 def revoke_bucket_access(self):
     cluster.App(self.app).revoke_bucket_access(self.s3bucket.arn)
 def grant_bucket_access(self):
     cluster.App(self.app).grant_bucket_access(
         self.s3bucket.arn,
         self.access_level,
         self.resources,
     )