示例#1
0
    def test_client_register_token(self):
        c = Consumer(None, None)

        c.application_type = "web"
        c.application_name = "My super service"
        c.redirect_uris = ["https://example.com/authz"]
        c.contact = ["*****@*****.**"]

        client_info = {"client_id": "clientid", "redirect_uris": ["https://example.com/authz"]}

        with responses.RequestsMock() as rsps:
            rsps.add(rsps.POST, "https://provider.example.com/registration/", json=client_info)
            c.register("https://provider.example.com/registration/", registration_token="initial_registration_token")
            header = rsps.calls[0].request.headers['Authorization'].decode()
            assert header == "Bearer aW5pdGlhbF9yZWdpc3RyYXRpb25fdG9rZW4="
示例#2
0
    def test_client_register_token(self):
        c = Consumer(None, None)

        c.application_type = "web"
        c.application_name = "My super service"
        c.redirect_uris = ["https://example.com/authz"]
        c.contact = ["*****@*****.**"]

        client_info = {"client_id": "clientid", "redirect_uris": ["https://example.com/authz"]}

        with responses.RequestsMock() as rsps:
            rsps.add(rsps.POST, "https://provider.example.com/registration/", json=client_info)
            c.register("https://provider.example.com/registration/", registration_token="initial_registration_token")
            header = rsps.calls[0].request.headers['Authorization'].decode()
            assert header == "Bearer aW5pdGlhbF9yZWdpc3RyYXRpb25fdG9rZW4="
示例#3
0
    def test_client_register(self, fake_oic_server):
        c = Consumer(None, None)

        c.application_type = "web"
        c.application_name = "My super service"
        c.redirect_uris = ["https://example.com/authz"]
        c.contact = ["*****@*****.**"]
        mfos = fake_oic_server("https://example.com")
        mfos.keyjar = SRVKEYS
        c.http_request = mfos.http_request
        location = c.discover("*****@*****.**")
        info = c.provider_config(location)

        c.register(info["registration_endpoint"])
        assert c.client_id is not None
        assert c.client_secret is not None
        assert c.registration_expires > utc_time_sans_frac()
示例#4
0
    def test_client_register(self, fake_oic_server):
        c = Consumer(None, None)

        c.application_type = "web"
        c.application_name = "My super service"
        c.redirect_uris = ["https://example.com/authz"]
        c.contact = ["*****@*****.**"]
        mfos = fake_oic_server("https://example.com")
        mfos.keyjar = SRVKEYS
        c.http_request = mfos.http_request
        location = c.discover("*****@*****.**")
        info = c.provider_config(location)

        c.register(info["registration_endpoint"])
        assert c.client_id is not None
        assert c.client_secret is not None
        assert c.registration_expires > utc_time_sans_frac()