Exemple #1
0
def test_delete_user():
    copyfile(DB_ORIGIN, DB_FILE)
    pdb = PassDB(DB_FILE)
    del pdb["naota"]
    pdb.close()
    db = tdb.open(DB_FILE)
    assert "USER_naota\x00" not in db
    assert "RID_000003e8\x00" not in db
    db.close()
Exemple #2
0
def test_listup_users():
    copyfile(DB_ORIGIN, DB_FILE)
    pdb = PassDB(DB_FILE)
    pdb.append(User("foo"))
    pdb.append(User("bar"))
    xs = []
    for x in pdb:
        xs.append(x.username)
    pdb.close()
    assert set(xs) == set(["naota", "foo", "bar"])
Exemple #3
0
def test_append_user():
    copyfile(DB_ORIGIN, DB_FILE)
    pdb = PassDB(DB_FILE)
    pdb.append(User("foo"))
    pdb.close()
    db = tdb.open(DB_FILE)
    assert "USER_foo\x00" in db
    assert db["RID_000003e9\x00"] == "foo\x00"
    assert db["NEXT_RID\x00"] == "\xea\x03\x00\x00"
    db.close()
Exemple #4
0
def test_change_password():
    copyfile(DB_ORIGIN, DB_FILE)
    pdb = PassDB(DB_FILE)
    user = pdb["naota"]
    user.set_password("hogefuga")
    pdb["naota"] = user
    pdb.close()
    db = tdb.open(DB_FILE)
    assert unpack_user(db["USER_naota\x00"]).nt_pw == \
        nthash("hogefuga").decode("hex")
    db.close()
Exemple #5
0
def test_open_close():
    copyfile(DB_ORIGIN, DB_FILE)
    pdb = PassDB(DB_FILE)
    pdb.close()