@@ -0,0 +1,1898 @@
+import json%0A%0Aimport pytest%0Afrom future.backports.urllib.parse import urlencode%0Afrom jwkest.jwk import RSAKey, rsa_load%0Afrom jwkest.jws import JWS%0A%0A%0Aclass TestWSGIApp:%0A    @pytest.fixture(autouse=True)%0A    def create_test_client(self, app, cert_and_key):%0A        self.app = app.test_client()%0A        self.signing_key = RSAKey(key=rsa_load(cert_and_key%5B1%5D), alg=%22RS256%22)%0A%0A    def test_full_flow(self):%0A        # make account linking request%0A        request_args = %7B%22id%22: %22id%22, %22idp%22: %22idp%22, %22redirect_endpoint%22: %22https://client.example.com/redirect_endpoint%22%7D%0A        jws = JWS(json.dumps(request_args)).sign_compact(%5Bself.signing_key%5D)%0A        path_get_id = %22/get_id?%7B%7D%22.format(urlencode(%7B%22jwt%22: jws%7D))%0A        resp = self.app.get(path_get_id)%0A        assert resp.status_code == 404%0A        ticket = resp.data.decode(%22utf-8%22)%0A%0A        # user gets redirected to the account linking page%0A        resp = self.app.get(%22/approve/%7B%7D%22.format(ticket))%0A        assert resp.status_code == 200%0A%0A        # redirect user to create an account page%0A        resp = self.app.post(%22/create_account%22)%0A        assert resp.status_code == 200%0A%0A        # send token by email (faked by writing it to a file)%0A        resp = self.app.post(%22/send_token%22, data=%7B%22email%22: %22test@example.com%22%7D)%0A        assert resp.status_code == 200%0A%0A        # get token from file%0A        with open(%22token%22) as f:%0A            token = f.read()%0A%0A        # verify token%0A        resp = self.app.post(%22/verify_token%22, data=%7B%22token%22: token%7D)%0A        assert resp.status_code == 200%0A%0A        # save account with a pin code%0A        resp = self.app.post(%22/save_account%22, data=%7B%22pin%22: %22!AbC123#%22%7D)%0A        assert resp.status_code == 302%0A        assert resp.headers%5B%22Location%22%5D == request_args%5B%22redirect_endpoint%22%5D%0A%0A        # get the id%0A        resp = self.app.get(path_get_id)%0A        assert resp.status_code == 200%0A        assert resp.data.decode(%22utf-8%22)%0A

Add test of full flow in WSGI app.