File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11use discover:: jwt:: * ;
22use regex_lite:: Regex ;
33
4+ const ECDSA_PRIVATE_KEY : & str = r#"-----BEGIN PRIVATE KEY-----
5+ MIGHAgEAMBMGByqGSM49AgEGCCqGSM49AwEHBG0wawIBAQQg5lTeXefIw7PeO809
6+ pxg9THzXGN5PToqXGXzhCcTpGbKhRANCAAQt5X5osNzNIxexaywne36MaSFO2Lok
7+ Vk6DwMW41i7/Hr0DjGlvBRmCCf0DcsyDyK14OAXltdwX5rYWSkGq8wev
8+ -----END PRIVATE KEY-----"# ;
9+
10+ const ECDSA_PUBLIC_KEY : & str = r#"-----BEGIN PUBLIC KEY-----
11+ MFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAELeV+aLDczSMXsWssJ3t+jGkhTti6
12+ JFZOg8DFuNYu/x69A4xpbwUZggn9A3LMg8iteDgF5bXcF+a2FkpBqvMHrw==
13+ -----END PUBLIC KEY-----"# ;
14+
415#[ test]
516fn assert_create_token ( ) {
617 let manager = TokenManager :: new (
7- Some ( Key :: Path ( "./tests/private.key" ) ) ,
8- Key :: Path ( "./tests/key.pub" ) ,
18+ Some ( Key :: Text :: < String > ( ECDSA_PRIVATE_KEY . to_string ( ) ) ) ,
19+ Key :: Text :: < String > ( ECDSA_PUBLIC_KEY . to_string ( ) ) ,
920 )
1021 . unwrap ( ) ;
1122
1223 let claims = Claims :: new ( "user1" . into ( ) ) ;
1324
1425 let token = manager. create_token ( & claims) . unwrap ( ) ;
1526
16- assert ! ( token. starts_with( "eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiJ9 ." ) ) ;
27+ assert ! ( token. starts_with( "eyJ0eXAiOiJKV1QiLCJhbGciOiJFUzI1NiJ9 ." ) ) ;
1728 assert ! (
1829 Regex :: new( r"^[A-Za-z0-9_-]{2,}(?:\.[A-Za-z0-9_-]{2,}){2}$" )
1930 . unwrap( )
Load Diff This file was deleted.
Load Diff This file was deleted.
You can’t perform that action at this time.
0 commit comments