File tree Expand file tree Collapse file tree 4 files changed +21
-3
lines changed
crates/crates_io_trustpub Expand file tree Collapse file tree 4 files changed +21
-3
lines changed Original file line number Diff line number Diff line change @@ -8,7 +8,7 @@ edition = "2024"
8
8
workspace = true
9
9
10
10
[features ]
11
- test-helpers = [" dep:mockall" ]
11
+ test-helpers = [" dep:mockall" , " dep:serde_json " ]
12
12
13
13
[dependencies ]
14
14
anyhow = " =1.0.98"
@@ -18,6 +18,7 @@ mockall = { version = "=0.13.1", optional = true }
18
18
reqwest = { version = " =0.12.15" , features = [" gzip" , " json" ] }
19
19
regex = " =1.11.1"
20
20
serde = { version = " =1.0.219" , features = [" derive" ] }
21
+ serde_json = { version = " =1.0.140" , optional = true }
21
22
thiserror = " =2.0.12"
22
23
tokio = { version = " =1.45.0" , features = [" sync" ] }
23
24
Original file line number Diff line number Diff line change @@ -18,3 +18,21 @@ pub trait OidcKeyStore: Send + Sync {
18
18
/// is an error while fetching the key, it will return an error.
19
19
async fn get_oidc_key ( & self , key_id : & str ) -> anyhow:: Result < Option < DecodingKey > > ;
20
20
}
21
+
22
+ #[ cfg( feature = "test-helpers" ) ]
23
+ impl MockOidcKeyStore {
24
+ /// Creates a new instance of [`MockOidcKeyStore`] based on the RSA keys
25
+ /// provided in the [`crate::test_keys`] module.
26
+ pub fn with_test_key ( ) -> Self {
27
+ use crate :: test_keys:: { DECODING_KEY , KEY_ID } ;
28
+ use mockall:: predicate:: * ;
29
+
30
+ let mut mock = Self :: new ( ) ;
31
+
32
+ mock. expect_get_oidc_key ( )
33
+ . with ( eq ( KEY_ID ) )
34
+ . returning ( |_| Ok ( Some ( DECODING_KEY . clone ( ) ) ) ) ;
35
+
36
+ mock
37
+ }
38
+ }
Original file line number Diff line number Diff line change 2
2
3
3
pub mod github;
4
4
pub mod keystore;
5
- #[ cfg( test) ]
5
+ #[ cfg( any ( test, feature = "test-helpers" ) ) ]
6
6
pub mod test_keys;
Original file line number Diff line number Diff line change @@ -54,7 +54,6 @@ pub(crate) const KEY_ID: &str = "c0ffee";
54
54
static ENCODING_KEY : LazyLock < EncodingKey > =
55
55
LazyLock :: new ( || EncodingKey :: from_rsa_pem ( PRIVATE_KEY_PEM ) . unwrap ( ) ) ;
56
56
57
- #[ allow( unused) ]
58
57
pub ( crate ) static DECODING_KEY : LazyLock < DecodingKey > = LazyLock :: new ( || {
59
58
let jwk = serde_json:: from_str ( PUBLIC_KEY_JWK ) . unwrap ( ) ;
60
59
DecodingKey :: from_jwk ( & jwk) . unwrap ( )
You can’t perform that action at this time.
0 commit comments