@@ -0,0 +1,1554 @@
+%22%22%22 Test %60%60dockci.api.jwt%60%60 against the DB %22%22%22%0Aimport json%0A%0Aimport pytest%0A%0A%0Aclass TestJwtServiceNew(object):%0A    %22%22%22 Test the %60%60JwtServiceNew%60%60 resource %22%22%22%0A    @pytest.mark.usefixtures('db')%0A    def test_agent_role(self, client, admin_user):%0A        %22%22%22 Test creating a service token with the agent internal role %22%22%22%0A        response = client.post('/api/v1/jwt/service', headers=%7B%0A            'x_dockci_username': admin_user.email,%0A            'x_dockci_password': 'testpass',%0A        %7D, data=%7B%0A            'name': 'test',%0A            'roles': %5B'agent'%5D,%0A        %7D)%0A%0A        assert response.status_code == 201%0A%0A        response_data = json.loads(response.data.decode())%0A        token = response_data.pop('token')%0A        assert response_data == %7B%7D%0A%0A        response = client.get('/api/v1/me/jwt', headers=%7B%0A            'x_dockci_api_key': token%0A        %7D)%0A        response_data = json.loads(response.data.decode())%0A        response_data.pop('iat')%0A%0A        assert response_data == dict(%0A            name='test',%0A            roles=%5B'agent'%5D,%0A            sub='service',%0A            sub_detail='/api/v1/users/service',%0A        )%0A%0A    @pytest.mark.usefixtures('db')%0A    def test_non_admin(self, client, user):%0A        %22%22%22 Test creating a service token without admin %22%22%22%0A        response = client.post('/api/v1/jwt/service', headers=%7B%0A            'x_dockci_username': user.email,%0A            'x_dockci_password': 'testpass',%0A        %7D, data=%7B%0A            'name': 'test',%0A            'roles': %5B'agent'%5D,%0A        %7D)%0A%0A        assert response.status_code == 401%0A

Test JWT service tokens