@@ -11,11 +11,11 @@ async fn test_policies_create() -> Result<()> {
1111
1212 let unique_name = format ! ( "test-policy-{}" , chrono:: Utc :: now( ) . timestamp( ) ) ;
1313 let policy_body = CreatePolicyBody {
14- chain_type : PolicyChainType :: Solana ,
14+ chain_type : WalletChainType :: Solana ,
1515 name : CreatePolicyBodyName :: try_from ( unique_name) . unwrap ( ) ,
1616 owner : None ,
1717 owner_id : None ,
18- rules : vec ! [ PolicyRuleRequestBody {
18+ rules : vec ! [ CreatePolicyBodyRulesItem {
1919 action: PolicyAction :: Allow ,
2020 conditions: vec![ PolicyCondition :: SolanaSystemProgramInstructionCondition (
2121 SolanaSystemProgramInstructionCondition {
@@ -25,8 +25,9 @@ async fn test_policies_create() -> Result<()> {
2525 value: ConditionValue :: String ( "1000000" . to_string( ) ) ,
2626 }
2727 ) ] ,
28+ id: None ,
2829 method: PolicyMethod :: SignTransaction ,
29- name: PolicyRuleRequestBodyName :: try_from( "test-rule" ) . unwrap( ) ,
30+ name: CreatePolicyBodyRulesItemName :: try_from( "test-rule" ) . unwrap( ) ,
3031 } ] ,
3132 version : CreatePolicyBodyVersion :: try_from ( "1.0" ) . unwrap ( ) ,
3233 } ;
@@ -61,7 +62,7 @@ async fn test_policies_get() -> Result<()> {
6162async fn test_policies_get_rule ( ) {
6263 let client = common:: get_test_client ( ) . unwrap ( ) ;
6364 let policy = common:: ensure_test_policy ( & client, vec ! [
64- PolicyRuleRequestBody {
65+ CreatePolicyBodyRulesItem {
6566 action: PolicyAction :: Allow ,
6667 conditions: vec![ PolicyCondition :: SolanaSystemProgramInstructionCondition (
6768 SolanaSystemProgramInstructionCondition {
@@ -71,9 +72,9 @@ async fn test_policies_get_rule() {
7172 value: ConditionValue :: String ( "2000000" . to_string( ) ) ,
7273 }
7374 ) ] ,
74-
75+ id : None ,
7576 method: PolicyMethod :: SignTransaction ,
76- name: PolicyRuleRequestBodyName :: try_from( "updated-rule" ) . unwrap( ) ,
77+ name: CreatePolicyBodyRulesItemName :: try_from( "updated-rule" ) . unwrap( ) ,
7778 }
7879 ] ) . await . unwrap ( ) ;
7980
@@ -98,15 +99,15 @@ async fn test_policies_update_with_auth_context() {
9899 let policy = common:: ensure_test_policy_with_user (
99100 & client,
100101 vec ! [ ] ,
101- Some ( OwnerInput :: PublicKey ( pubkey. to_string ( ) ) ) ,
102+ Some ( OwnerInput :: Variant1 ( OwnerInputPublicKey { public_key : P256PublicKey ( pubkey. to_string ( ) ) } ) ) ,
102103 )
103104 . await
104105 . unwrap ( ) ;
105106
106107 let ctx = AuthorizationContext :: new ( ) . push ( key) ;
107108
108109 let update_body = UpdatePolicyBody {
109- owner : Some ( OwnerInput :: PublicKey ( pubkey. to_string ( ) ) ) ,
110+ owner : Some ( OwnerInput :: Variant1 ( OwnerInputPublicKey { public_key : P256PublicKey ( pubkey. to_string ( ) ) } ) ) ,
110111 owner_id : None ,
111112 name : Some ( UpdatePolicyBodyName :: try_from ( "my-owned-policy" ) . unwrap ( ) ) ,
112113 rules : vec ! [ PolicyRuleRequestBody {
@@ -151,12 +152,12 @@ async fn test_policies_delete() {
151152 // First create a policy to delete
152153 let unique_name = format ! ( "delete-policy-{}" , chrono:: Utc :: now( ) . timestamp( ) ) ;
153154 let policy_body = CreatePolicyBody {
154- chain_type : PolicyChainType :: Solana ,
155+ chain_type : WalletChainType :: Solana ,
155156 name : CreatePolicyBodyName :: try_from ( unique_name) . unwrap ( ) ,
156157 // TODO: set the owner here once we have a JWT
157158 owner : None ,
158159 owner_id : None ,
159- rules : vec ! [ PolicyRuleRequestBody {
160+ rules : vec ! [ CreatePolicyBodyRulesItem {
160161 action: PolicyAction :: Allow ,
161162 conditions: vec![ PolicyCondition :: SolanaSystemProgramInstructionCondition (
162163 SolanaSystemProgramInstructionCondition {
@@ -166,8 +167,9 @@ async fn test_policies_delete() {
166167 value: ConditionValue :: String ( "1000000" . to_string( ) ) ,
167168 }
168169 ) ] ,
170+ id: None ,
169171 method: PolicyMethod :: SignTransaction ,
170- name: PolicyRuleRequestBodyName :: try_from( "test-rule" ) . unwrap( ) ,
172+ name: CreatePolicyBodyRulesItemName :: try_from( "test-rule" ) . unwrap( ) ,
171173 } ] ,
172174 version : CreatePolicyBodyVersion :: try_from ( "1.0" ) . unwrap ( ) ,
173175 } ;
@@ -230,7 +232,7 @@ async fn test_policies_create_rule() {
230232async fn test_policies_update_rule ( ) {
231233 let client = common:: get_test_client ( ) . unwrap ( ) ;
232234
233- let mut rule = PolicyRuleRequestBody {
235+ let create_rule = CreatePolicyBodyRulesItem {
234236 action : PolicyAction :: Deny ,
235237 conditions : vec ! [ PolicyCondition :: SolanaSystemProgramInstructionCondition (
236238 SolanaSystemProgramInstructionCondition {
@@ -240,15 +242,28 @@ async fn test_policies_update_rule() {
240242 value: ConditionValue :: String ( "10000000" . to_string( ) ) ,
241243 }
242244 ) ] ,
245+ id : None ,
243246 method : PolicyMethod :: SignTransaction ,
244- name : PolicyRuleRequestBodyName :: try_from ( "my-great-rule" ) . unwrap ( ) ,
247+ name : CreatePolicyBodyRulesItemName :: try_from ( "my-great-rule" ) . unwrap ( ) ,
245248 } ;
246249
247- let policy = common:: ensure_test_policy ( & client, vec ! [ rule . clone ( ) ] )
250+ let policy = common:: ensure_test_policy ( & client, vec ! [ create_rule ] )
248251 . await
249252 . unwrap ( ) ;
250253
251- rule. action = PolicyAction :: Allow ;
254+ let rule = PolicyRuleRequestBody {
255+ action : PolicyAction :: Allow ,
256+ conditions : vec ! [ PolicyCondition :: SolanaSystemProgramInstructionCondition (
257+ SolanaSystemProgramInstructionCondition {
258+ field: SolanaSystemProgramInstructionConditionField :: TransferLamports ,
259+ field_source: SolanaSystemProgramInstructionConditionFieldSource :: SolanaSystemProgramInstruction ,
260+ operator: ConditionOperator :: Gt ,
261+ value: ConditionValue :: String ( "10000000" . to_string( ) ) ,
262+ }
263+ ) ] ,
264+ method : PolicyMethod :: SignTransaction ,
265+ name : PolicyRuleRequestBodyName :: try_from ( "my-great-rule" ) . unwrap ( ) ,
266+ } ;
252267
253268 let private_key = include_str ! ( "./test_private_key.pem" ) ;
254269 let ctx = AuthorizationContext :: new ( ) . push ( PrivateKey :: new ( private_key. into ( ) ) ) ;
@@ -271,7 +286,7 @@ async fn test_policies_update_rule() {
271286#[ tokio:: test]
272287async fn test_policies_delete_rule ( ) {
273288 let client = common:: get_test_client ( ) . unwrap ( ) ;
274- let policy = common:: ensure_test_policy ( & client, vec ! [ PolicyRuleRequestBody {
289+ let policy = common:: ensure_test_policy ( & client, vec ! [ CreatePolicyBodyRulesItem {
275290 action: PolicyAction :: Allow ,
276291 conditions: vec![ PolicyCondition :: SolanaSystemProgramInstructionCondition (
277292 SolanaSystemProgramInstructionCondition {
@@ -281,8 +296,9 @@ async fn test_policies_delete_rule() {
281296 value: ConditionValue :: String ( "1000000" . to_string( ) ) ,
282297 }
283298 ) ] ,
299+ id: None ,
284300 method: PolicyMethod :: SignTransaction ,
285- name: PolicyRuleRequestBodyName :: try_from( "my-unique-rule" ) . unwrap( ) ,
301+ name: CreatePolicyBodyRulesItemName :: try_from( "my-unique-rule" ) . unwrap( ) ,
286302 } ] ) . await . unwrap ( ) ;
287303
288304 let private_key = include_str ! ( "./test_private_key.pem" ) ;
0 commit comments