Codebase rewritten to:
tangled.org/atpasser.poxiao-labs.work/atpasser
1from atpasser import did, handle, nsid, rKey, uri
2
3
4testStrings, testMethods = {}, {}
5
6
7testStrings[
8 "did"
9
10] = """did:plc:z72i7hdynmk6r22z27h6tvur
11
12did:web:blueskyweb.xyz
13
14did:method:val:two
15
16did:m:v
17
18did:method::::val
19
20did:method:-:_:.
21
22did:key:zQ3shZc2QzApp2oymGvQbzP8eKheVshBHbU4ZYjeXqwSKEn6N
23
24did:METHOD:val
25
26did:m123:val
27
28DID:method:val
29did:method:
30
31did:method:val/two
32
33did:method:val?two
34
35did:method:val#two"""
36
37testMethods["did"] = did.DID
38
39
40testStrings[
41 "handle"
42
43] = """jay.bsky.social
44
458.cn
46
47name.t--t
48
49XX.LCS.MIT.EDU
50a.co
51
52xn--notarealidn.com
53
54xn--fiqa61au8b7zsevnm8ak20mc4a87e.xn--fiqs8s
55
56xn--ls8h.test
57example.t
58
59jo@hn.test
60
61💩.tes
62t
63john..test
64
65xn--bcher-.tld
66
67john.0
68
69cn.8
70
71www.masełkowski.pl.com
72
73org
74
75name.org.
76
772gzyxa5ihm7nsggfxnu52rck2vv4rvmdlkiu3zzui5du4xyclen53wid.onion
78laptop.local
79
80blah.arpa"""
81
82testMethods["handle"] = handle.Handle
83
84
85testStrings[
86 "nsid"
87
88] = """com.example.fooBar
89
90net.users.bob.ping
91
92a-0.b-1.c
93
94a.b.c
95
96com.example.fooBarV2
97
98cn.8.lex.stuff
99
100com.exa💩ple.thin
101com.example
102
103com.example.3"""
104
105testMethods["nsid"] = nsid.NSID
106
107
108testStrings[
109
110 "rkey"
111
112] = """3jui7kd54zh2y
113self
114example.com
115
116~1.2-3_
117
118dHJ1ZQ
119pre:fix
120
121_
122
123alpha/beta
124.
125..
126
127#extra
128
129@handle
130
131any space
132
133any+space
134
135number[3]
136
137number(3)
138
139"quote"
140
141dHJ1ZQ=="""
142
143testMethods["rkey"] = rKey.RKey
144
145
146testStrings[
147 "uri"
148
149] = """at://foo.com/com.example.foo/123
150
151at://foo.com/example/123
152
153at://computer
154
155at://example.com:3000
156
157at://foo.com/
158
159at://user:pass@foo.com"""
160
161testMethods["uri"] = uri.URI
162
163
164for item in testMethods:
165
166 print(f"START TEST {item}")
167
168 for value in testStrings[item].splitlines():
169
170 print(f"Value: {value}")
171
172 try:
173
174 print(f"str(): {str(testMethods[item](value))}")
175
176 except Exception as e:
177
178 print(f"× {e}")
179