Esempio n. 1
0
    def setUp(self):
        TestAuth.setUp(self)
        self.client = app.test_client()
        self.headers = {
            'content-type': 'application/json',
            'Authorization': self._encode_credentials(self.username,
                                                      self.password)
        }

        self.token_endpoint = '/tokens'
        self.authorized_endpoint = '/users'

        self.token = self._get_auth_token(self.token_endpoint, self.headers)

        self.token_headers = {
            'content-type': 'application/json',
            'Authorization': self._encode_credentials(self.token)
        }
Esempio n. 2
0
    def setUp(self):
        """
        Starts up the server, and requests an authentication token using the
        correct login credentials.
        """
        TestAuth.setUp(self)
        self.client = app.test_client()
        self.headers = {
            'content-type': 'application/json',
            'Authorization': 'Basic %s' % b64encode(
                ('%s:%s' % (self.username, self.password)).encode('ascii')
            ).decode('ascii')
        }
        r = self.client.post('/tokens', headers=self.headers)

        self.assertEqual(r.status_code, 201)

        self.token = json.loads(r.data.decode('ascii'))['token']
Esempio n. 3
0
    def setUp(self):
        TestAuth.setUp(self)
        self.client = app.test_client()
        self.headers = {
            'content-type': 'application/json',
            'Authorization': self._encode_credentials(
                    self.username, self.password
            )
        }

        self.token_endpoint = '/tokens'
        self.authorized_endpoint = '/users'

        self.token = self._get_auth_token(self.token_endpoint, self.headers)

        self.token_headers = {
            'content-type': 'application/json',
            'Authorization': self._encode_credentials(self.token)
        }
Esempio n. 4
0
    def setUp(self):
        """
        Starts up the server, and requests an authentication token using the
        correct login credentials.
        """
        TestAuth.setUp(self)
        self.client = app.test_client()
        self.headers = {
            'content-type':
            'application/json',
            'Authorization':
            'Basic %s' % b64encode(
                ('%s:%s' % (self.username,
                            self.password)).encode('ascii')).decode('ascii')
        }
        r = self.client.post('/tokens', headers=self.headers)

        self.assertEqual(r.status_code, 201)

        self.token = json.loads(r.data.decode('ascii'))['token']
Esempio n. 5
0
    def setUp(self):
        TestAuth.setUp(self)
        self.client = app.test_client()
        self.headers = {
            'content-type': 'application/json',
            'Authorization': 'Basic %s' % b64encode(
                ('%s:%s' % (self.username, self.password)).encode('ascii')
            ).decode('ascii')
        }

        r = self.client.post('/tokens', headers=self.headers)

        self.assertEqual(r.status_code, 201)

        self.token = json.loads(r.data.decode('ascii'))['token']

        self.token_auth_headers = deepcopy(self.headers)

        self.token_auth_headers['Authorization'] = 'Basic %s' % b64encode(
                ('%s:' % self.token).encode('ascii')
        ).decode('ascii')

        self.assertNotEqual(self.token_auth_headers, self.headers)
Esempio n. 6
0
    def setUp(self):
        TestAuth.setUp(self)
        self.client = app.test_client()
        self.headers = {
            'content-type':
            'application/json',
            'Authorization':
            'Basic %s' % b64encode(
                ('%s:%s' % (self.username,
                            self.password)).encode('ascii')).decode('ascii')
        }

        r = self.client.post('/tokens', headers=self.headers)

        self.assertEqual(r.status_code, 201)

        self.token = json.loads(r.data.decode('ascii'))['token']

        self.token_auth_headers = deepcopy(self.headers)

        self.token_auth_headers['Authorization'] = 'Basic %s' % b64encode(
            ('%s:' % self.token).encode('ascii')).decode('ascii')

        self.assertNotEqual(self.token_auth_headers, self.headers)
 def setUp(self):
     self.client = app.test_client(True)
     self.headers = {'content-type': 'application/json'}
     self.url = url
     self.request_method = self.client.get