Exemplo n.º 1
0
    def _test_open_domain_connect_template_asynclink(config):
        params = {
            "IP": "132.148.25.185",
            "RANDOMTEXT": "shm:1531371203:Hejo async"
        }

        dc = DomainConnect()
        context = dc.open_domain_connect_template_asynclink(
            'asyncpage.' + config['TEST_DOMAIN'],
            'exampleservice.domainconnect.org',
            'template2',
            params=params,
            redirect_uri=
            'https://exampleservice.domainconnect.org/async_oauth_response',
            service_id_in_path=config['ASYNC_SERVICE_IN_PATH'])

        code = input("Please enter code: ")
        context.code = code

        ctx = dc.get_async_token(context,
                                 test_credentials[context.config.providerName])
        assert (ctx.access_token is not None), 'Access token missing'
        assert (ctx.access_token_expires_in
                is not None), 'Access token expiration data missing'
        assert (ctx.iat is not None), 'Access token iat missing'

        dc.apply_domain_connect_template_async(context, params=params)
Exemplo n.º 2
0
    def _test_get_domain_connect_async_conflict(config):
        if config["ASYNC_SERVICE_IN_PATH"]:
            print(
                "Skipping test as service in path does not support multiple templates in consent: {}"
                .format(config))
            return

        params = {
            "IP": "132.148.25.184",
            "RANDOMTEXT": "shm:1531371203:Hejo async"
        }
        params2 = {
            "IP": "132.148.25.185",
            "RANDOMTEXT": "shm:1531371203:Hejo async in conflict"
        }

        dc = DomainConnect()
        context = dc.open_domain_connect_template_asynclink(
            domain='asyncpage-conflict.' + config['TEST_DOMAIN'],
            provider_id='exampleservice.domainconnect.org',
            service_id=['template1', 'template2'],
            params=params,
            redirect_uri=
            'https://exampleservice.domainconnect.org/async_oauth_response',
            service_id_in_path=config['ASYNC_SERVICE_IN_PATH'])

        code = input("Please enter code: ")
        context.code = code

        ctx = dc.get_async_token(context,
                                 test_credentials[context.config.providerName])
        assert (ctx.access_token is not None), 'Access token missing'
        assert (ctx.access_token_expires_in
                is not None), 'Access token expiration data missing'

        dc.apply_domain_connect_template_async(context,
                                               service_id='template1',
                                               params=params,
                                               force=True)

        try:
            dc.apply_domain_connect_template_async(context,
                                                   service_id='template2',
                                                   params=params2)
            assert False, '2. No error on apply'
        except ConflictOnApplyException:
            pass

        dc.apply_domain_connect_template_async(context,
                                               service_id='template2',
                                               params=params2,
                                               force=True)