Skip to content

Commit

Permalink
Merge pull request #2223 from ganga-devs/credential_fix
Browse files Browse the repository at this point in the history
Update AFS credential
  • Loading branch information
mesmith75 authored Dec 8, 2023
2 parents 16ffd41 + 6a7ad27 commit ff88b43
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
17 changes: 16 additions & 1 deletion ganga/GangaCore/GPIDev/Credentials/AfsToken.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class AfsTokenInfo(ICredentialInfo):
should_warn = False

info_pattern = re.compile(
r"^User's \(AFS ID \d*\) tokens for (?P<id>\w*@\S*) \[Expires (?P<expires>.*)\]$", re.MULTILINE)
r"^User's \(AFS ID \d*\) (rxkad )?tokens for ((?P<id>\w*@)?\S*) \[Expires (?P<expires>.*)\]$", re.MULTILINE)

__slots__ = ('shell', 'cache', 'initial_requirements')

Expand Down Expand Up @@ -130,6 +130,21 @@ def expiry_time(self):

return soonest

def exists(self):
# type: () -> bool
"""
Does the credential exist
"""
info = self.info
matches = re.finditer(AfsTokenInfo.info_pattern, info)
if not matches:
return False
all_tokens = [_m for _m in matches]
if len(all_tokens) > 0:
return True
else:
return False

def default_location(self):
"""
This returns the default location of a kerberos token on disk as determined from the uid
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ def _check_call(self, cmd):
def fake_shell(mocker):
s = mocker.patch('GangaCore.GPIDev.Credentials.VomsProxy.VomsProxyInfo.shell', FakeShell())
mocker.patch('GangaCore.GPIDev.Adapters.ICredentialInfo.os.path.exists', return_value=True)
mocker.patch('GangaCore.GPIDev.Credentials.AfsToken.AfsTokenInfo.exists', return_value=True)
mocker.patch('GangaCore.GPIDev.Credentials.CredentialStore.CredentialStore.enable_caching', False)
yield s

Expand Down

0 comments on commit ff88b43

Please sign in to comment.