def getSecretAction(args, location, region, **session_params): try: if WILDCARD_CHAR in args.credential: names = expand_wildcard(args.credential, [x["name"] for x in listSecrets(region=region, location=location, only_latest=True, **session_params)]) print(json.dumps(dict((name, getSecret(name, args.version, region=region, location=location, context=args.context, **session_params)) for name in names))) else: sys.stdout.write(getSecret(args.credential, args.version, region=region, location=location, context=args.context, **session_params)) if not args.noline: sys.stdout.write("\n") except ItemNotFound as e: fatal(e) except KmsError as e: fatal(e) except IntegrityError as e: fatal(e)
def test_three_wild_card_with_many_matches(self): self.assertEqual(expand_wildcard("Q*E*Q*E", self.secrets_set2), ["QrEQrE", "QErQE"])
def test_two_wild_cards_with_many_matches(self): self.assertEqual(expand_wildcard("Q*Q*Q", self.secrets_set2), ["QQQ", "QVQQ", "QVQVQ", "QQVQ"])
def test_one_wild_card_with_many_matches(self): self.assertEqual(expand_wildcard("a*b", self.secrets_set), ["ab", "a b", "aabb"])
def test_one_wild_card_with_one_match(self): self.assertEqual(expand_wildcard("a*z", self.secrets_set), ["a[anyvalue]z"])
def test_exact_match_regex(self): self.assertEqual(expand_wildcard("abc", self.secrets_set), ["abc"])
def test_end_regex(self): self.assertEqual(expand_wildcard("ba", self.secrets_set), ["ba"])
def test_start_regex(self): self.assertEqual(expand_wildcard("a", self.secrets_set), ["a"])