-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_vault.py
More file actions
49 lines (40 loc) · 1.39 KB
/
test_vault.py
File metadata and controls
49 lines (40 loc) · 1.39 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
import requests
BASE_URL = 'http://127.0.0.1:5000/api'
def run_test():
print("--- VAULT OPERATION TEST ---")
user = input("Username: ")
master_pw = input("Master Password: ")
# 1. ADD A PASSWORD
print("\nAttempting to add 'Netflix'...")
payload_add = {
"username": user,
"master_password": master_pw,
"site_name": "Netflix",
"site_username": "cool_guy@email.com",
"site_password": "SuperSecretNetflixPassword123"
}
resp = requests.post(f"{BASE_URL}/add_password", json=payload_add)
print(f"Add Status: {resp.status_code}")
print(f"Add Response: {resp.json()}")
if resp.status_code != 201:
print("Stopping test due to error.")
return
# 2. RETRIEVE PASSWORDS
print("\nAttempting to retrieve passwords...")
payload_get = {
"username": user,
"master_password": master_pw
}
resp = requests.post(f"{BASE_URL}/get_passwords", json=payload_get)
if resp.status_code == 200:
passwords = resp.json()
print(f"\nSUCCESS! Found {len(passwords)} entries:")
for p in passwords:
print(f" - Site: {p['site']}")
print(f" User: {p['username']}")
print(f" Pass: {p['password']}") # Should be readable!
else:
print("Failed to retrieve.")
print(resp.json())
if __name__ == '__main__':
run_test()