Exemplo n.º 1
0
def test_login(postgresql):
    u = get_user()
    url = reverse('login')
    c = Client()
    r = c.post(url, data={'username': u.username, 'password': '******'})
    # Should be redirected to homepage
    assert urllib.parse.urlsplit(r['Location']).path == '/'
Exemplo n.º 2
0
def test_session_auth_accepted(postgresql):
    u = get_user()
    c = Client()
    data = dict(username=u.username, password='******')
    c.post(reverse('login'), data)
    url = get_api_url('hosts', 'api_dispatch_list')
    response = c.get(url)
    assert response.status_code == 200
Exemplo n.º 3
0
    def setup_method(self, method):

        # Get a logged in client ready
        self.user = get_user()
        self.client = Client()
        self.client.post(reverse('login'), {
            'username': self.user.username,
            'password': '******'
        })
Exemplo n.º 4
0
def test_config_xmlrpc_marshaling(postgresql):
    u = get_user()
    c = BasicAuthClient(u.username, 'password123')
    url = get_api_url('ingredients', 'api_dispatch_list')
    # data = json.dumps({'config_yaml': {1: 'int key'}})
    # data = json.dumps({'config_yaml': '"bigint": 123412341234}'})
    data = json.dumps({
        'name': randchars(),
        'config_yaml': "{'really_big_int': 1234123412341234}"
    })
    resp = c.post(url, data=data, content_type='application/json')
    assert "int exceeds XML-RPC limits" in resp.content.decode('utf-8')
Exemplo n.º 5
0
 def test_release(self, redis):
     u = get_user()
     c = BasicAuthClient(u.username, 'password123')
     url = get_api_url('releases', 'api_deploy_release', pk=self.release.id)
     response = c.post(url,
                       content_type="application/json",
                       data=json.dumps({
                           'config_name': 'config_name',
                           'host': 'host',
                           'proc': 'proc',
                           'port': 'port',
                       }))
     assert response.status_code == 202
Exemplo n.º 6
0
    def setup_method(self, method):
        self.app = models.App(
            name=randchars(),
            repo_url=randchars(),
            repo_type=randchars(),
        )
        self.app.save()

        self.build = models.Build(
            app=self.app,
            tag=randchars(),
            file=randchars(),
            status='success',
            hash=randchars(),
        )
        self.build.save()

        self.release = models.Release(
            build=self.build,
            config_yaml='',
            env_yaml='',
            hash=randchars(),
        )
        self.release.save()

        self.squad = models.Squad(name=randchars())
        self.squad.save()

        # create a swarm object
        self.swarm = models.Swarm(
            app=self.app,
            release=self.release,
            config_name=randchars(),
            proc_name='web',
            squad=self.squad,
        )
        self.swarm.save()

        # Get a logged in client ready
        self.user = get_user()
        self.client = Client()
        data = dict(username=self.user.username, password='******')
        self.client.post(reverse('login'), data)
Exemplo n.º 7
0
def test_basic_auth_bad_password(postgresql):
    u = get_user()
    c = BasicAuthClient(u.username, 'BADPASSWORD')
    url = get_api_url('hosts', 'api_dispatch_list')
    response = c.get(url)
    assert response.status_code == 401
Exemplo n.º 8
0
def test_basic_auth_accepted(postgresql):
    u = get_user()
    c = BasicAuthClient(u.username, 'password123')
    url = get_api_url('hosts', 'api_dispatch_list')
    response = c.get(url)
    assert response.status_code == 200
Exemplo n.º 9
0
 def client(self):
     user = get_user()
     client = Client()
     data = dict(username=user.username, password='******')
     client.post(reverse('login'), data)
     return client
Exemplo n.º 10
0
    def setup(self):

        self.app = models.App(
            name=randchars(),
            repo_url=randchars(),
            repo_type=randchars(),
        )
        self.app.save()

        self.app2 = models.App(
            name=randchars(),
            repo_url=randchars(),
            repo_type=randchars(),
        )
        self.app2.save()

        self.build = models.Build(
            app=self.app,
            tag=randchars(),
            file=randchars(),
            status='success',
            hash=randchars(),
        )
        self.build.save()

        self.build2 = models.Build(
            app=self.app2,
            tag=randchars(),
            file=randchars(),
            status='success',
            hash=randchars(),
        )
        self.build2.save()

        self.release = models.Release(
            build=self.build,
            config_yaml='',
            env_yaml='',
            hash=randchars(),
        )
        self.release.save()

        self.release2 = models.Release(
            build=self.build2,
            config_yaml='',
            env_yaml='',
            hash=randchars(),
        )
        self.release2.save()

        self.squad = models.Squad(name=randchars())
        self.squad.save()

        # create a swarm object
        self.swarm = models.Swarm(
            app=self.app,
            release=self.release,
            config_name=randchars(),
            proc_name='web',
            squad=self.squad,
        )
        self.swarm.save()

        self.swarm2 = models.Swarm(
            app=self.app2,
            release=self.release2,
            config_name=randchars(),
            proc_name='web',
            squad=self.squad,
        )
        self.swarm2.save()

        dashboard_name = randchars()
        self.dashboard = models.Dashboard(
            name=dashboard_name,
            slug=slugify(dashboard_name),
        )
        self.dashboard.save()
        self.dashboard.apps.add(self.app2)

        # Get a logged in client ready
        self.user = get_user()
        models.UserProfile.objects.create(user=self.user)
        self.user.userprofile.default_dashboard = self.dashboard
        self.user.userprofile.save()
        self.client = Client()
        self.client.post(reverse('login'), {
            'username': self.user.username,
            'password': '******'
        })