Exemplo n.º 1
0
def build_agent(platform, identity):
    '''Build an agent, configure its keys and return the agent.'''
    keys = keystore.KeyStore(
        os.path.join(platform.volttron_home, identity + '.keys'))
    keys.generate()
    agent = platform.build_agent(identity=identity,
                                 serverkey=platform.publickey,
                                 publickey=keys.public(),
                                 secretkey=keys.secret())
    # Make publickey easily accessible for these tests
    agent.publickey = keys.public()
    return agent
Exemplo n.º 2
0
def test_keystore_with_same_path(keystore_instance1):
    '''Reading from the same path should fetch the same keys'''
    path = keystore_instance1.filename
    keys = keystore.KeyStore(path)
    assert keystore_instance1.public() == keys.public()
    assert keystore_instance1.secret() == keys.secret()
Exemplo n.º 3
0
def test_keystore_generated_when_created(tmpdir_factory):
    kspath = str(tmpdir_factory.mktemp('keys').join('keys.json'))
    ks = keystore.KeyStore(kspath)
    assert os.stat(kspath).st_mode & 0o777 == 0o600
    assert ks.secret()
    assert ks.public()
Exemplo n.º 4
0
def keystore_instance1(tmpdir_factory):
    path = str(tmpdir_factory.mktemp('keys').join('keys.json'))
    print('KEYSTORE PATH:', path)
    keys = keystore.KeyStore(path)
    keys.generate()
    return keys