Forking what is left of ZeroNet and hopefully adding an AT Proto Frontend/Proxy
1import pytest
2
3from Crypt import CryptBitcoin
4
5
6@pytest.mark.usefixtures("resetSettings")
7class TestUser:
8 def testAddress(self, user):
9 assert user.master_address == "15E5rhcAUD69WbiYsYARh4YHJ4sLm2JEyc"
10 address_index = 1458664252141532163166741013621928587528255888800826689784628722366466547364755811
11 assert user.getAddressAuthIndex("15E5rhcAUD69WbiYsYARh4YHJ4sLm2JEyc") == address_index
12
13 # Re-generate privatekey based on address_index
14 def testNewSite(self, user):
15 address, address_index, site_data = user.getNewSiteData() # Create a new random site
16 assert CryptBitcoin.hdPrivatekey(user.master_seed, address_index) == site_data["privatekey"]
17
18 user.sites = {} # Reset user data
19
20 # Site address and auth address is different
21 assert user.getSiteData(address)["auth_address"] != address
22 # Re-generate auth_privatekey for site
23 assert user.getSiteData(address)["auth_privatekey"] == site_data["auth_privatekey"]
24
25 def testAuthAddress(self, user):
26 # Auth address without Cert
27 auth_address = user.getAuthAddress("1EU1tbG9oC1A8jz2ouVwGZyQ5asrNsE4Vr")
28 assert auth_address == "1MyJgYQjeEkR9QD66nkfJc9zqi9uUy5Lr2"
29 auth_privatekey = user.getAuthPrivatekey("1EU1tbG9oC1A8jz2ouVwGZyQ5asrNsE4Vr")
30 assert CryptBitcoin.privatekeyToAddress(auth_privatekey) == auth_address
31
32 def testCert(self, user):
33 cert_auth_address = user.getAuthAddress("1iD5ZQJMNXu43w1qLB8sfdHVKppVMduGz") # Add site to user's registry
34 # Add cert
35 user.addCert(cert_auth_address, "zeroid.bit", "faketype", "fakeuser", "fakesign")
36 user.setCert("1EU1tbG9oC1A8jz2ouVwGZyQ5asrNsE4Vr", "zeroid.bit")
37
38 # By using certificate the auth address should be same as the certificate provider
39 assert user.getAuthAddress("1EU1tbG9oC1A8jz2ouVwGZyQ5asrNsE4Vr") == cert_auth_address
40 auth_privatekey = user.getAuthPrivatekey("1EU1tbG9oC1A8jz2ouVwGZyQ5asrNsE4Vr")
41 assert CryptBitcoin.privatekeyToAddress(auth_privatekey) == cert_auth_address
42
43 # Test delete site data
44 assert "1EU1tbG9oC1A8jz2ouVwGZyQ5asrNsE4Vr" in user.sites
45 user.deleteSiteData("1EU1tbG9oC1A8jz2ouVwGZyQ5asrNsE4Vr")
46 assert "1EU1tbG9oC1A8jz2ouVwGZyQ5asrNsE4Vr" not in user.sites
47
48 # Re-create add site should generate normal, unique auth_address
49 assert not user.getAuthAddress("1EU1tbG9oC1A8jz2ouVwGZyQ5asrNsE4Vr") == cert_auth_address
50 assert user.getAuthAddress("1EU1tbG9oC1A8jz2ouVwGZyQ5asrNsE4Vr") == "1MyJgYQjeEkR9QD66nkfJc9zqi9uUy5Lr2"