matrix_sdk_test/test_json/
api_responses.rs1use std::sync::LazyLock;
4
5use serde_json::{Value as JsonValue, json};
6
7pub static DEVICES: LazyLock<JsonValue> = LazyLock::new(|| {
9 json!({
10 "devices": [
11 {
12 "device_id": "BNYQQWUMXO",
13 "display_name": "Client 1",
14 "last_seen_ip": "-",
15 "last_seen_ts": 1596117733037u64,
16 "user_id": "@example:localhost"
17 },
18 {
19 "device_id": "LEBKSEUSNR",
20 "display_name": "Client 2",
21 "last_seen_ip": "-",
22 "last_seen_ts": 1599057006985u64,
23 "user_id": "@example:localhost"
24 }
25 ]
26 })
27});
28
29pub static DEVICE: LazyLock<JsonValue> = LazyLock::new(|| {
31 json!({
32 "device_id": "QBUAZIFURK",
33 "display_name": "android",
34 "last_seen_ip": "1.2.3.4",
35 "last_seen_ts": 1474491775024u64
36 })
37});
38
39pub static GET_ALIAS: LazyLock<JsonValue> = LazyLock::new(|| {
41 json!({
42 "room_id": "!lUbmUPdxdXxEQurqOs:example.net",
43 "servers": [
44 "example.org",
45 "example.net",
46 "matrix.org",
47 ]
48 })
49});
50
51pub static KEYS_QUERY: LazyLock<JsonValue> = LazyLock::new(|| {
53 json!({
54 "device_keys": {
55 "@alice:example.org": {
56 "JLAFKJWSCS": {
57 "algorithms": [
58 "m.olm.v1.curve25519-aes-sha2",
59 "m.megolm.v1.aes-sha2"
60 ],
61 "device_id": "JLAFKJWSCS",
62 "user_id": "@alice:example.org",
63 "keys": {
64 "curve25519:JLAFKJWSCS": "wjLpTLRqbqBzLs63aYaEv2Boi6cFEbbM/sSRQ2oAKk4",
65 "ed25519:JLAFKJWSCS": "nE6W2fCblxDcOFmeEtCHNl8/l8bXcu7GKyAswA4r3mM"
66 },
67 "signatures": {
68 "@alice:example.org": {
69 "ed25519:JLAFKJWSCS": "m53Wkbh2HXkc3vFApZvCrfXcX3AI51GsDHustMhKwlv3TuOJMj4wistcOTM8q2+e/Ro7rWFUb9ZfnNbwptSUBA"
70 }
71 },
72 "unsigned": {
73 "device_display_name": "Alice's mobile phone"
74 }
75 }
76 }
77 },
78 "failures": {}
79 })
80});
81
82pub static KEYS_QUERY_TWO_DEVICES_ONE_SIGNED: LazyLock<JsonValue> = LazyLock::new(|| {
86 json!({
87 "device_keys":{
88 "@web2:localhost:8482":{
89 "AVXFQWJUQA":{
90 "algorithms":[
91 "m.olm.v1.curve25519-aes-sha2",
92 "m.megolm.v1.aes-sha2"
93 ],
94 "device_id":"AVXFQWJUQA",
95 "keys":{
96 "curve25519:AVXFQWJUQA":"LTpv2DGMhggPAXO02+7f68CNEp6A40F0Yl8B094Y8gc",
97 "ed25519:AVXFQWJUQA":"loz5i40dP+azDtWvsD0L/xpnCjNkmrcvtXVXzCHX8Vw"
98 },
99 "signatures":{
100 "@web2:localhost:8482":{
101 "ed25519:AVXFQWJUQA":"BmdzjXMwZaZ0ZK8T6h3pkTA+gZbD34Bzf8FNazBdAIE16fxVzrlSJkLfXnjdBqRO0Dlda5vKgGpqJazZP6obDw"
102 }
103 },
104 "user_id":"@web2:localhost:8482"
105 },
106 "JERTCKWUWG":{
107 "algorithms":[
108 "m.olm.v1.curve25519-aes-sha2",
109 "m.megolm.v1.aes-sha2"
110 ],
111 "device_id":"JERTCKWUWG",
112 "keys":{
113 "curve25519:JERTCKWUWG":"XJixbpnfIk+RqcK5T6moqVY9d9Q1veR8WjjSlNiQNT0",
114 "ed25519:JERTCKWUWG":"48f3WQAMGwYLBg5M5qUhqnEVA8yeibjZpPsShoWMFT8"
115 },
116 "signatures":{
117 "@web2:localhost:8482":{
118 "ed25519:JERTCKWUWG":"Wc67XYem4IKCpshcslQ6ketCE5otubpX+Bh01OB8ghLxl1d6exlZsgaRA57N8RJ0EMvbeTWCweHXXC/UeeQ4DQ",
119 "ed25519:uXOM0Xlfts9SGysk/yNr0Vn9rgv1Ifh3R8oPhtic4BM":"dto9VPhhJbNw62j8NQyjnwukMd1NtYnDYSoUOzD5dABq1u2Kt/ZdthcTO42HyxG/3/hZdno8XPfJ47l1ZxuXBA"
120 }
121 },
122 "user_id":"@web2:localhost:8482"
123 }
124 }
125 },
126 "failures":{
127
128 },
129 "master_keys":{
130 "@web2:localhost:8482":{
131 "user_id":"@web2:localhost:8482",
132 "usage":[
133 "master"
134 ],
135 "keys":{
136 "ed25519:Ct4QR+aXrzW4iYIgH1B/56NkPEtSPoN+h2TGoQ0xxYI":"Ct4QR+aXrzW4iYIgH1B/56NkPEtSPoN+h2TGoQ0xxYI"
137 },
138 "signatures":{
139 "@web2:localhost:8482":{
140 "ed25519:JERTCKWUWG":"H9hEsUJ+alB5XAboDzU4loVb+SZajC4tsQzGaeU/FHMFAnWeVarTMCR+NmPSGsZfvPrNz2WVS2G7FIH5yhJfBg"
141 }
142 }
143 }
144 },
145 "self_signing_keys":{
146 "@web2:localhost:8482":{
147 "user_id":"@web2:localhost:8482",
148 "usage":[
149 "self_signing"
150 ],
151 "keys":{
152 "ed25519:uXOM0Xlfts9SGysk/yNr0Vn9rgv1Ifh3R8oPhtic4BM":"uXOM0Xlfts9SGysk/yNr0Vn9rgv1Ifh3R8oPhtic4BM"
153 },
154 "signatures":{
155 "@web2:localhost:8482":{
156 "ed25519:Ct4QR+aXrzW4iYIgH1B/56NkPEtSPoN+h2TGoQ0xxYI":"YbD6gTEwY078nllTxmlyea2VNvAElQ/ig7aPsyhA3h1gGwFvPdtyDbomjdIphUF/lXQ+Eyz4SzlUWeghr1b3BA"
157 }
158 }
159 }
160 },
161 "user_signing_keys":{
162
163 }
164 })
165});
166
167pub static KEYS_UPLOAD: LazyLock<JsonValue> = LazyLock::new(|| {
169 json!({
170 "one_time_key_counts": {
171 "curve25519": 10,
172 "signed_curve25519": 20
173 }
174 })
175});
176
177pub static LOGIN: LazyLock<JsonValue> = LazyLock::new(|| {
179 json!({
180 "access_token": "abc123",
181 "device_id": "GHTYAJCE",
182 "home_server": "matrix.org",
183 "user_id": "@cheeky_monkey:matrix.org"
184 })
185});
186
187pub static LOGIN_WITH_DISCOVERY: LazyLock<JsonValue> = LazyLock::new(|| {
189 json!({
190 "access_token": "abc123",
191 "device_id": "GHTYAJCE",
192 "home_server": "matrix.org",
193 "user_id": "@cheeky_monkey:matrix.org",
194 "well_known": {
195 "m.homeserver": {
196 "base_url": "https://example.org"
197 },
198 "m.identity_server": {
199 "base_url": "https://id.example.org"
200 }
201 }
202 })
203});
204
205pub static LOGIN_WITH_REFRESH_TOKEN: LazyLock<JsonValue> = LazyLock::new(|| {
207 json!({
208 "access_token": "abc123",
209 "device_id": "GHTYAJCE",
210 "home_server": "matrix.org",
211 "user_id": "@cheeky_monkey:matrix.org",
212 "expires_in_ms": 432000000,
213 "refresh_token": "zyx987",
214 })
215});
216
217pub static LOGIN_RESPONSE_ERR: LazyLock<JsonValue> = LazyLock::new(|| {
219 json!({
220 "errcode": "M_FORBIDDEN",
221 "error": "Invalid password"
222 })
223});
224
225pub static LOGIN_TYPES: LazyLock<JsonValue> = LazyLock::new(|| {
227 json!({
228 "flows": [
229 {
230 "type": "m.login.password"
231 },
232 {
233 "type": "m.login.sso"
234 },
235 {
236 "type": "m.login.token"
237 }
238 ]
239 })
240});
241
242pub static NOT_FOUND: LazyLock<JsonValue> = LazyLock::new(|| {
245 json!({
246 "errcode": "M_NOT_FOUND",
247 "error": "No resource was found for this request.",
248 "soft_logout": true,
249 })
250});
251
252pub static PUBLIC_ROOMS: LazyLock<JsonValue> = LazyLock::new(|| {
255 json!({
256 "chunk": [
257 {
258 "aliases": [
259 "#murrays:cheese.bar"
260 ],
261 "avatar_url": "mxc://bleeker.street/CHEDDARandBRIE",
262 "guest_can_join": false,
263 "name": "CHEESE",
264 "num_joined_members": 37,
265 "room_id": "!ol19s:bleecker.street",
266 "topic": "Tasty tasty cheese",
267 "world_readable": true
268 }
269 ],
270 "next_batch": "p190q",
271 "prev_batch": "p1902",
272 "total_room_count_estimate": 115
273 })
274});
275
276pub static PUBLIC_ROOMS_FINAL_PAGE: LazyLock<JsonValue> = LazyLock::new(|| {
279 json!({
280 "chunk": [
281 {
282 "canonical_alias": "#murrays:pear.bar",
283 "avatar_url": "mxc://bleeker.street/pear",
284 "guest_can_join": false,
285 "name": "PEAR",
286 "num_joined_members": 20,
287 "room_id": "!ca18r:bleecker.street",
288 "topic": "Tasty tasty pear",
289 "world_readable": false,
290 "join_rule": "knock"
291 }
292 ],
293 "prev_batch": "p190q",
294 "total_room_count_estimate": 115
295 })
296});
297
298pub static REFRESH_TOKEN: LazyLock<JsonValue> = LazyLock::new(|| {
300 json!({
301 "access_token": "5678",
302 "expire_in_ms": 432000000,
303 })
304});
305
306pub static REFRESH_TOKEN_WITH_REFRESH_TOKEN: LazyLock<JsonValue> = LazyLock::new(|| {
308 json!({
309 "access_token": "9012",
310 "expire_in_ms": 432000000,
311 "refresh_token": "wxyz",
312 })
313});
314
315pub static REGISTRATION_RESPONSE_ERR: LazyLock<JsonValue> = LazyLock::new(|| {
317 json!({
318 "errcode": "M_FORBIDDEN",
319 "error": "Invalid password",
320 "completed": ["example.type.foo"],
321 "flows": [
322 {
323 "stages": ["example.type.foo", "example.type.bar"]
324 },
325 {
326 "stages": ["example.type.foo", "example.type.baz"]
327 }
328 ],
329 "params": {
330 "example.type.baz": {
331 "example_key": "foobar"
332 }
333 },
334 "session": "xxxxxx"
335 })
336});
337
338pub static UNKNOWN_TOKEN_SOFT_LOGOUT: LazyLock<JsonValue> = LazyLock::new(|| {
340 json!({
341 "errcode": "M_UNKNOWN_TOKEN",
342 "error": "Invalid access token passed.",
343 "soft_logout": true,
344 })
345});
346
347pub static VERSIONS: LazyLock<JsonValue> = LazyLock::new(|| {
349 json!({
350 "versions": [
351 "r0.0.1",
352 "r0.1.0",
353 "r0.2.0",
354 "r0.3.0",
355 "r0.4.0",
356 "r0.5.0",
357 "r0.6.0"
358 ],
359 "unstable_features": {
360 "org.matrix.label_based_filtering": true,
361 "org.matrix.e2e_cross_signing": true,
362 "org.matrix.msc4028": true,
363 "org.matrix.simplified_msc3575": true,
364 }
365 })
366});
367
368pub static WELL_KNOWN: LazyLock<JsonValue> = LazyLock::new(|| {
370 json!({
371 "m.homeserver": {
372 "base_url": "HOMESERVER_URL"
373 },
374 "m.rtc_foci": [
375 {
376 "type": "livekit",
377 "livekit_service_url": "https://livekit.example.com",
378 }
379 ]
380 })
381});
382
383pub static WHOAMI: LazyLock<JsonValue> = LazyLock::new(|| {
385 json!({
386 "user_id": "@joe:example.org"
387 })
388});