Beispiel #1
0
 def test_reuse_token(self, client):
     self.test_logout(client)
     response = client.get(
         '/api/account/identity',
         headers={'Authorization': 'Bearer ' + self.token})
     print(response.data)
     assert b'Token has been revoked' in response.data
Beispiel #2
0
def loadCaptcha(client):
    response = client.get('/api/account/captcha')
    content_type = response.headers['Content-Type']
    response = client.get('/api/account/cheat')
    code = response.data.decode('utf-8')
    return content_type, code
Beispiel #3
0
    def test_add_address(self, client):

        response = client.get(
            '/api/address/all',
            headers={'Authorization': 'Bearer ' + self.token})
        init_len = len(response.json)

        response = client.get(
            '/api/address/add',
            headers={'Authorization': 'Bearer ' + self.token},
            json={
                'receiver': 'asd',
            })
        assert response.json['result'] == False

        response = client.get(
            '/api/address/add',
            headers={'Authorization': 'Bearer ' + self.token},
            json={
                'receiver': 'asd',
                'phonenumber': 'asd',
                'address': 'asd',
            })
        assert response.json['result'] == True
        temp_id = response.json['id']

        response = client.get(
            '/api/address/all',
            headers={'Authorization': 'Bearer ' + self.token})
        new_len = len(response.json)
        assert new_len == init_len + 1
        new_pram = [i for i in response.json if i['id'] == temp_id]
        assert new_pram[0]['phonenumber'] == 'asd'

        response = client.get(
            '/api/address/update',
            headers={'Authorization': 'Bearer ' + self.token},
            json={
                'receiver': 'asd',
                'phonenumber': 'dsa',
                'address': 'asd',
                'id': temp_id,
            })
        assert response.json['result'] == True

        response = client.get(
            '/api/address/all',
            headers={'Authorization': 'Bearer ' + self.token})
        assert len(response.json) == new_len
        new_pram = [i for i in response.json if i['id'] == temp_id]
        assert new_pram[0]['phonenumber'] == 'dsa'

        response = client.get(
            '/api/address/del',
            headers={'Authorization': 'Bearer ' + self.token},
            json={
                'id': temp_id,
            })
        assert response.json['result'] == True

        response = client.get(
            '/api/address/all',
            headers={'Authorization': 'Bearer ' + self.token})
        new_len = len(response.json)
        assert new_len == init_len
Beispiel #4
0
 def test_after_logout(self, client):
     response = client.get('/api/account/identity')
     assert b'Missing Authorization Header' in response.data
Beispiel #5
0
 def test_optional_user(self, client):
     response = client.get(
         '/api/account/state',
         headers={'Authorization': 'Bearer ' + self.token})
     assert b'logged_in_as_user' in response.data
Beispiel #6
0
 def test_after_login_succeed(self, client):
     response = client.get(
         '/api/account/identity',
         headers={'Authorization': 'Bearer ' + self.token})
     assert b'logged_in_as_user' in response.data
Beispiel #7
0
 def test_optional_anonymous(self, client):
     response = client.get('/api/account/state')
     assert b'logged_in_as_anonymous' in response.data