@@ -95,18 +95,74 @@ async fn add_member_to_group() -> Result<(), Error> {
9595
9696 let group_id = alice. create_group ( & [ & alice_pub_id] ) . await ?;
9797
98- let msg = "Für wenst'd've hätten wir Hunger?" . as_bytes ( ) ;
98+ let msg = b"<insert famous citation here>" ;
9999 let encrypted = alice. encrypt ( msg, & Default :: default ( ) ) . await ?;
100100 let resource_id = alice. get_resource_id ( & encrypted) ?;
101101
102102 let options = SharingOptions :: new ( ) . share_with_groups ( & [ & group_id] ) ;
103103 alice. share ( & [ resource_id] , & options) . await ?;
104104
105- alice. update_group_members ( & group_id, & [ bob_pub_id] ) . await ?;
105+ alice
106+ . update_group_members ( & group_id, & [ bob_pub_id] , & [ ] )
107+ . await ?;
106108
107109 assert_eq ! ( bob. decrypt( & encrypted) . await ?, msg) ;
108110
109111 alice. stop ( ) . await ?;
110112 bob. stop ( ) . await ?;
111113 Ok ( ( ) )
112114}
115+
116+ #[ tokio:: test( flavor = "multi_thread" ) ]
117+ async fn remove_member_from_group ( ) -> Result < ( ) , Error > {
118+ let app = TestApp :: get ( ) . await ;
119+ let alice_id = app. create_identity ( None ) ;
120+ let alice_pub_id = app. get_public_identity ( & alice_id) ;
121+ let alice = app. start_anonymous ( & alice_id) . await ?;
122+ let bob_id = app. create_identity ( None ) ;
123+ let bob_pub_id = app. get_public_identity ( & bob_id) ;
124+ let bob = app. start_anonymous ( & bob_id) . await ?;
125+
126+ let group_id = alice. create_group ( & [ & alice_pub_id, & bob_pub_id] ) . await ?;
127+
128+ let msg = b"<insert famous citation here>" ;
129+ let options = EncryptionOptions :: new ( ) . share_with_groups ( & [ & group_id] ) ;
130+ let encrypted = alice. encrypt ( msg, & options) . await ?;
131+
132+ assert_eq ! ( bob. decrypt( & encrypted) . await ?, msg) ;
133+
134+ alice
135+ . update_group_members ( & group_id, & [ ] , & [ bob_pub_id] )
136+ . await ?;
137+
138+ let encrypted = alice. encrypt ( msg, & options) . await ?;
139+
140+ let err = bob. decrypt ( & encrypted) . await . unwrap_err ( ) ;
141+ assert_eq ! ( err. code( ) , ErrorCode :: InvalidArgument ) ;
142+
143+ alice. stop ( ) . await ?;
144+ bob. stop ( ) . await ?;
145+ Ok ( ( ) )
146+ }
147+
148+ #[ tokio:: test( flavor = "multi_thread" ) ]
149+ async fn reject_empty_group_update ( ) -> Result < ( ) , Error > {
150+ let app = TestApp :: get ( ) . await ;
151+ let alice_id = app. create_identity ( None ) ;
152+ let alice_pub_id = app. get_public_identity ( & alice_id) ;
153+ let alice = app. start_anonymous ( & alice_id) . await ?;
154+
155+ let group_id = alice. create_group ( & [ & alice_pub_id] ) . await ?;
156+
157+ let empty_vec = Vec :: < String > :: new ( ) ;
158+
159+ let err = alice
160+ . update_group_members ( & group_id, & empty_vec, & empty_vec)
161+ . await
162+ . unwrap_err ( ) ;
163+ assert_eq ! ( err. code( ) , ErrorCode :: InvalidArgument ) ;
164+
165+ alice. stop ( ) . await ?;
166+
167+ Ok ( ( ) )
168+ }
0 commit comments