コード例 #1
0
ファイル: test_client_auth.py プロジェクト: zh0uquan/prefect
    def test_logout_clears_access_token_and_tenant(self, patch_post):
        tenant_id = str(uuid.uuid4())
        post = patch_post({
            "data": {
                "tenant": [{
                    "id": tenant_id
                }],
                "switchTenant": {
                    "accessToken": "ACCESS_TOKEN",
                    "expiresAt": "2100-01-01",
                    "refreshToken": "REFRESH_TOKEN",
                },
            }
        })
        client = Client()
        client.login_to_tenant(tenant_id=tenant_id)

        assert client._access_token is not None
        assert client._refresh_token is not None
        assert client._active_tenant_id is not None

        client.logout_from_tenant()

        assert client._access_token is None
        assert client._refresh_token is None
        assert client._active_tenant_id is None

        # new client doesn't load the active tenant
        assert Client()._active_tenant_id is None