@@ -47,6 +47,9 @@ fn test_permission_migration() {
4747 let mut funding_setup = AccountSetup :: new_funding ( ) ;
4848 let funding_account = funding_setup. as_account_info ( ) ;
4949
50+ let mut security_auth_setup = AccountSetup :: new_funding ( ) ;
51+ let security_auth_account = security_auth_setup. as_account_info ( ) ;
52+
5053 let mut attacker_setup = AccountSetup :: new_funding ( ) ;
5154 let attacker_account = attacker_setup. as_account_info ( ) ;
5255
@@ -61,6 +64,7 @@ fn test_permission_migration() {
6164
6265 let mut price_setup = AccountSetup :: new :: < PriceAccount > ( & program_id) ;
6366 let mut price_account = price_setup. as_account_info ( ) ;
67+ PriceAccount :: initialize ( & price_account, PC_VERSION ) . unwrap ( ) ;
6468
6569
6670 product_account. is_signer = false ;
@@ -73,6 +77,7 @@ fn test_permission_migration() {
7377 let mut permissions_account_data =
7478 PermissionAccount :: initialize ( & permissions_account, PC_VERSION ) . unwrap ( ) ;
7579 permissions_account_data. master_authority = * funding_account. key ;
80+ permissions_account_data. security_authority = * security_auth_account. key ;
7681 }
7782
7883 assert_eq ! (
@@ -89,6 +94,19 @@ fn test_permission_migration() {
8994 ) ;
9095
9196
97+ assert_eq ! (
98+ process_instruction(
99+ & program_id,
100+ & [
101+ security_auth_account. clone( ) ,
102+ mapping_account. clone( ) ,
103+ permissions_account. clone( )
104+ ] ,
105+ bytes_of:: <CommandHeader >( & InitMapping . into( ) )
106+ ) ,
107+ Err ( OracleError :: PermissionViolation . into( ) )
108+ ) ;
109+
92110 process_instruction (
93111 & program_id,
94112 & [
@@ -252,4 +270,38 @@ fn test_permission_migration() {
252270 ) ,
253271 Err ( OracleError :: PermissionViolation . into( ) )
254272 ) ;
273+
274+
275+ // Security authority can change minimum number of publishers
276+ process_instruction (
277+ & program_id,
278+ & [
279+ security_auth_account. clone ( ) ,
280+ price_account. clone ( ) ,
281+ permissions_account. clone ( ) ,
282+ ] ,
283+ bytes_of :: < SetMinPubArgs > ( & SetMinPubArgs {
284+ header : SetMinPub . into ( ) ,
285+ minimum_publishers : 5 ,
286+ unused_ : [ 0 ; 3 ] ,
287+ } ) ,
288+ )
289+ . unwrap ( ) ;
290+
291+ // Security authority can't add publishers
292+ assert_eq ! (
293+ process_instruction(
294+ & program_id,
295+ & [
296+ security_auth_account. clone( ) ,
297+ price_account. clone( ) ,
298+ permissions_account. clone( ) ,
299+ ] ,
300+ bytes_of:: <AddPublisherArgs >( & AddPublisherArgs {
301+ header: AddPublisher . into( ) ,
302+ publisher: Pubkey :: new_unique( ) ,
303+ } )
304+ ) ,
305+ Err ( OracleError :: PermissionViolation . into( ) )
306+ )
255307}
0 commit comments