Beispiel #1
0
def blank_cloud():
    configfile, configpath = tempfile.mkstemp(suffix='blank_cloud')
    config.setStatePath(configpath)
    from cozify import cloud
    yield cloud
    config.setStatePath()
    os.remove(configpath)
Beispiel #2
0
def live_cloud():
    configfile, configpath = tempfile.mkstemp(suffix='live_cloud')
    config.setStatePath(configpath, copy_current=True)
    from cozify import cloud
    yield cloud
    config.setStatePath()
    os.remove(configpath)
Beispiel #3
0
def main():
    fh, tmp = tempfile.mkstemp()
    config.setStatePath(tmp)

    assert cloud.authenticate()
    config.dump_state()
    print(hub.tz())
    os.remove(tmp)
def main(statepath):
    config.setStatePath(statepath)

    cloud_token = cloud.token()
    hub_id = hub.default()
    hub_token = hub.token(hub_id)

    pp = pprint.PrettyPrinter(indent=2)
    for token in cloud_token, hub_token:
        claims = jwt.decode(token, verify=False)
        pp.pprint(claims)
Beispiel #5
0
def tmp_cloud():
    obj = lambda: 0
    obj.configfile, obj.configpath = tempfile.mkstemp(suffix='tmp_cloud')
    obj.section = 'Cloud'
    obj.email = '*****@*****.**'
    obj.token = 'eyJkb20iOiJ1ayIsImFsZyI6IkhTNTEyIiwidHlwIjoiSldUIn0.eyJyb2xlIjo4LCJpYXQiOjE1MTI5ODg5NjksImV4cCI6MTUxNTQwODc2OSwidXNlcl9pZCI6ImRlYWRiZWVmLWFhYWEtYmJiYi1jY2NjLWRkZGRkZGRkZGRkZCIsImtpZCI6ImRlYWRiZWVmLWRkZGQtY2NjYy1iYmJiLWFhYWFhYWFhYWFhYSIsImlzcyI6IkNsb3VkIn0.QVKKYyfTJPks_BXeKs23uvslkcGGQnBTKodA-UGjgHg'  # valid but useless jwt token.
    obj.expiry = datetime.timedelta(days=1)
    obj.now = datetime.datetime.now()
    obj.iso_now = obj.now.isoformat().split(".")[0]
    obj.yesterday = obj.now - datetime.timedelta(days=1)
    obj.iso_yesterday = obj.yesterday.isoformat().split(".")[0]
    config.setStatePath(obj.configpath)
    from cozify import cloud
    cloud._setAttr('email', obj.email)
    cloud._setAttr('remotetoken', obj.token)
    cloud._setAttr('last_refresh', obj.iso_yesterday)
    yield obj
    os.remove(obj.configpath)
    logging.error('exiting, tried to remove: {0}'.format(obj.configpath))
Beispiel #6
0
def live_hub():
    config.setStatePath()  # we assume the default config will be "live"
    configfile, configpath = tempfile.mkstemp(suffix='live_hub')
    config.setStatePath(configpath, copy_current=True)
    from cozify import hub
    assert hub.ping()
    print('Live hub state for testing:')
    config.dump_state()  # dump state so it's visible in failed test output
    yield hub
    config.setStatePath()
    os.remove(configpath)
def test_config_XDG_env(tmp_hub):
    with tempfile.TemporaryDirectory() as td:
        os.environ["XDG_CONFIG_HOME"] = td
        config.setStatePath(config._initXDG())
        assert td in config.state_file
Beispiel #8
0
 def __exit__(self, exc_type, exc_value, traceback):
     config.setStatePath()
Beispiel #9
0
def live_hub():
    config.setStatePath()  # default config assumed to be live
    print('Live hub state for testing:')
    config.dump_state()  # dump state so it's visible in failed test output
    from cozify import hub
    yield hub