def Args(parser): id_group = parser.add_group(mutex=True, required=True, help='The certificate identifier.') base.Argument( '--serial-number', help='The serial number of the certificate.').AddToParser(id_group) concept_parsers.ConceptParser([ presentation_specs.ResourcePresentationSpec( '--certificate', resource_args.CreateCertificateResourceSpec('certificate'), 'The certificate to revoke.', flag_name_overrides={ 'issuer': '', 'issuer-location': '', 'project': '', }, group=id_group), presentation_specs.ResourcePresentationSpec( '--issuer', resource_args.CreateCertificateAuthorityResourceSpec( 'Issuing CA', 'issuer', 'issuer-location'), 'The issuing certificate authority of the certificate to revoke.', required=False), ]).AddToParser(parser) flags.AddRevocationReasonFlag(parser)
def Args(parser): id_group = parser.add_group(mutex=True, required=True, help='The certificate identifier.') serial_num_group = id_group.add_group( help='The serial number and certificate authority resource.', required=False) serial_num_group.add_argument( '--serial-number', help='The serial number of the certificate.', required=True) concept_parsers.ConceptParser([ presentation_specs.ResourcePresentationSpec( '--certificate', resource_args.CreateCertificateResourceSpec('CERTIFICATE'), 'The certificate to revoke.', required=False, prefixes=True, group=id_group), presentation_specs.ResourcePresentationSpec( '--issuer', resource_args.CreateCertificateAuthorityResourceSpec( 'CERTIFICATE_AUTHORITY', 'issuer', 'issuer-location'), 'The issuing certificate authority of the certificate to revoke.', required=False, group=serial_num_group), ]).AddToParser(parser) flags.AddRevocationReasonFlag(parser)
def testRevocationReasonFlagInvalid(self): flags.AddRevocationReasonFlag(self.parser) with self.assertRaises(cli_test_base.MockArgumentError): self.parser.parse_args(['--reason', 'invalid'])
def testRevocationReasonFlag(self): flags.AddRevocationReasonFlag(self.parser) args = self.parser.parse_args(['--reason', 'key-compromise']) self.assertEqual(args.reason, 'key-compromise')