def testCertificateAuthorityInDifferentLocationRaisesException(self): args = self.parser.parse_args([ 'projects/foo/locations/us-east1/certificateAuthorities/new-ca', '--create-csr', '--csr-output-file=csr.pem', '--subject=CN=test,O=Google', '--kms-key-version=projects/foo/locations/us-west1/keyRings/kr1/cryptoKeys/k1/cryptoKeyVersions/1', ]) with self.AssertRaisesExceptionMatches( exceptions.InvalidArgumentException, 'same location'): create._ParseResourceArgs(args)
def testKmsKeyVersionInUnsupportedLocationsRaisesException(self): args = self.parser.parse_args([ 'new-ca', '--subject=CN=test,O=Google', '--create-csr', '--csr-output-file=csr.pem', '--kms-key-version=1', '--kms-key=k1', '--kms-keyring=kr1', '--kms-location=us', ]) with self.AssertRaisesExceptionMatches( exceptions.InvalidArgumentException, 'unsupported location'): create._ParseResourceArgs(args)
def testInlineFirstPartyIssuer(self): args = self.parser.parse_args([ 'new-ca', '--issuer=projects/foo/locations/us-west1/certificateAuthorities/my-root', '--subject=CN=test,O=Google', '--kms-key-version=projects/foo/locations/us-west1/keyRings/kr1/cryptoKeys/k1/cryptoKeyVersions/1', ]) _, _, issuer_ref = create._ParseResourceArgs(args) self.assertEqual(issuer_ref.certificateAuthoritiesId, 'my-root') self.assertEqual(issuer_ref.locationsId, 'us-west1')
def testCertificateAuthorityUsesLocationFromKeyVersion(self): args = self.parser.parse_args([ 'new-ca', '--subject=CN=test,O=Google', '--create-csr', '--csr-output-file=csr.pem', '--kms-key-version=1', '--kms-key=k1', '--kms-keyring=kr1', '--kms-location=us-west1', ]) _, ca_ref, _ = create._ParseResourceArgs(args) self.assertEqual(ca_ref.locationsId, 'us-west1')
def testParseInlineKmsKeyVersion(self): args = self.parser.parse_args([ 'new-ca', '--create-csr', '--csr-output-file=csr.pem', '--subject=CN=test,O=Google', '--kms-key-version=projects/foo/locations/us-west1/keyRings/kr1/cryptoKeys/k1/cryptoKeyVersions/1', ]) kms_key_version_ref, _, _ = create._ParseResourceArgs(args) self.assertEqual(kms_key_version_ref.projectsId, 'foo') self.assertEqual(kms_key_version_ref.locationsId, 'us-west1') self.assertEqual(kms_key_version_ref.keyRingsId, 'kr1') self.assertEqual(kms_key_version_ref.cryptoKeysId, 'k1') self.assertEqual(kms_key_version_ref.cryptoKeyVersionsId, '1')
def testParseComponentizedKmsKeyVersion(self): args = self.parser.parse_args([ 'new-ca', '--subject=CN=test,O=Google', '--create-csr', '--csr-output-file=csr.pem', '--kms-key-version=1', '--kms-key=k1', '--kms-keyring=kr1', '--kms-location=us-west1', '--kms-project=foo', ]) kms_key_version_ref, _, _ = create._ParseResourceArgs(args) self.assertEqual(kms_key_version_ref.projectsId, 'foo') self.assertEqual(kms_key_version_ref.locationsId, 'us-west1') self.assertEqual(kms_key_version_ref.keyRingsId, 'kr1') self.assertEqual(kms_key_version_ref.cryptoKeysId, 'k1') self.assertEqual(kms_key_version_ref.cryptoKeyVersionsId, '1')