@@ -171,6 +171,8 @@ impl NostrMlsStorageProvider for NostrMlsMemoryStorage {
171
171
mod tests {
172
172
use std:: collections:: BTreeSet ;
173
173
174
+ use aes_gcm:: aead:: OsRng ;
175
+ use aes_gcm:: { Aes128Gcm , KeyInit } ;
174
176
use nostr:: { EventId , Kind , PublicKey , RelayUrl , Tags , Timestamp , UnsignedEvent } ;
175
177
use nostr_mls_storage:: groups:: types:: { Group , GroupExporterSecret , GroupState , GroupType } ;
176
178
use nostr_mls_storage:: groups:: GroupStorage ;
@@ -183,6 +185,10 @@ mod tests {
183
185
184
186
use super :: * ;
185
187
188
+ pub fn generate_encryption_key ( ) -> Vec < u8 > {
189
+ Aes128Gcm :: generate_key ( OsRng ) . to_vec ( )
190
+ }
191
+
186
192
fn create_test_group_id ( ) -> GroupId {
187
193
GroupId :: from_slice ( & [ 1 , 2 , 3 , 4 ] )
188
194
}
@@ -242,6 +248,8 @@ mod tests {
242
248
let nostr_storage = NostrMlsMemoryStorage :: new ( storage) ;
243
249
let mls_group_id = create_test_group_id ( ) ;
244
250
let nostr_group_id = create_test_nostr_group_id ( ) ;
251
+ let image_url = Some ( "http://blossom_server:4531/fake_img.png" . to_owned ( ) ) ;
252
+ let image_key = Some ( generate_encryption_key ( ) ) ;
245
253
let group = Group {
246
254
mls_group_id : mls_group_id. clone ( ) ,
247
255
nostr_group_id,
@@ -253,6 +261,8 @@ mod tests {
253
261
group_type : GroupType :: Group ,
254
262
epoch : 0 ,
255
263
state : GroupState :: Active ,
264
+ image_url,
265
+ image_key,
256
266
} ;
257
267
nostr_storage. save_group ( group. clone ( ) ) . unwrap ( ) ;
258
268
let found_group = nostr_storage
@@ -279,6 +289,8 @@ mod tests {
279
289
let nostr_storage = NostrMlsMemoryStorage :: new ( storage) ;
280
290
let mls_group_id = create_test_group_id ( ) ;
281
291
let nostr_group_id = create_test_nostr_group_id ( ) ;
292
+ let image_url = Some ( "http://blossom_server:4531/fake_img.png" . to_owned ( ) ) ;
293
+ let image_key = Some ( generate_encryption_key ( ) ) ;
282
294
let group = Group {
283
295
mls_group_id : mls_group_id. clone ( ) ,
284
296
nostr_group_id,
@@ -290,6 +302,8 @@ mod tests {
290
302
group_type : GroupType :: Group ,
291
303
epoch : 0 ,
292
304
state : GroupState :: Active ,
305
+ image_url,
306
+ image_key,
293
307
} ;
294
308
nostr_storage. save_group ( group. clone ( ) ) . unwrap ( ) ;
295
309
let relay_url1 = RelayUrl :: parse ( "wss://relay1.example.com" ) . unwrap ( ) ;
@@ -334,6 +348,8 @@ mod tests {
334
348
let nostr_storage = NostrMlsMemoryStorage :: new ( storage) ;
335
349
let mls_group_id = create_test_group_id ( ) ;
336
350
let nostr_group_id = create_test_nostr_group_id ( ) ;
351
+ let image_url = Some ( "http://blossom_server:4531/fake_img.png" . to_owned ( ) ) ;
352
+ let image_key = Some ( generate_encryption_key ( ) ) ;
337
353
let group = Group {
338
354
mls_group_id : mls_group_id. clone ( ) ,
339
355
nostr_group_id,
@@ -345,6 +361,8 @@ mod tests {
345
361
group_type : GroupType :: Group ,
346
362
epoch : 0 ,
347
363
state : GroupState :: Active ,
364
+ image_url,
365
+ image_key,
348
366
} ;
349
367
nostr_storage. save_group ( group. clone ( ) ) . unwrap ( ) ;
350
368
let group_exporter_secret_0 = GroupExporterSecret {
@@ -417,6 +435,8 @@ mod tests {
417
435
nostr_group_id,
418
436
group_name : "Test Welcome Group" . to_string ( ) ,
419
437
group_description : "A test welcome group" . to_string ( ) ,
438
+ group_image_key : None ,
439
+ group_image_url : None ,
420
440
group_admin_pubkeys : BTreeSet :: from ( [ pubkey] ) ,
421
441
group_relays : BTreeSet :: from ( [ RelayUrl :: parse ( "wss://relay.example.com" ) . unwrap ( ) ] ) ,
422
442
welcomer : pubkey,
@@ -475,6 +495,8 @@ mod tests {
475
495
let nostr_storage = NostrMlsMemoryStorage :: new ( storage) ;
476
496
let mls_group_id = create_test_group_id ( ) ;
477
497
let nostr_group_id = create_test_nostr_group_id ( ) ;
498
+ let image_url = Some ( "http://blossom_server:4531/fake_img.png" . to_owned ( ) ) ;
499
+ let image_key = Some ( generate_encryption_key ( ) ) ;
478
500
let group = Group {
479
501
mls_group_id : mls_group_id. clone ( ) ,
480
502
nostr_group_id,
@@ -486,6 +508,8 @@ mod tests {
486
508
group_type : GroupType :: Group ,
487
509
epoch : 0 ,
488
510
state : GroupState :: Active ,
511
+ image_url,
512
+ image_key,
489
513
} ;
490
514
nostr_storage. save_group ( group. clone ( ) ) . unwrap ( ) ;
491
515
let event_id = EventId :: all_zeros ( ) ;
@@ -568,6 +592,8 @@ mod tests {
568
592
// Create a test group to verify the cache works
569
593
let mls_group_id = create_test_group_id ( ) ;
570
594
let nostr_group_id = create_test_nostr_group_id ( ) ;
595
+ let image_url = Some ( "http://blossom_server:4531/fake_img.png" . to_owned ( ) ) ;
596
+ let image_key = Some ( generate_encryption_key ( ) ) ;
571
597
let group = Group {
572
598
mls_group_id : mls_group_id. clone ( ) ,
573
599
nostr_group_id,
@@ -579,6 +605,8 @@ mod tests {
579
605
group_type : GroupType :: Group ,
580
606
epoch : 0 ,
581
607
state : GroupState :: Active ,
608
+ image_url,
609
+ image_key,
582
610
} ;
583
611
584
612
// Save the group
@@ -598,6 +626,8 @@ mod tests {
598
626
// Create a test group to verify the default implementation works
599
627
let mls_group_id = create_test_group_id ( ) ;
600
628
let nostr_group_id = create_test_nostr_group_id ( ) ;
629
+ let image_url = Some ( "http://blossom_server:4531/fake_img.png" . to_owned ( ) ) ;
630
+ let image_key = Some ( generate_encryption_key ( ) ) ;
601
631
let group = Group {
602
632
mls_group_id : mls_group_id. clone ( ) ,
603
633
nostr_group_id,
@@ -609,6 +639,8 @@ mod tests {
609
639
group_type : GroupType :: Group ,
610
640
epoch : 0 ,
611
641
state : GroupState :: Active ,
642
+ image_url,
643
+ image_key,
612
644
} ;
613
645
614
646
// Save the group
0 commit comments