33import base64
44from urllib .parse import urlparse , urlencode , parse_qsl
55
6+ import mongomock
67import pytest
78from jwkest .jwk import rsa_load , RSAKey
89from jwkest .jws import JWS
910from oic .oic .message import ClaimsRequest , Claims
10- from pyop .storage import MongoWrapper
11+ from pyop .storage import StorageBase
1112from saml2 import BINDING_HTTP_REDIRECT
1213from saml2 .config import IdPConfig
1314from werkzeug .test import Client
2526CLIENT_SECRET = "secret"
2627CLIENT_REDIRECT_URI = "https://client.example.com/cb"
2728REDIRECT_URI = "https://client.example.com/cb"
29+ DB_URI = "mongodb://localhost/satosa"
2830
2931@pytest .fixture (scope = "session" )
3032def client_db_path (tmpdir_factory ):
@@ -45,26 +47,19 @@ def client_db_path(tmpdir_factory):
4547 return path
4648
4749@pytest .fixture
48- def oidc_frontend_config (signing_key_path , mongodb_instance ):
50+ def oidc_frontend_config (signing_key_path ):
4951 data = {
5052 "module" : "satosa.frontends.openid_connect.OpenIDConnectFrontend" ,
5153 "name" : "OIDCFrontend" ,
5254 "config" : {
5355 "issuer" : "https://proxy-op.example.com" ,
5456 "signing_key_path" : signing_key_path ,
5557 "provider" : {"response_types_supported" : ["id_token" ]},
56- "client_db_uri" : mongodb_instance . get_uri () , # use mongodb for integration testing
57- "db_uri" : mongodb_instance . get_uri () # use mongodb for integration testing
58+ "client_db_uri" : DB_URI , # use mongodb for integration testing
59+ "db_uri" : DB_URI # use mongodb for integration testing
5860 }
5961 }
6062
61- # insert client in mongodb
62- cdb = MongoWrapper (mongodb_instance .get_uri (), "satosa" , "clients" )
63- cdb [CLIENT_ID ] = {
64- "redirect_uris" : [REDIRECT_URI ],
65- "response_types" : ["id_token" ]
66- }
67-
6863 return data
6964
7065
@@ -87,8 +82,20 @@ def oidc_stateless_frontend_config(signing_key_path, client_db_path):
8782 return data
8883
8984
85+ @mongomock .patch (servers = (('localhost' , 27017 ),))
9086class TestOIDCToSAML :
87+ def _client_setup (self ):
88+ """Insert client in mongodb."""
89+ self ._cdb = StorageBase .from_uri (
90+ DB_URI , db_name = "satosa" , collection = "clients" , ttl = None
91+ )
92+ self ._cdb [CLIENT_ID ] = {
93+ "redirect_uris" : [REDIRECT_URI ],
94+ "response_types" : ["id_token" ]
95+ }
96+
9197 def test_full_flow (self , satosa_config_dict , oidc_frontend_config , saml_backend_config , idp_conf ):
98+ self ._client_setup ()
9299 subject_id = "testuser1"
93100
94101 # proxy config
0 commit comments