@@ -12,13 +12,15 @@ def __common_init(self, cxone_client : CxOneClient):
1212 self .__fetched_scan_config = False
1313 self .__fetched_repomgr_config = False
1414 self .__fetched_scm_config = False
15+ self .__is_imported = False
1516 self .__lock = asyncio .Lock ()
1617
1718 @staticmethod
1819 async def from_project_json (cxone_client : CxOneClient , json : dict ):
1920 retval = ProjectRepoConfig ()
2021 ProjectRepoConfig .__common_init (retval , cxone_client )
2122 retval .__project_data = json
23+ retval .__is_imported = "repoId" in retval .__project_data .keys ()
2224
2325 return retval
2426
@@ -27,6 +29,7 @@ async def from_project_id(cxone_client : CxOneClient, project_id : str):
2729 retval = ProjectRepoConfig ()
2830 ProjectRepoConfig .__common_init (retval , cxone_client )
2931 retval .__project_data = json_on_ok (await retrieve_project_info (cxone_client , project_id ))
32+ retval .__is_imported = "repoId" in retval .__project_data .keys ()
3033 return retval
3134
3235
@@ -72,7 +75,12 @@ async def __get_repomgr_config(self):
7275 if not self .__fetched_repomgr_config :
7376 self .__fetched_repomgr_config = True
7477 repoId = self .__project_data ['repoId' ]
75- self .__repomgr_config = json_on_ok (await retrieve_repo_by_id (self .__client , repoId ))
78+
79+ repo_response = await retrieve_repo_by_id (self .__client , repoId )
80+ if repo_response .ok :
81+ self .__repomgr_config = repo_response .json ()
82+ else :
83+ self .__repomgr_config = None
7684
7785 return self .__repomgr_config
7886
@@ -120,7 +128,7 @@ async def __get_logical_primary_branch(self):
120128 return None
121129
122130 async def __get_scm_config (self ):
123- if not await self .is_scm_imported :
131+ if not await self .is_scm_imported or await self . scm_creds_expired :
124132 return None
125133
126134 this_scm_id = await self .scm_id
@@ -143,12 +151,19 @@ async def repo_url(self):
143151
144152 @property
145153 async def is_scm_imported (self ):
146- return await self .__get_repomgr_config () is not None
154+ return self .__is_imported
155+
156+
157+ @property
158+ async def scm_creds_expired (self ):
159+ if not self .__is_imported :
160+ return True
147161
162+ return await self .__get_repomgr_config () is None
148163
149164 @property
150165 async def scm_id (self ):
151- if not await self .is_scm_imported :
166+ if not await self .is_scm_imported or await self . scm_creds_expired :
152167 return None
153168
154169 cfg = await self .__get_repomgr_config ()
@@ -162,15 +177,15 @@ async def scm_id(self):
162177
163178 @property
164179 async def scm_org (self ):
165- if not await self .is_scm_imported :
180+ if not await self .is_scm_imported or await self . scm_creds_expired :
166181 return None
167182
168183 return CloneUrlParser (await self .scm_type , await self .repo_url ).org
169184
170185
171186 @property
172187 async def scm_type (self ):
173- if not await self .is_scm_imported :
188+ if not await self .is_scm_imported or await self . scm_creds_expired :
174189 return None
175190
176191 cfg = await self .__get_scm_config ()
@@ -183,14 +198,14 @@ async def scm_type(self):
183198
184199 @property
185200 async def repo_id (self ):
186- if not await self .is_scm_imported :
201+ if not await self .is_scm_imported or await self . scm_creds_expired :
187202 return None
188203
189204 return self .__project_data ['repoId' ]
190205
191206 @property
192207 async def scm_repo_id (self ):
193- if not await self .is_scm_imported :
208+ if not await self .is_scm_imported or await self . scm_creds_expired :
194209 return None
195210
196211 return self .__project_data ['scmRepoId' ]
@@ -203,7 +218,7 @@ def project_id(self):
203218 async def get_enabled_scanners (self , by_branch ):
204219 engines = []
205220
206- if await self .is_scm_imported :
221+ if await self .is_scm_imported and not await self . scm_creds_expired :
207222 # Use the engine configuration on the import
208223 cfg = await self .__get_repomgr_config ()
209224
0 commit comments