@@ -47,6 +47,9 @@ fn test_permission_migration() {
47
47
let mut funding_setup = AccountSetup :: new_funding ( ) ;
48
48
let funding_account = funding_setup. as_account_info ( ) ;
49
49
50
+ let mut security_auth_setup = AccountSetup :: new_funding ( ) ;
51
+ let security_auth_account = security_auth_setup. as_account_info ( ) ;
52
+
50
53
let mut attacker_setup = AccountSetup :: new_funding ( ) ;
51
54
let attacker_account = attacker_setup. as_account_info ( ) ;
52
55
@@ -61,6 +64,7 @@ fn test_permission_migration() {
61
64
62
65
let mut price_setup = AccountSetup :: new :: < PriceAccount > ( & program_id) ;
63
66
let mut price_account = price_setup. as_account_info ( ) ;
67
+ PriceAccount :: initialize ( & price_account, PC_VERSION ) . unwrap ( ) ;
64
68
65
69
66
70
product_account. is_signer = false ;
@@ -73,6 +77,7 @@ fn test_permission_migration() {
73
77
let mut permissions_account_data =
74
78
PermissionAccount :: initialize ( & permissions_account, PC_VERSION ) . unwrap ( ) ;
75
79
permissions_account_data. master_authority = * funding_account. key ;
80
+ permissions_account_data. security_authority = * security_auth_account. key ;
76
81
}
77
82
78
83
assert_eq ! (
@@ -89,6 +94,19 @@ fn test_permission_migration() {
89
94
) ;
90
95
91
96
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
+
92
110
process_instruction (
93
111
& program_id,
94
112
& [
@@ -252,4 +270,38 @@ fn test_permission_migration() {
252
270
) ,
253
271
Err ( OracleError :: PermissionViolation . into( ) )
254
272
) ;
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
+ )
255
307
}
0 commit comments