@@ -47,171 +47,6 @@ async fn test_user_profile_api() -> Result<()> {
4747 Ok ( ( ) )
4848}
4949
50- #[ tokio:: test]
51- async fn test_kv_storage_apis ( ) -> Result < ( ) > {
52- // Load environment variables
53- let env_path = std:: path:: Path :: new ( "../.env.local" ) ;
54- if env_path. exists ( ) {
55- dotenvy:: from_path ( env_path) . ok ( ) ;
56- }
57-
58- let base_url = std:: env:: var ( "VITE_OPEN_SECRET_API_URL" )
59- . unwrap_or_else ( |_| "http://localhost:3000" . to_string ( ) ) ;
60- let client_id = std:: env:: var ( "VITE_TEST_CLIENT_ID" )
61- . ok ( )
62- . and_then ( |id| Uuid :: parse_str ( & id) . ok ( ) )
63- . expect ( "VITE_TEST_CLIENT_ID must be set" ) ;
64-
65- // Create client and login as guest for isolation
66- let client = common:: new_test_client ( base_url) ?;
67- client. perform_attestation_handshake ( ) . await ?;
68-
69- let guest_password = "test_kv_password" ;
70- client
71- . register_guest ( guest_password. to_string ( ) , client_id)
72- . await ?;
73-
74- // Test KV operations
75- let test_key = "test_key_rust" ;
76- let test_value = "test_value_from_rust_sdk" ;
77-
78- // PUT
79- let put_result = client. kv_put ( test_key, test_value. to_string ( ) ) . await ?;
80- assert_eq ! ( put_result, test_value) ;
81- println ! ( "✓ KV PUT successful" ) ;
82-
83- // GET
84- let get_result = client. kv_get ( test_key) . await ?;
85- assert_eq ! ( get_result, test_value) ;
86- println ! ( "✓ KV GET successful" ) ;
87-
88- // LIST
89- let list_result = client. kv_list ( ) . await ?;
90- assert ! ( list_result. iter( ) . any( |item| item. key == test_key) ) ;
91- println ! ( "✓ KV LIST successful" ) ;
92-
93- // DELETE
94- client. kv_delete ( test_key) . await ?;
95- println ! ( "✓ KV DELETE successful" ) ;
96-
97- // Verify deletion
98- let list_after_delete = client. kv_list ( ) . await ?;
99- assert ! ( !list_after_delete. iter( ) . any( |item| item. key == test_key) ) ;
100- println ! ( "✓ KV deletion verified" ) ;
101-
102- Ok ( ( ) )
103- }
104-
105- #[ tokio:: test]
106- async fn test_kv_delete_all ( ) -> Result < ( ) > {
107- // Load environment variables
108- let env_path = std:: path:: Path :: new ( "../.env.local" ) ;
109- if env_path. exists ( ) {
110- dotenvy:: from_path ( env_path) . ok ( ) ;
111- }
112-
113- let base_url = std:: env:: var ( "VITE_OPEN_SECRET_API_URL" )
114- . unwrap_or_else ( |_| "http://localhost:3000" . to_string ( ) ) ;
115- let client_id = std:: env:: var ( "VITE_TEST_CLIENT_ID" )
116- . ok ( )
117- . and_then ( |id| Uuid :: parse_str ( & id) . ok ( ) )
118- . expect ( "VITE_TEST_CLIENT_ID must be set" ) ;
119-
120- // Create client and login as guest for isolation
121- let client = common:: new_test_client ( base_url) ?;
122- client. perform_attestation_handshake ( ) . await ?;
123-
124- client
125- . register_guest ( "test_kv_delete_all" . to_string ( ) , client_id)
126- . await ?;
127-
128- // Add multiple keys
129- client. kv_put ( "key1" , "value1" . to_string ( ) ) . await ?;
130- client. kv_put ( "key2" , "value2" . to_string ( ) ) . await ?;
131- client. kv_put ( "key3" , "value3" . to_string ( ) ) . await ?;
132-
133- // Verify they exist
134- let list_result = client. kv_list ( ) . await ?;
135- assert ! ( list_result. len( ) >= 3 ) ;
136- println ! ( "✓ Keys added successfully" ) ;
137-
138- // Delete all
139- client. kv_delete_all ( ) . await ?;
140- println ! ( "✓ kv_delete_all called" ) ;
141-
142- // Verify empty
143- let list_after_delete = client. kv_list ( ) . await ?;
144- assert ! ( list_after_delete. is_empty( ) ) ;
145- println ! ( "✓ All keys deleted successfully" ) ;
146-
147- Ok ( ( ) )
148- }
149-
150- #[ tokio:: test]
151- async fn test_kv_storage_with_special_characters ( ) -> Result < ( ) > {
152- // Load environment variables
153- let env_path = std:: path:: Path :: new ( "../.env.local" ) ;
154- if env_path. exists ( ) {
155- dotenvy:: from_path ( env_path) . ok ( ) ;
156- }
157-
158- let base_url = std:: env:: var ( "VITE_OPEN_SECRET_API_URL" )
159- . unwrap_or_else ( |_| "http://localhost:3000" . to_string ( ) ) ;
160- let client_id = std:: env:: var ( "VITE_TEST_CLIENT_ID" )
161- . ok ( )
162- . and_then ( |id| Uuid :: parse_str ( & id) . ok ( ) )
163- . expect ( "VITE_TEST_CLIENT_ID must be set" ) ;
164-
165- // Create client and login
166- let client = common:: new_test_client ( base_url) ?;
167- client. perform_attestation_handshake ( ) . await ?;
168- client
169- . register_guest ( "test_kv_special" . to_string ( ) , client_id)
170- . await ?;
171-
172- // Test with various special characters that need URL encoding
173- let test_cases = vec ! [
174- ( "key/with/slashes" , "value1" ) ,
175- ( "key?with=query¶ms" , "value2" ) ,
176- ( "key#with#hash" , "value3" ) ,
177- ( "key with spaces" , "value4" ) ,
178- ( "key%with%percents" , "value5" ) ,
179- ( "key@with!special$chars" , "value6" ) ,
180- ( "key[with]brackets{and}braces" , "value7" ) ,
181- ( "key:with:colons;semicolons" , "value8" ) ,
182- ] ;
183-
184- for ( key, value) in & test_cases {
185- println ! ( "Testing key: {:?}" , key) ;
186-
187- // PUT with special characters
188- let put_result = client. kv_put ( key, value. to_string ( ) ) . await ?;
189- assert_eq ! ( put_result, * value) ;
190-
191- // GET with special characters
192- let get_result = client. kv_get ( key) . await ?;
193- assert_eq ! ( get_result, * value) ;
194-
195- // DELETE with special characters
196- client. kv_delete ( key) . await ?;
197-
198- println ! ( "✓ KV operations successful for key: {:?}" , key) ;
199- }
200-
201- // Verify all were deleted
202- let final_list = client. kv_list ( ) . await ?;
203- for ( key, _) in & test_cases {
204- assert ! (
205- !final_list. iter( ) . any( |item| item. key == * key) ,
206- "Key {:?} should have been deleted" ,
207- key
208- ) ;
209- }
210- println ! ( "✓ All special character keys handled correctly" ) ;
211-
212- Ok ( ( ) )
213- }
214-
21550#[ tokio:: test]
21651async fn test_private_key_generation ( ) -> Result < ( ) > {
21752 // Load environment variables
0 commit comments