Exemple #1
0
    def test_when_access_token_exist_but_unallowed_roles(self):
        client = Client.create_client('test', 'test', 'apotek')
        access_token = client.generate_access_token()
        self.client.cookies['access_token'] = access_token

        response = self.client.get(self.url)

        self.assertEqual(response.status_code, 403)
        self.assertTemplateUsed(response, 'website/login.html')
Exemple #2
0
    def test_when_access_token_exist_and_valid(self):
        client = Client.create_client('test', 'test', 'loket')
        access_token = client.generate_access_token()
        self.client.cookies['access_token'] = access_token

        response = self.client.get(self.url)

        self.assertEqual(response.status_code, 200)
        self.assertTemplateUsed(response, 'website/mainpage.html')
Exemple #3
0
    def test_when_allowed_roles_access_token_exists(self):
        client = Client.create_client('test', 'test', 'admin')
        access_token = client.generate_access_token()
        self.client.cookies['access_token'] = access_token

        response = self.client.get(self.url)

        self.assertEqual(response.status_code, 200)
        self.assertTemplateUsed(response, 'website/common_daftar_page.html')