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