示例#1
0
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)
示例#2
0
 def test_three_wild_card_with_many_matches(self):
     self.assertEqual(expand_wildcard("Q*E*Q*E", self.secrets_set2), ["QrEQrE", "QErQE"])
示例#3
0
 def test_two_wild_cards_with_many_matches(self):
     self.assertEqual(expand_wildcard("Q*Q*Q", self.secrets_set2), ["QQQ", "QVQQ", "QVQVQ", "QQVQ"])
示例#4
0
 def test_one_wild_card_with_many_matches(self):
     self.assertEqual(expand_wildcard("a*b", self.secrets_set), ["ab", "a b", "aabb"])
示例#5
0
 def test_one_wild_card_with_one_match(self):
     self.assertEqual(expand_wildcard("a*z", self.secrets_set), ["a[anyvalue]z"])
示例#6
0
 def test_exact_match_regex(self):
     self.assertEqual(expand_wildcard("abc", self.secrets_set), ["abc"])
示例#7
0
 def test_end_regex(self):
     self.assertEqual(expand_wildcard("ba", self.secrets_set), ["ba"])
示例#8
0
 def test_start_regex(self):
     self.assertEqual(expand_wildcard("a", self.secrets_set), ["a"])
示例#9
0
 def test_three_wild_card_with_many_matches(self):
     self.assertEqual(expand_wildcard("Q*E*Q*E", self.secrets_set2),
                      ["QrEQrE", "QErQE"])
示例#10
0
 def test_two_wild_cards_with_many_matches(self):
     self.assertEqual(expand_wildcard("Q*Q*Q", self.secrets_set2),
                      ["QQQ", "QVQQ", "QVQVQ", "QQVQ"])
示例#11
0
 def test_one_wild_card_with_many_matches(self):
     self.assertEqual(expand_wildcard("a*b", self.secrets_set),
                      ["ab", "a b", "aabb"])
示例#12
0
 def test_one_wild_card_with_one_match(self):
     self.assertEqual(expand_wildcard("a*z", self.secrets_set),
                      ["a[anyvalue]z"])
示例#13
0
 def test_exact_match_regex(self):
     self.assertEqual(expand_wildcard("abc", self.secrets_set), ["abc"])
示例#14
0
 def test_end_regex(self):
     self.assertEqual(expand_wildcard("ba", self.secrets_set), ["ba"])
示例#15
0
 def test_start_regex(self):
     self.assertEqual(expand_wildcard("a", self.secrets_set), ["a"])