File tree Expand file tree Collapse file tree 1 file changed +27
-0
lines changed Expand file tree Collapse file tree 1 file changed +27
-0
lines changed Original file line number Diff line number Diff line change
1
+ from oauth2_provider import utils
2
+
3
+
4
+ def test_jwk_from_pem_caches_jwk ():
5
+ a_tiny_rsa_key = """-----BEGIN RSA PRIVATE KEY-----
6
+ MGQCAQACEQCxqYaL6GtPooVMhVwcZrCfAgMBAAECECyNmdsuHvMqIEl9/Fex27kC
7
+ CQDlc0deuSVrtQIJAMY4MTw2eCeDAgkA5VzfMykQ5yECCQCgkF4Zl0nHPwIJALPv
8
+ +IAFUPv3
9
+ -----END RSA PRIVATE KEY-----"""
10
+
11
+ # For the same private key we expect the same object to be returned
12
+
13
+ jwk1 = utils .jwk_from_pem (a_tiny_rsa_key )
14
+ jwk2 = utils .jwk_from_pem (a_tiny_rsa_key )
15
+
16
+ assert jwk1 is jwk2
17
+
18
+ a_different_tiny_rsa_key = """-----BEGIN RSA PRIVATE KEY-----
19
+ MGMCAQACEQCvyNNNw4J201yzFVogcfgnAgMBAAECEE3oXe5bNlle+xU4EVHTUIEC
20
+ CQDpSvwIvDMSIQIJAMDk47DzG9FHAghtvg1TWpy3oQIJAL6NHlS+RBufAgkA6QLA
21
+ 2GK4aDc=
22
+ -----END RSA PRIVATE KEY-----"""
23
+
24
+ # But for a different key, a different object
25
+ jwk3 = utils .jwk_from_pem (a_different_tiny_rsa_key )
26
+
27
+ assert jwk3 is not jwk1
You can’t perform that action at this time.
0 commit comments