MCPcopy
hub / github.com/HelloZeroNet/ZeroNet / testRules

Method testRules

src/Test/TestContentUser.py:37–66  ·  view source on GitHub ↗
(self, site)

Source from the content-addressed store, hash-verified

35 assert '1J6UrZMkarjVg5ax9W4qThir3BFUikbW6C' not in valid_signers # The user itself
36
37 def testRules(self, site):
38 # We going to manipulate it this test rules based on data/users/content.json
39 user_content = site.storage.loadJson("data/users/1J6UrZMkarjVg5ax9W4qThir3BFUikbW6C/content.json")
40
41 # Known user
42 user_content["cert_auth_type"] = "web"
43 user_content["cert_user_id"] = "nofish@zeroid.bit"
44 rules = site.content_manager.getRules("data/users/1J6UrZMkarjVg5ax9W4qThir3BFUikbW6C/content.json", user_content)
45 assert rules["max_size"] == 100000
46 assert "1J6UrZMkarjVg5ax9W4qThir3BFUikbW6C" in rules["signers"]
47
48 # Unknown user
49 user_content["cert_auth_type"] = "web"
50 user_content["cert_user_id"] = "noone@zeroid.bit"
51 rules = site.content_manager.getRules("data/users/1J6UrZMkarjVg5ax9W4qThir3BFUikbW6C/content.json", user_content)
52 assert rules["max_size"] == 10000
53 assert "1J6UrZMkarjVg5ax9W4qThir3BFUikbW6C" in rules["signers"]
54
55 # User with more size limit based on auth type
56 user_content["cert_auth_type"] = "bitmsg"
57 user_content["cert_user_id"] = "noone@zeroid.bit"
58 rules = site.content_manager.getRules("data/users/1J6UrZMkarjVg5ax9W4qThir3BFUikbW6C/content.json", user_content)
59 assert rules["max_size"] == 15000
60 assert "1J6UrZMkarjVg5ax9W4qThir3BFUikbW6C" in rules["signers"]
61
62 # Banned user
63 user_content["cert_auth_type"] = "web"
64 user_content["cert_user_id"] = "bad@zeroid.bit"
65 rules = site.content_manager.getRules("data/users/1J6UrZMkarjVg5ax9W4qThir3BFUikbW6C/content.json", user_content)
66 assert "1J6UrZMkarjVg5ax9W4qThir3BFUikbW6C" not in rules["signers"]
67
68 def testRulesAddress(self, site):
69 user_inner_path = "data/users/1CjfbrbwtP8Y2QjPy12vpTATkUT7oSiPQ9/content.json"

Callers

nothing calls this directly

Calls 2

loadJsonMethod · 0.80
getRulesMethod · 0.80

Tested by

no test coverage detected