@@ -529,7 +529,7 @@ def __init__(self, response: dict):
529529class _SyncGatewayBase :
530530 """
531531 Base class for Sync Gateway clients containing common document and database operations.
532- This class should not be instantiated directly - use SyncGateway or SyncGatewayPublic instead.
532+ This class should not be instantiated directly - use SyncGateway or SyncGatewayUserClient instead.
533533 """
534534
535535 def __init__ (
@@ -556,21 +556,6 @@ def __init__(
556556 port ,
557557 BasicAuth (username , password , "ascii" ),
558558 )
559- r = requests .get (
560- f"{ scheme } { url } :{ port } /_config" ,
561- auth = (username , password ),
562- # disable hostname verification as we do in _create_session
563- verify = False ,
564- timeout = 10 ,
565- )
566- r .raise_for_status ()
567- try :
568- self .using_rosmar = r .json ()["bootstrap" ]["server" ].startswith ("rosmar" )
569- except AttributeError :
570- raise CblTestError (
571- "Unexpected response {r.json()} from Sync Gateway /_config endpoint, cannot determine if using Rosmar"
572- ) from None
573- self .using_rosmar = False
574559
575560 @property
576561 def hostname (self ) -> str :
@@ -587,6 +572,11 @@ def secure(self) -> bool:
587572 """Gets whether the Sync Gateway instance uses TLS"""
588573 return self .__secure
589574
575+ @property
576+ def scheme (self ) -> str :
577+ """Gets the URL scheme to use when connecting to the Sync Gateway instance (http or https)"""
578+ return "https://" if self .secure else "http://"
579+
590580 def _create_session (
591581 self , secure : bool , scheme : str , url : str , port : int , auth : BasicAuth | None
592582 ) -> ClientSession :
@@ -646,9 +636,8 @@ async def _send_request(
646636
647637 async def get_version (self ) -> CouchbaseVersion :
648638 # Telemetry not really important for this call
649- scheme = "https://" if self .secure else "http://"
650639 async with self ._create_session (
651- self .secure , scheme , self .hostname , 4984 , None
640+ self .secure , self . scheme , self .hostname , 4984 , None
652641 ) as s :
653642 resp = await self ._send_request ("get" , "/" , session = s )
654643 assert isinstance (resp , dict )
@@ -1345,9 +1334,8 @@ async def get_document_revision_public(
13451334 )
13461335 params = {"rev" : revision }
13471336
1348- scheme = "https://" if self .secure else "http://"
13491337 async with self ._create_session (
1350- self .secure , scheme , self .hostname , 4984 , auth
1338+ self .secure , self . scheme , self .hostname , 4984 , auth
13511339 ) as session :
13521340 return await self ._send_request ("GET" , path , params = params , session = session )
13531341
@@ -1615,6 +1603,21 @@ def __init__(
16151603 """
16161604 super ().__init__ (url , username , password , port , secure )
16171605 self .__public_port = public_port
1606+ r = requests .get (
1607+ f"{ self .scheme } { url } :{ port } /_config" ,
1608+ auth = (username , password ),
1609+ # disable hostname verification as we do in _create_session
1610+ verify = False ,
1611+ timeout = 10 ,
1612+ )
1613+ r .raise_for_status ()
1614+ config = r .json ()
1615+ try :
1616+ self .using_rosmar = config ["bootstrap" ]["server" ].startswith ("rosmar" )
1617+ except KeyError :
1618+ raise CblTestError (
1619+ f"Unexpected response from Sync Gateway /_config endpoint, cannot determine if using Rosmar. { config } "
1620+ ) from None
16181621
16191622 def create_collection_access_dict (self , input : dict [str , list [str ]]) -> dict :
16201623 """
@@ -1846,9 +1849,8 @@ async def start(self, config_name: str = "bootstrap") -> None:
18461849 # Check if SGW is already running by probing the public endpoint (4984)
18471850 try :
18481851 # Use a short timeout to distinguish "not running" from "slow"
1849- scheme = "https://" if self .secure else "http://"
18501852 async with self ._create_session (
1851- self .secure , scheme , self .hostname , 4984 , None
1853+ self .secure , self . scheme , self .hostname , 4984 , None
18521854 ) as session :
18531855 async with session .get ("/" , timeout = ClientTimeout (total = 5 )) as resp :
18541856 if resp .status == 200 :
0 commit comments