From 9caff31ab75d940a5354cbe205dd390962d16465 Mon Sep 17 00:00:00 2001 From: SitaLakshmi Date: Tue, 17 Jan 2023 17:49:08 -0500 Subject: [PATCH] lint fix --- .../java/privateca/ActivateSubordinateCa.java | 24 ++--- .../src/main/java/privateca/CreateCaPool.java | 12 +-- .../java/privateca/CreateCertificate.java | 10 +- .../privateca/CreateCertificateAuthority.java | 10 +- ...ate_CSR.java => CreateCertificateCsr.java} | 24 ++--- .../java/privateca/CreateSubordinateCa.java | 10 +- .../src/main/java/privateca/DeleteCaPool.java | 16 ++-- .../privateca/DeleteCertificateAuthority.java | 10 +- .../DisableCertificateAuthority.java | 10 +- .../privateca/EnableCertificateAuthority.java | 10 +- .../java/privateca/FilterCertificates.java | 13 +-- .../privateca/ListCertificateAuthorities.java | 10 +- .../main/java/privateca/ListCertificates.java | 10 +- .../java/privateca/RevokeCertificate.java | 10 +- .../UndeleteCertificateAuthority.java | 10 +- ...y.java => UpdateCaPoolIssuancePolicy.java} | 17 ++-- .../privateca/UpdateCertificateAuthority.java | 10 +- .../src/test/java/privateca/SnippetsIT.java | 92 +++++++++---------- 18 files changed, 155 insertions(+), 153 deletions(-) rename privateca/snippets/src/main/java/privateca/{CreateCertificate_CSR.java => CreateCertificateCsr.java} (88%) rename privateca/snippets/src/main/java/privateca/{UpdateCaPool_IssuancePolicy.java => UpdateCaPoolIssuancePolicy.java} (92%) diff --git a/privateca/snippets/src/main/java/privateca/ActivateSubordinateCa.java b/privateca/snippets/src/main/java/privateca/ActivateSubordinateCa.java index f37e86c89f6..e233df5ee85 100644 --- a/privateca/snippets/src/main/java/privateca/ActivateSubordinateCa.java +++ b/privateca/snippets/src/main/java/privateca/ActivateSubordinateCa.java @@ -36,14 +36,14 @@ public static void main(String[] args) // location: For a list of locations, see: // https://cloud.google.com/certificate-authority-service/docs/locations - // pool_Id: Set a unique id for the CA pool. + // poolId: Set a unique id for the CA pool. // subordinateCaName: The CA to be activated. - // pemCACertificate: The signed certificate, obtained by signing the CSR. + // pemCaCertificate: The signed certificate, obtained by signing the CSR. String project = "your-project-id"; String location = "ca-location"; - String pool_Id = "ca-pool-id"; + String poolId = "ca-pool-id"; String subordinateCaName = "subordinate-certificate-authority-name"; - String pemCACertificate = + String pemCaCertificate = "-----BEGIN CERTIFICATE-----\n" + "sample-pem-certificate\n" + "-----END CERTIFICATE-----"; // certificateAuthorityName: The name of the certificate authority which signed the CSR. @@ -51,21 +51,21 @@ public static void main(String[] args) // then use the CA's issuerCertificateChain. String certificateAuthorityName = "certificate-authority-name"; - activateSubordinateCA( - project, location, pool_Id, certificateAuthorityName, subordinateCaName, pemCACertificate); + activateSubordinateCa( + project, location, poolId, certificateAuthorityName, subordinateCaName, pemCaCertificate); } // Activate a subordinate CA. // *Prerequisite*: Get the CSR of the subordinate CA signed by another CA. Pass in the signed // certificate and (issuer CA's name or the issuer CA's Certificate chain). // *Post*: After activating the subordinate CA, it should be enabled before issuing certificates. - public static void activateSubordinateCA( + public static void activateSubordinateCa( String project, String location, - String pool_Id, + String poolId, String certificateAuthorityName, String subordinateCaName, - String pemCACertificate) + String pemCaCertificate) throws ExecutionException, InterruptedException, IOException { // Initialize client that will be used to send requests. This client only needs to be created // once, and can be reused for multiple requests. After completing all of your requests, call @@ -75,14 +75,14 @@ public static void activateSubordinateCA( CertificateAuthorityServiceClient.create()) { // Subordinate CA parent. String subordinateCaParent = - CertificateAuthorityName.of(project, location, pool_Id, subordinateCaName).toString(); + CertificateAuthorityName.of(project, location, poolId, subordinateCaName).toString(); // Construct the "Activate CA Request". ActivateCertificateAuthorityRequest activateCertificateAuthorityRequest = ActivateCertificateAuthorityRequest.newBuilder() .setName(subordinateCaParent) // The signed certificate. - .setPemCaCertificate(pemCACertificate) + .setPemCaCertificate(pemCaCertificate) .setSubordinateConfig( SubordinateConfig.newBuilder() // Follow one of the below methods: @@ -91,7 +91,7 @@ public static void activateSubordinateCA( // Name. .setCertificateAuthority( CertificateAuthorityName.of( - project, location, pool_Id, certificateAuthorityName) + project, location, poolId, certificateAuthorityName) .toString()) // Method 2: If issuer CA is external to Google Cloud, set the issuer's diff --git a/privateca/snippets/src/main/java/privateca/CreateCaPool.java b/privateca/snippets/src/main/java/privateca/CreateCaPool.java index 5907b5266d7..044bb67ad42 100644 --- a/privateca/snippets/src/main/java/privateca/CreateCaPool.java +++ b/privateca/snippets/src/main/java/privateca/CreateCaPool.java @@ -37,16 +37,16 @@ public static void main(String[] args) // TODO(developer): Replace these variables before running the sample. // location: For a list of locations, see: // https://cloud.google.com/certificate-authority-service/docs/locations - // pool_Id: Set a unique pool_Id for the CA pool. + // poolId: Set a unique poolId for the CA pool. String project = "your-project-id"; String location = "ca-location"; - String pool_Id = "ca-pool-id"; - createCaPool(project, location, pool_Id); + String poolId = "ca-pool-id"; + createCaPool(project, location, poolId); } // Create a Certificate Authority Pool. All certificates created under this CA pool will // follow the same issuance policy, IAM policies,etc., - public static void createCaPool(String project, String location, String pool_Id) + public static void createCaPool(String project, String location, String poolId) throws InterruptedException, ExecutionException, IOException { // Initialize client that will be used to send requests. This client only needs to be created // once, and can be reused for multiple requests. After completing all of your requests, call @@ -69,7 +69,7 @@ Set the Tier (see: https://cloud.google.com/certificate-authority-service/docs/t CreateCaPoolRequest caPoolRequest = CreateCaPoolRequest.newBuilder() .setParent(LocationName.of(project, location).toString()) - .setCaPoolId(pool_Id) + .setCaPoolId(poolId) .setCaPool( CaPool.newBuilder() .setIssuancePolicy(issuancePolicy) @@ -87,7 +87,7 @@ Set the Tier (see: https://cloud.google.com/certificate-authority-service/docs/t return; } - System.out.println("CA pool created successfully: " + pool_Id); + System.out.println("CA pool created successfully: " + poolId); } } } diff --git a/privateca/snippets/src/main/java/privateca/CreateCertificate.java b/privateca/snippets/src/main/java/privateca/CreateCertificate.java index c686643999e..77089aeac7a 100644 --- a/privateca/snippets/src/main/java/privateca/CreateCertificate.java +++ b/privateca/snippets/src/main/java/privateca/CreateCertificate.java @@ -48,18 +48,18 @@ public static void main(String[] args) // publicKeyBytes: Public key used in signing the certificates. // location: For a list of locations, see: // https://cloud.google.com/certificate-authority-service/docs/locations - // pool_Id: Set a unique id for the CA pool. + // poolId: Set a unique id for the CA pool. // certificateAuthorityName: The name of the certificate authority which issues the certificate. // certificateName: Set a unique name for the certificate. String project = "your-project-id"; ByteString publicKeyBytes = ByteString.copyFrom(new byte[]{}); String location = "ca-location"; - String pool_Id = "ca-pool_Id"; + String poolId = "ca-poolId"; String certificateAuthorityName = "certificate-authority-name"; String certificateName = "certificate-name"; createCertificate( - project, location, pool_Id, certificateAuthorityName, certificateName, publicKeyBytes); + project, location, poolId, certificateAuthorityName, certificateName, publicKeyBytes); } // Create a Certificate which is issued by the Certificate Authority present in the CA Pool. @@ -68,7 +68,7 @@ public static void main(String[] args) public static void createCertificate( String project, String location, - String pool_Id, + String poolId, String certificateAuthorityName, String certificateName, ByteString publicKeyBytes) @@ -134,7 +134,7 @@ public static void createCertificate( // Create the Certificate Request. CreateCertificateRequest certificateRequest = CreateCertificateRequest.newBuilder() - .setParent(CaPoolName.of(project, location, pool_Id).toString()) + .setParent(CaPoolName.of(project, location, poolId).toString()) .setCertificateId(certificateName) .setCertificate(certificate) .setIssuingCertificateAuthorityId(certificateAuthorityName) diff --git a/privateca/snippets/src/main/java/privateca/CreateCertificateAuthority.java b/privateca/snippets/src/main/java/privateca/CreateCertificateAuthority.java index cf88522d0c8..09f486d1a8d 100644 --- a/privateca/snippets/src/main/java/privateca/CreateCertificateAuthority.java +++ b/privateca/snippets/src/main/java/privateca/CreateCertificateAuthority.java @@ -44,18 +44,18 @@ public static void main(String[] args) // TODO(developer): Replace these variables before running the sample. // location: For a list of locations, see: // https://cloud.google.com/certificate-authority-service/docs/locations - // pool_Id: Set it to the CA Pool under which the CA should be created. + // poolId: Set it to the CA Pool under which the CA should be created. // certificateAuthorityName: Unique name for the CA. String project = "your-project-id"; String location = "ca-location"; - String pool_Id = "ca-pool-id"; + String poolId = "ca-pool-id"; String certificateAuthorityName = "certificate-authority-name"; - createCertificateAuthority(project, location, pool_Id, certificateAuthorityName); + createCertificateAuthority(project, location, poolId, certificateAuthorityName); } // Create Certificate Authority which is the root CA in the given CA Pool. public static void createCertificateAuthority( - String project, String location, String pool_Id, String certificateAuthorityName) + String project, String location, String poolId, String certificateAuthorityName) throws InterruptedException, ExecutionException, IOException { // Initialize client that will be used to send requests. This client only needs to be created // once, and can be reused for multiple requests. After completing all of your requests, call @@ -108,7 +108,7 @@ public static void createCertificateAuthority( // Create the CertificateAuthorityRequest. CreateCertificateAuthorityRequest certificateAuthorityRequest = CreateCertificateAuthorityRequest.newBuilder() - .setParent(CaPoolName.of(project, location, pool_Id).toString()) + .setParent(CaPoolName.of(project, location, poolId).toString()) .setCertificateAuthorityId(certificateAuthorityName) .setCertificateAuthority(certificateAuthority) .build(); diff --git a/privateca/snippets/src/main/java/privateca/CreateCertificate_CSR.java b/privateca/snippets/src/main/java/privateca/CreateCertificateCsr.java similarity index 88% rename from privateca/snippets/src/main/java/privateca/CreateCertificate_CSR.java rename to privateca/snippets/src/main/java/privateca/CreateCertificateCsr.java index aa34b9c63de..8d98ac05f2b 100644 --- a/privateca/snippets/src/main/java/privateca/CreateCertificate_CSR.java +++ b/privateca/snippets/src/main/java/privateca/CreateCertificateCsr.java @@ -27,7 +27,7 @@ import java.io.IOException; import java.util.concurrent.ExecutionException; -public class CreateCertificate_CSR { +public class CreateCertificateCsr { public static void main(String[] args) throws IOException, ExecutionException, InterruptedException { @@ -35,33 +35,33 @@ public static void main(String[] args) // location: For a list of locations, see: // https://cloud.google.com/certificate-authority-service/docs/locations - // pool_Id: Set a unique id for the CA pool. + // poolId: Set a unique id for the CA pool. // certificateAuthorityName: The name of the certificate authority to sign the CSR. // certificateName: Set a unique name for the certificate. - // pemCSR: Set the Certificate Issuing Request in the pem encoded format. + // pemCsr: Set the Certificate Issuing Request in the pem encoded format. String project = "your-project-id"; String location = "ca-location"; - String pool_Id = "ca-pool-id"; + String poolId = "ca-pool-id"; String certificateAuthorityName = "certificate-authority-name"; String certificateName = "certificate-name"; - String pemCSR = + String pemCsr = "-----BEGIN CERTIFICATE REQUEST-----\n" + "sample-pem-csr-format\n" + "-----END CERTIFICATE REQUEST-----"; - createCertificateWithCSR( - project, location, pool_Id, certificateAuthorityName, certificateName, pemCSR); + createCertificateWithCsr( + project, location, poolId, certificateAuthorityName, certificateName, pemCsr); } // Create a Certificate which is issued by the specified Certificate Authority. // The certificate details and the public key is provided as a CSR (Certificate Signing Request). - public static void createCertificateWithCSR( + public static void createCertificateWithCsr( String project, String location, - String pool_Id, + String poolId, String certificateAuthorityName, String certificateName, - String pemCSR) + String pemCsr) throws IOException, ExecutionException, InterruptedException { // Initialize client that will be used to send requests. This client only needs to be created // once, and can be reused for multiple requests. After completing all of your requests, call @@ -76,7 +76,7 @@ public static void createCertificateWithCSR( // The pemCSR contains the public key and the domain details required. Certificate certificate = Certificate.newBuilder() - .setPemCsr(pemCSR) + .setPemCsr(pemCsr) .setLifetime(Duration.newBuilder().setSeconds(certificateLifetime).build()) .build(); @@ -84,7 +84,7 @@ public static void createCertificateWithCSR( // Set the CA which is responsible for creating the certificate with the provided CSR. CreateCertificateRequest certificateRequest = CreateCertificateRequest.newBuilder() - .setParent(CaPoolName.of(project, location, pool_Id).toString()) + .setParent(CaPoolName.of(project, location, poolId).toString()) .setIssuingCertificateAuthorityId(certificateAuthorityName) .setCertificateId(certificateName) .setCertificate(certificate) diff --git a/privateca/snippets/src/main/java/privateca/CreateSubordinateCa.java b/privateca/snippets/src/main/java/privateca/CreateSubordinateCa.java index 2c52f376993..cde09b7efb6 100644 --- a/privateca/snippets/src/main/java/privateca/CreateSubordinateCa.java +++ b/privateca/snippets/src/main/java/privateca/CreateSubordinateCa.java @@ -45,18 +45,18 @@ public static void main(String[] args) // TODO(developer): Replace these variables before running the sample. // location: For a list of locations, see: // https://cloud.google.com/certificate-authority-service/docs/locations - // pool_Id: Set it to the CA Pool under which the CA should be created. + // poolId: Set it to the CA Pool under which the CA should be created. // subordinateCaName: Unique name for the Subordinate CA. String project = "your-project-id"; String location = "ca-location"; - String pool_Id = "ca-pool-id"; + String poolId = "ca-pool-id"; String subordinateCaName = "subordinate-certificate-authority-name"; - createSubordinateCertificateAuthority(project, location, pool_Id, subordinateCaName); + createSubordinateCertificateAuthority(project, location, poolId, subordinateCaName); } public static void createSubordinateCertificateAuthority( - String project, String location, String pool_Id, String subordinateCaName) + String project, String location, String poolId, String subordinateCaName) throws IOException, ExecutionException, InterruptedException { // Initialize client that will be used to send requests. This client only needs to be created // once, and can be reused for multiple requests. After completing all of your requests, call @@ -111,7 +111,7 @@ public static void createSubordinateCertificateAuthority( // Create the CertificateAuthorityRequest. CreateCertificateAuthorityRequest subCertificateAuthorityRequest = CreateCertificateAuthorityRequest.newBuilder() - .setParent(CaPoolName.of(project, location, pool_Id).toString()) + .setParent(CaPoolName.of(project, location, poolId).toString()) .setCertificateAuthorityId(subordinateCaName) .setCertificateAuthority(subCertificateAuthority) .build(); diff --git a/privateca/snippets/src/main/java/privateca/DeleteCaPool.java b/privateca/snippets/src/main/java/privateca/DeleteCaPool.java index eabe2a56526..1745469136c 100644 --- a/privateca/snippets/src/main/java/privateca/DeleteCaPool.java +++ b/privateca/snippets/src/main/java/privateca/DeleteCaPool.java @@ -34,16 +34,16 @@ public static void main(String[] args) // TODO(developer): Replace these variables before running the sample. // location: For a list of locations, see: // https://cloud.google.com/certificate-authority-service/docs/locations - // pool_Id: The id of the CA pool to be deleted. + // poolId: The id of the CA pool to be deleted. String project = "your-project-id"; String location = "ca-location"; - String pool_Id = "ca-pool-id"; - deleteCaPool(project, location, pool_Id); + String poolId = "ca-pool-id"; + deleteCaPool(project, location, poolId); } - // Delete the CA pool as mentioned by the pool_Id. + // Delete the CA pool as mentioned by the poolId. // Before deleting the pool, all CAs in the pool MUST BE deleted. - public static void deleteCaPool(String project, String location, String pool_Id) + public static void deleteCaPool(String project, String location, String poolId) throws InterruptedException, ExecutionException, IOException { // Initialize client that will be used to send requests. This client only needs to be created // once, and can be reused for multiple requests. After completing all of your requests, call @@ -52,12 +52,12 @@ public static void deleteCaPool(String project, String location, String pool_Id) try (CertificateAuthorityServiceClient certificateAuthorityServiceClient = CertificateAuthorityServiceClient.create()) { - // Set the project, location and pool_Id to delete. + // Set the project, location and poolId to delete. CaPoolName caPool = CaPoolName.newBuilder() .setProject(project) .setLocation(location) - .setCaPool(pool_Id) + .setCaPool(poolId) .build(); // Create the Delete request. @@ -74,7 +74,7 @@ public static void deleteCaPool(String project, String location, String pool_Id) return; } - System.out.println("Deleted CA Pool: " + pool_Id); + System.out.println("Deleted CA Pool: " + poolId); } } } diff --git a/privateca/snippets/src/main/java/privateca/DeleteCertificateAuthority.java b/privateca/snippets/src/main/java/privateca/DeleteCertificateAuthority.java index e8127017061..0f8051806af 100644 --- a/privateca/snippets/src/main/java/privateca/DeleteCertificateAuthority.java +++ b/privateca/snippets/src/main/java/privateca/DeleteCertificateAuthority.java @@ -34,19 +34,19 @@ public static void main(String[] args) // TODO(developer): Replace these variables before running the sample. // location: For a list of locations, see: // https://cloud.google.com/certificate-authority-service/docs/locations - // pool_Id: The id of the CA pool under which the CA is present. + // poolId: The id of the CA pool under which the CA is present. // certificateAuthorityName: The name of the CA to be deleted. String project = "your-project-id"; String location = "ca-location"; - String pool_Id = "ca-pool-id"; + String poolId = "ca-pool-id"; String certificateAuthorityName = "certificate-authority-name"; - deleteCertificateAuthority(project, location, pool_Id, certificateAuthorityName); + deleteCertificateAuthority(project, location, poolId, certificateAuthorityName); } // Delete the Certificate Authority from the specified CA pool. // Before deletion, the CA must be disabled and must not contain any active certificates. public static void deleteCertificateAuthority( - String project, String location, String pool_Id, String certificateAuthorityName) + String project, String location, String poolId, String certificateAuthorityName) throws IOException, ExecutionException, InterruptedException { // Initialize client that will be used to send requests. This client only needs to be created // once, and can be reused for multiple requests. After completing all of your requests, call @@ -59,7 +59,7 @@ public static void deleteCertificateAuthority( CertificateAuthorityName.newBuilder() .setProject(project) .setLocation(location) - .setCaPool(pool_Id) + .setCaPool(poolId) .setCertificateAuthority(certificateAuthorityName) .build(); diff --git a/privateca/snippets/src/main/java/privateca/DisableCertificateAuthority.java b/privateca/snippets/src/main/java/privateca/DisableCertificateAuthority.java index cd96b6d2783..663287d2c26 100644 --- a/privateca/snippets/src/main/java/privateca/DisableCertificateAuthority.java +++ b/privateca/snippets/src/main/java/privateca/DisableCertificateAuthority.java @@ -34,18 +34,18 @@ public static void main(String[] args) // TODO(developer): Replace these variables before running the sample. // location: For a list of locations, see: // https://cloud.google.com/certificate-authority-service/docs/locations - // pool_Id: The id of the CA pool under which the CA is present. + // poolId: The id of the CA pool under which the CA is present. // certificateAuthorityName: The name of the CA to be disabled. String project = "your-project-id"; String location = "ca-location"; - String pool_Id = "ca-pool-id"; + String poolId = "ca-pool-id"; String certificateAuthorityName = "certificate-authority-name"; - disableCertificateAuthority(project, location, pool_Id, certificateAuthorityName); + disableCertificateAuthority(project, location, poolId, certificateAuthorityName); } // Disable a Certificate Authority which is present in the given CA pool. public static void disableCertificateAuthority( - String project, String location, String pool_Id, String certificateAuthorityName) + String project, String location, String poolId, String certificateAuthorityName) throws IOException, ExecutionException, InterruptedException { // Initialize client that will be used to send requests. This client only needs to be created // once, and can be reused for multiple requests. After completing all of your requests, call @@ -59,7 +59,7 @@ public static void disableCertificateAuthority( CertificateAuthorityName.newBuilder() .setProject(project) .setLocation(location) - .setCaPool(pool_Id) + .setCaPool(poolId) .setCertificateAuthority(certificateAuthorityName) .build(); diff --git a/privateca/snippets/src/main/java/privateca/EnableCertificateAuthority.java b/privateca/snippets/src/main/java/privateca/EnableCertificateAuthority.java index d3f2fc0ebd3..c25156d31ba 100644 --- a/privateca/snippets/src/main/java/privateca/EnableCertificateAuthority.java +++ b/privateca/snippets/src/main/java/privateca/EnableCertificateAuthority.java @@ -34,19 +34,19 @@ public static void main(String[] args) // TODO(developer): Replace these variables before running the sample. // location: For a list of locations, see: // https://cloud.google.com/certificate-authority-service/docs/locations - // pool_Id: The id of the CA pool under which the CA is present. + // poolId: The id of the CA pool under which the CA is present. // certificateAuthorityName: The name of the CA to be enabled. String project = "your-project-id"; String location = "ca-location"; - String pool_Id = "ca-pool-id"; + String poolId = "ca-pool-id"; String certificateAuthorityName = "certificate-authority-name"; - enableCertificateAuthority(project, location, pool_Id, certificateAuthorityName); + enableCertificateAuthority(project, location, poolId, certificateAuthorityName); } // Enable the Certificate Authority present in the given ca pool. // CA cannot be enabled if it has been already deleted. public static void enableCertificateAuthority( - String project, String location, String pool_Id, String certificateAuthorityName) + String project, String location, String poolId, String certificateAuthorityName) throws IOException, ExecutionException, InterruptedException { try (CertificateAuthorityServiceClient certificateAuthorityServiceClient = CertificateAuthorityServiceClient.create()) { @@ -55,7 +55,7 @@ public static void enableCertificateAuthority( CertificateAuthorityName.newBuilder() .setProject(project) .setLocation(location) - .setCaPool(pool_Id) + .setCaPool(poolId) .setCertificateAuthority(certificateAuthorityName) .build(); diff --git a/privateca/snippets/src/main/java/privateca/FilterCertificates.java b/privateca/snippets/src/main/java/privateca/FilterCertificates.java index b59e4ab7a86..de770aa8172 100644 --- a/privateca/snippets/src/main/java/privateca/FilterCertificates.java +++ b/privateca/snippets/src/main/java/privateca/FilterCertificates.java @@ -30,16 +30,16 @@ public static void main(String[] args) throws IOException { // TODO(developer): Replace these variables before running the sample. // location: For a list of locations, see: // https://cloud.google.com/certificate-authority-service/docs/locations - // pool_Id: Id of the CA pool which contains the certificates to be listed. + // poolId: Id of the CA pool which contains the certificates to be listed. String project = "your-project-id"; String location = "ca-location"; - String pool_Id = "ca-pool-id"; + String poolId = "ca-pool-id"; - filterCertificates(project, location, pool_Id); + filterCertificates(project, location, poolId); } // Filter certificates based on a condition and list them. - public static void filterCertificates(String project, String location, String pool_Id) + public static void filterCertificates(String project, String location, String poolId) throws IOException { // Initialize client that will be used to send requests. This client only needs to be created // once, and can be reused for multiple requests. After completing all of your requests, call @@ -52,7 +52,7 @@ public static void filterCertificates(String project, String location, String po CaPoolName.newBuilder() .setProject(project) .setLocation(location) - .setCaPool(pool_Id) + .setCaPool(poolId) .build(); // Create the certificate request and set the filter condition. @@ -64,7 +64,8 @@ public static void filterCertificates(String project, String location, String po see: https://cloud.google.com/certificate-authority-service/docs/sorting-filtering-certificates#filtering_support Few examples for constructing conditions: - certificate_description.subject_description.not_after_time=timestamp(com.google.protobuf) + certificate_description.subject_description.not_after_time= + timestamp(com.google.protobuf) certificate_description.subject_description.subject_alt_name.dns_names:my-dns Here, we are filtering certificates which has organization name = csr-org-name */ .setFilter( diff --git a/privateca/snippets/src/main/java/privateca/ListCertificateAuthorities.java b/privateca/snippets/src/main/java/privateca/ListCertificateAuthorities.java index 47fa03d0f25..a33f5345764 100644 --- a/privateca/snippets/src/main/java/privateca/ListCertificateAuthorities.java +++ b/privateca/snippets/src/main/java/privateca/ListCertificateAuthorities.java @@ -29,15 +29,15 @@ public static void main(String[] args) throws IOException { // TODO(developer): Replace these variables before running the sample. // location: For a list of locations, see: // https://cloud.google.com/certificate-authority-service/docs/locations - // pool_Id: The id of the CA pool under which the CAs to be listed are present. + // poolId: The id of the CA pool under which the CAs to be listed are present. String project = "your-project-id"; String location = "ca-location"; - String pool_Id = "ca-pool-id"; - listCertificateAuthority(project, location, pool_Id); + String poolId = "ca-pool-id"; + listCertificateAuthority(project, location, poolId); } // List all Certificate authorities present in the given CA Pool. - public static void listCertificateAuthority(String project, String location, String pool_Id) + public static void listCertificateAuthority(String project, String location, String poolId) throws IOException { // Initialize client that will be used to send requests. This client only needs to be created // once, and can be reused for multiple requests. After completing all of your requests, call @@ -51,7 +51,7 @@ public static void listCertificateAuthority(String project, String location, Str CaPoolName.newBuilder() .setProject(project) .setLocation(location) - .setCaPool(pool_Id) + .setCaPool(poolId) .build(); // List the CA name and its corresponding state. diff --git a/privateca/snippets/src/main/java/privateca/ListCertificates.java b/privateca/snippets/src/main/java/privateca/ListCertificates.java index 7f747457b50..ef1646b8d75 100644 --- a/privateca/snippets/src/main/java/privateca/ListCertificates.java +++ b/privateca/snippets/src/main/java/privateca/ListCertificates.java @@ -29,15 +29,15 @@ public static void main(String[] args) throws IOException { // TODO(developer): Replace these variables before running the sample. // location: For a list of locations, see: // https://cloud.google.com/certificate-authority-service/docs/locations - // pool_Id: Id of the CA pool which contains the certificates to be listed. + // poolId: Id of the CA pool which contains the certificates to be listed. String project = "your-project-id"; String location = "ca-location"; - String pool_Id = "ca-pool-id"; - listCertificates(project, location, pool_Id); + String poolId = "ca-pool-id"; + listCertificates(project, location, poolId); } // List Certificates present in the given CA pool. - public static void listCertificates(String project, String location, String pool_Id) + public static void listCertificates(String project, String location, String poolId) throws IOException { // Initialize client that will be used to send requests. This client only needs to be created // once, and can be reused for multiple requests. After completing all of your requests, call @@ -50,7 +50,7 @@ public static void listCertificates(String project, String location, String pool CaPoolName.newBuilder() .setProject(project) .setLocation(location) - .setCaPool(pool_Id) + .setCaPool(poolId) .build(); // Retrieve and print the certificate names. diff --git a/privateca/snippets/src/main/java/privateca/RevokeCertificate.java b/privateca/snippets/src/main/java/privateca/RevokeCertificate.java index b3d3b24fc3e..1c6a10dc273 100644 --- a/privateca/snippets/src/main/java/privateca/RevokeCertificate.java +++ b/privateca/snippets/src/main/java/privateca/RevokeCertificate.java @@ -34,19 +34,19 @@ public static void main(String[] args) // TODO(developer): Replace these variables before running the sample. // location: For a list of locations, see: // https://cloud.google.com/certificate-authority-service/docs/locations - // pool_Id: Id for the CA pool which contains the certificate. + // poolId: Id for the CA pool which contains the certificate. // certificateName: Name of the certificate to be revoked. String project = "your-project-id"; String location = "ca-location"; - String pool_Id = "ca-pool-id"; + String poolId = "ca-pool-id"; String certificateName = "certificate-name"; - revokeCertificate(project, location, pool_Id, certificateName); + revokeCertificate(project, location, poolId, certificateName); } // Revoke an issued certificate. Once revoked, the certificate will become invalid and will expire // post its lifetime. public static void revokeCertificate( - String project, String location, String pool_Id, String certificateName) + String project, String location, String poolId, String certificateName) throws IOException, ExecutionException, InterruptedException { // Initialize client that will be used to send requests. This client only needs to be created // once, and can be reused for multiple requests. After completing all of your requests, call @@ -60,7 +60,7 @@ public static void revokeCertificate( CertificateName.newBuilder() .setProject(project) .setLocation(location) - .setCaPool(pool_Id) + .setCaPool(poolId) .setCertificate(certificateName) .build(); diff --git a/privateca/snippets/src/main/java/privateca/UndeleteCertificateAuthority.java b/privateca/snippets/src/main/java/privateca/UndeleteCertificateAuthority.java index f1e56eeb6b3..ba83f568ee9 100644 --- a/privateca/snippets/src/main/java/privateca/UndeleteCertificateAuthority.java +++ b/privateca/snippets/src/main/java/privateca/UndeleteCertificateAuthority.java @@ -36,19 +36,19 @@ public static void main(String[] args) // TODO(developer): Replace these variables before running the sample. // location: For a list of locations, see: // https://cloud.google.com/certificate-authority-service/docs/locations - // pool_Id: The id of the CA pool under which the deleted CA is present. + // poolId: The id of the CA pool under which the deleted CA is present. // certificateAuthorityName: The name of the CA to be restored (undeleted). String project = "your-project-id"; String location = "ca-location"; - String pool_Id = "ca-pool-id"; + String poolId = "ca-pool-id"; String certificateAuthorityName = "certificate-authority-name"; - undeleteCertificateAuthority(project, location, pool_Id, certificateAuthorityName); + undeleteCertificateAuthority(project, location, poolId, certificateAuthorityName); } // Restore a deleted CA, if still within the grace period of 30 days. public static void undeleteCertificateAuthority( - String project, String location, String pool_Id, String certificateAuthorityName) + String project, String location, String poolId, String certificateAuthorityName) throws IOException, ExecutionException, InterruptedException, TimeoutException { // Initialize client that will be used to send requests. This client only needs to be created // once, and can be reused for multiple requests. After completing all of your requests, call @@ -58,7 +58,7 @@ public static void undeleteCertificateAuthority( CertificateAuthorityServiceClient.create()) { String certificateAuthorityParent = - CertificateAuthorityName.of(project, location, pool_Id, certificateAuthorityName) + CertificateAuthorityName.of(project, location, poolId, certificateAuthorityName) .toString(); // Confirm if the CA is in DELETED stage. diff --git a/privateca/snippets/src/main/java/privateca/UpdateCaPool_IssuancePolicy.java b/privateca/snippets/src/main/java/privateca/UpdateCaPoolIssuancePolicy.java similarity index 92% rename from privateca/snippets/src/main/java/privateca/UpdateCaPool_IssuancePolicy.java rename to privateca/snippets/src/main/java/privateca/UpdateCaPoolIssuancePolicy.java index c2630dc8b09..86f20669f38 100644 --- a/privateca/snippets/src/main/java/privateca/UpdateCaPool_IssuancePolicy.java +++ b/privateca/snippets/src/main/java/privateca/UpdateCaPoolIssuancePolicy.java @@ -33,24 +33,24 @@ import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeoutException; -public class UpdateCaPool_IssuancePolicy { +public class UpdateCaPoolIssuancePolicy { public static void main(String[] args) throws IOException, ExecutionException, InterruptedException, TimeoutException { // TODO(developer): Replace these variables before running the sample. // location: For a list of locations, see: // https://cloud.google.com/certificate-authority-service/docs/locations - // pool_Id: The CA pool for which the issuance policy is to be updated. + // poolId: The CA pool for which the issuance policy is to be updated. String project = "your-project-id"; String location = "ca-location"; - String pool_Id = "ca-pool-id"; + String poolId = "ca-pool-id"; - updateCaPoolIssuancePolicy(project, location, pool_Id); + updateCaPoolIssuancePolicy(project, location, poolId); } /* Update the Issuance policy for a CA Pool. All certificates issued from this CA Pool should meet the issuance policy. */ - public static void updateCaPoolIssuancePolicy(String project, String location, String pool_Id) + public static void updateCaPoolIssuancePolicy(String project, String location, String poolId) throws IOException, ExecutionException, InterruptedException, TimeoutException { /* Initialize client that will be used to send requests. This client only needs to be created once, and can be reused for multiple requests. After completing all of your requests, call @@ -78,7 +78,7 @@ public static void updateCaPoolIssuancePolicy(String project, String location, S CaPool caPool = CaPool.newBuilder() - .setName(CaPoolName.of(project, location, pool_Id).toString()) + .setName(CaPoolName.of(project, location, poolId).toString()) .setIssuancePolicy(issuancePolicy) .build(); @@ -97,7 +97,8 @@ public static void updateCaPoolIssuancePolicy(String project, String location, S .addPaths( "issuance_policy.identity_constraints.allow_subject_passthrough") .addPaths( - "issuance_policy.identity_constraints.allow_subject_alt_names_passthrough") + "issuance_policy.identity_constraints." + + "allow_subject_alt_names_passthrough") .addPaths("issuance_policy.identity_constraints.cel_expression") .build())) .build(); @@ -117,7 +118,7 @@ public static void updateCaPoolIssuancePolicy(String project, String location, S // Get the CA Pool's issuance policy and verify if the fields have been successfully updated. IssuancePolicy response = certificateAuthorityServiceClient - .getCaPool(CaPoolName.of(project, location, pool_Id).toString()) + .getCaPool(CaPoolName.of(project, location, poolId).toString()) .getIssuancePolicy(); // Similarly, you can check for other modified fields as well. diff --git a/privateca/snippets/src/main/java/privateca/UpdateCertificateAuthority.java b/privateca/snippets/src/main/java/privateca/UpdateCertificateAuthority.java index a6639b6cdee..4c0868f793f 100644 --- a/privateca/snippets/src/main/java/privateca/UpdateCertificateAuthority.java +++ b/privateca/snippets/src/main/java/privateca/UpdateCertificateAuthority.java @@ -37,19 +37,19 @@ public static void main(String[] args) // TODO(developer): Replace these variables before running the sample. // location: For a list of locations, see: // https://cloud.google.com/certificate-authority-service/docs/locations - // pool_Id: Set it to the CA Pool under which the CA should be created. + // poolId: Set it to the CA Pool under which the CA should be created. // certificateAuthorityName: Unique name for the CA. String project = "your-project-id"; String location = "ca-location"; - String pool_Id = "ca-pool-id"; + String poolId = "ca-pool-id"; String certificateAuthorityName = "certificate-authority-name"; - updateCaLabel(project, location, pool_Id, certificateAuthorityName); + updateCaLabel(project, location, poolId, certificateAuthorityName); } // Updates the labels in a certificate authority. public static void updateCaLabel( - String project, String location, String pool_Id, String certificateAuthorityName) + String project, String location, String poolId, String certificateAuthorityName) throws IOException, ExecutionException, InterruptedException, TimeoutException { /* Initialize client that will be used to send requests. This client only needs to be created once, and can be reused for multiple requests. After completing all of your requests, call @@ -60,7 +60,7 @@ public static void updateCaLabel( // Set the parent path and the new labels. String certificateAuthorityParent = - CertificateAuthorityName.of(project, location, pool_Id, certificateAuthorityName) + CertificateAuthorityName.of(project, location, poolId, certificateAuthorityName) .toString(); CertificateAuthority certificateAuthority = CertificateAuthority.newBuilder() diff --git a/privateca/snippets/src/test/java/privateca/SnippetsIT.java b/privateca/snippets/src/test/java/privateca/SnippetsIT.java index ab15bb5299b..446974f6350 100644 --- a/privateca/snippets/src/test/java/privateca/SnippetsIT.java +++ b/privateca/snippets/src/test/java/privateca/SnippetsIT.java @@ -61,8 +61,8 @@ public class SnippetsIT { private static final String PROJECT_ID = System.getenv("GOOGLE_CLOUD_PROJECT"); private static String LOCATION; - private static String CA_POOL_ID; - private static String CA_POOL_ID_DELETE; + private static String CA_poolId; + private static String CA_poolId_DELETE; private static String CA_NAME; private static String CA_NAME_DELETE; private static String SUBORDINATE_CA_NAME; @@ -88,8 +88,8 @@ public static void setUp() reqEnvVar("GOOGLE_CLOUD_PROJECT"); LOCATION = "asia-south1"; - CA_POOL_ID = "ca-pool-" + UUID.randomUUID(); - CA_POOL_ID_DELETE = "ca-pool-" + UUID.randomUUID(); + CA_poolId = "ca-pool-" + UUID.randomUUID(); + CA_poolId_DELETE = "ca-pool-" + UUID.randomUUID(); CA_NAME = "ca-name-" + UUID.randomUUID(); CA_NAME_DELETE = "ca-name-" + UUID.randomUUID(); SUBORDINATE_CA_NAME = "sub-ca-name-" + UUID.randomUUID(); @@ -100,41 +100,41 @@ public static void setUp() // <--- START CA POOL ---> // Create CA Pool. - privateca.CreateCaPool.createCaPool(PROJECT_ID, LOCATION, CA_POOL_ID); - privateca.CreateCaPool.createCaPool(PROJECT_ID, LOCATION, CA_POOL_ID_DELETE); + privateca.CreateCaPool.createCaPool(PROJECT_ID, LOCATION, CA_poolId); + privateca.CreateCaPool.createCaPool(PROJECT_ID, LOCATION, CA_poolId_DELETE); sleep(5); // Set the issuance policy for the created CA Pool. - privateca.UpdateCaPool_IssuancePolicy.updateCaPoolIssuancePolicy( - PROJECT_ID, LOCATION, CA_POOL_ID); + UpdateCaPoolIssuancePolicy.updateCaPoolIssuancePolicy( + PROJECT_ID, LOCATION, CA_poolId); // <--- END CA POOL ---> // <--- START ROOT CA ---> // Create and Enable Certificate Authority. privateca.CreateCertificateAuthority.createCertificateAuthority( - PROJECT_ID, LOCATION, CA_POOL_ID, CA_NAME); + PROJECT_ID, LOCATION, CA_poolId, CA_NAME); sleep(10); privateca.EnableCertificateAuthority.enableCertificateAuthority( - PROJECT_ID, LOCATION, CA_POOL_ID, CA_NAME); + PROJECT_ID, LOCATION, CA_poolId, CA_NAME); // Create and Delete Certificate Authority. privateca.CreateCertificateAuthority.createCertificateAuthority( - PROJECT_ID, LOCATION, CA_POOL_ID, CA_NAME_DELETE); + PROJECT_ID, LOCATION, CA_poolId, CA_NAME_DELETE); sleep(10); privateca.DeleteCertificateAuthority.deleteCertificateAuthority( - PROJECT_ID, LOCATION, CA_POOL_ID, CA_NAME_DELETE); + PROJECT_ID, LOCATION, CA_poolId, CA_NAME_DELETE); // <--- END ROOT CA ---> // <--- START SUBORDINATE CA ---> // Follow the below steps to create and enable a Subordinate Certificate Authority. // 1. Create a Subordinate Certificate Authority. privateca.CreateSubordinateCa.createSubordinateCertificateAuthority( - PROJECT_ID, LOCATION, CA_POOL_ID, SUBORDINATE_CA_NAME); + PROJECT_ID, LOCATION, CA_poolId, SUBORDINATE_CA_NAME); sleep(10); // 2. Fetch CSR. - String pemCSR = fetchPemCSR(CA_POOL_ID, SUBORDINATE_CA_NAME); + String pemCsr = fetchPemCSR(CA_poolId, SUBORDINATE_CA_NAME); // 3. Sign the CSR, and create a certificate. - privateca.CreateCertificate_CSR.createCertificateWithCSR( - PROJECT_ID, LOCATION, CA_POOL_ID, CA_NAME, CSR_CERTIFICATE_NAME, pemCSR); + CreateCertificateCsr.createCertificateWithCsr( + PROJECT_ID, LOCATION, CA_poolId, CA_NAME, CSR_CERTIFICATE_NAME, pemCsr); // <--- END SUBORDINATE CA ---> // <--- START CERTIFICATE ---> @@ -162,7 +162,7 @@ public static void setUp() // Create certificate with the above generated public key. privateca.CreateCertificate.createCertificate( - PROJECT_ID, LOCATION, CA_POOL_ID, CA_NAME, CERTIFICATE_NAME, publicKeyByteString); + PROJECT_ID, LOCATION, CA_poolId, CA_NAME, CERTIFICATE_NAME, publicKeyByteString); sleep(5); // <--- END CERTIFICATE ---> } @@ -176,7 +176,7 @@ public static void cleanUp() // Revoke Certificate. privateca.RevokeCertificate.revokeCertificate( - PROJECT_ID, LOCATION, CA_POOL_ID, CSR_CERTIFICATE_NAME); + PROJECT_ID, LOCATION, CA_poolId, CSR_CERTIFICATE_NAME); // Delete Certificate Template. privateca.DeleteCertificateTemplate.deleteCertificateTemplate( @@ -184,18 +184,18 @@ public static void cleanUp() // Delete root CA. privateca.DeleteCertificateAuthority.deleteCertificateAuthority( - PROJECT_ID, LOCATION, CA_POOL_ID, CA_NAME); + PROJECT_ID, LOCATION, CA_poolId, CA_NAME); sleep(5); // Deleting the undeleted CA. privateca.DeleteCertificateAuthority.deleteCertificateAuthority( - PROJECT_ID, LOCATION, CA_POOL_ID, CA_NAME_DELETE); + PROJECT_ID, LOCATION, CA_poolId, CA_NAME_DELETE); // Delete Subordinate CA. privateca.DeleteCertificateAuthority.deleteCertificateAuthority( - PROJECT_ID, LOCATION, CA_POOL_ID, SUBORDINATE_CA_NAME); + PROJECT_ID, LOCATION, CA_poolId, SUBORDINATE_CA_NAME); sleep(5); // Delete CA Pool. - privateca.DeleteCaPool.deleteCaPool(PROJECT_ID, LOCATION, CA_POOL_ID); + privateca.DeleteCaPool.deleteCaPool(PROJECT_ID, LOCATION, CA_poolId); stdOut = null; System.setOut(null); @@ -207,11 +207,11 @@ public static void sleep(int seconds) throws InterruptedException { } // Fetch CSR of the given CA. - public static String fetchPemCSR(String pool_Id, String caName) throws IOException { + public static String fetchPemCSR(String poolId, String caName) throws IOException { try (CertificateAuthorityServiceClient certificateAuthorityServiceClient = CertificateAuthorityServiceClient.create()) { String caParent = - CertificateAuthorityName.of(PROJECT_ID, LOCATION, pool_Id, caName).toString(); + CertificateAuthorityName.of(PROJECT_ID, LOCATION, poolId, caName).toString(); FetchCertificateAuthorityCsrResponse response = certificateAuthorityServiceClient.fetchCertificateAuthorityCsr(caParent); @@ -264,12 +264,12 @@ public void testCreateCAPool() throws IOException { CertificateAuthorityServiceClient.create()) { String caPoolName = certificateAuthorityServiceClient - .getCaPool(CaPoolName.of(PROJECT_ID, LOCATION, CA_POOL_ID).toString()) + .getCaPool(CaPoolName.of(PROJECT_ID, LOCATION, CA_poolId).toString()) .getName(); assertThat(caPoolName) .contains( String.format( - "projects/%s/locations/%s/caPools/%s", PROJECT_ID, LOCATION, CA_POOL_ID)); + "projects/%s/locations/%s/caPools/%s", PROJECT_ID, LOCATION, CA_poolId)); } } @@ -279,7 +279,7 @@ public void testUpdateCAPoolIssuancePolicy() throws IOException { CertificateAuthorityServiceClient.create()) { IssuancePolicy issuancePolicy = certificateAuthorityServiceClient - .getCaPool(CaPoolName.of(PROJECT_ID, LOCATION, CA_POOL_ID).toString()) + .getCaPool(CaPoolName.of(PROJECT_ID, LOCATION, CA_poolId).toString()) .getIssuancePolicy(); String actualExpression = @@ -294,14 +294,14 @@ public void testUpdateCAPoolIssuancePolicy() throws IOException { @Test public void testListCAPools() throws IOException { privateca.ListCaPools.listCaPools(PROJECT_ID, LOCATION); - assertThat(stdOut.toString()).contains(CA_POOL_ID); + assertThat(stdOut.toString()).contains(CA_poolId); } @Test public void testDeleteCAPool() throws InterruptedException, ExecutionException, IOException, TimeoutException { - privateca.DeleteCaPool.deleteCaPool(PROJECT_ID, LOCATION, CA_POOL_ID_DELETE); - assertThat(stdOut.toString()).contains("Deleted CA Pool: " + CA_POOL_ID_DELETE); + privateca.DeleteCaPool.deleteCaPool(PROJECT_ID, LOCATION, CA_poolId_DELETE); + assertThat(stdOut.toString()).contains("Deleted CA Pool: " + CA_poolId_DELETE); } @Test @@ -311,21 +311,21 @@ public void testCreateCertificateAuthority() throws IOException { CertificateAuthorityServiceClient.create()) { CertificateAuthority response = certificateAuthorityServiceClient.getCertificateAuthority( - CertificateAuthorityName.of(PROJECT_ID, LOCATION, CA_POOL_ID, CA_NAME).toString()); + CertificateAuthorityName.of(PROJECT_ID, LOCATION, CA_poolId, CA_NAME).toString()); assertThat(response.getName()).contains(CA_NAME); } } @Test public void testListCertificateAuthorities() throws IOException { - privateca.ListCertificateAuthorities.listCertificateAuthority(PROJECT_ID, LOCATION, CA_POOL_ID); + privateca.ListCertificateAuthorities.listCertificateAuthority(PROJECT_ID, LOCATION, CA_poolId); assertThat(stdOut.toString()).contains(CA_NAME); } @Test public void testUpdateCertificateAuthority() throws IOException, ExecutionException, InterruptedException, TimeoutException { - privateca.UpdateCertificateAuthority.updateCaLabel(PROJECT_ID, LOCATION, CA_POOL_ID, CA_NAME); + privateca.UpdateCertificateAuthority.updateCaLabel(PROJECT_ID, LOCATION, CA_poolId, CA_NAME); assertThat(stdOut.toString()).contains("Successfully updated the labels ! "); } @@ -339,10 +339,10 @@ public void testMonitorCertificateAuthority() throws IOException, InterruptedExc public void testEnableDisableCertificateAuthority() throws InterruptedException, ExecutionException, IOException { privateca.EnableCertificateAuthority.enableCertificateAuthority( - PROJECT_ID, LOCATION, CA_POOL_ID, CA_NAME); + PROJECT_ID, LOCATION, CA_poolId, CA_NAME); assertThat(stdOut.toString()).contains("Enabled Certificate Authority : " + CA_NAME); privateca.DisableCertificateAuthority.disableCertificateAuthority( - PROJECT_ID, LOCATION, CA_POOL_ID, CA_NAME); + PROJECT_ID, LOCATION, CA_poolId, CA_NAME); assertThat(stdOut.toString()).contains("Disabled Certificate Authority : " + CA_NAME); } @@ -352,7 +352,7 @@ public void testDeleteUndeleteCertificateAuthority() // CA deleted as part of setup(). Undelete the CA. // The undelete operation will be executed only if the CA was successfully deleted. privateca.UndeleteCertificateAuthority.undeleteCertificateAuthority( - PROJECT_ID, LOCATION, CA_POOL_ID, CA_NAME_DELETE); + PROJECT_ID, LOCATION, CA_poolId, CA_NAME_DELETE); assertThat(stdOut.toString()) .contains("Successfully restored the Certificate Authority ! " + CA_NAME_DELETE); } @@ -395,7 +395,7 @@ public void testCreateCertificate() throws IOException { try (CertificateAuthorityServiceClient certificateAuthorityServiceClient = CertificateAuthorityServiceClient.create()) { CertificateName certificateName = - CertificateName.of(PROJECT_ID, LOCATION, CA_POOL_ID, CERTIFICATE_NAME); + CertificateName.of(PROJECT_ID, LOCATION, CA_poolId, CERTIFICATE_NAME); Certificate certificate = certificateAuthorityServiceClient.getCertificate(certificateName); assertThat(certificate.getName()).contains(CERTIFICATE_NAME); } @@ -403,14 +403,14 @@ public void testCreateCertificate() throws IOException { @Test public void testListCertificates() throws IOException { - privateca.ListCertificates.listCertificates(PROJECT_ID, LOCATION, CA_POOL_ID); + privateca.ListCertificates.listCertificates(PROJECT_ID, LOCATION, CA_poolId); assertThat(stdOut.toString()).contains(CERTIFICATE_NAME); } @Test public void testFilterCertificates() throws IOException { // Filter only certificates created using CSR. - privateca.FilterCertificates.filterCertificates(PROJECT_ID, LOCATION, CA_POOL_ID); + privateca.FilterCertificates.filterCertificates(PROJECT_ID, LOCATION, CA_poolId); assertThat(stdOut.toString()).contains(CSR_CERTIFICATE_NAME); assertThat(stdOut.toString()).doesNotContain(CERTIFICATE_NAME); } @@ -421,12 +421,12 @@ public void testRevokeCertificate() throws InterruptedException, ExecutionExcept CertificateAuthorityServiceClient.create()) { // Revoke the certificate. privateca.RevokeCertificate.revokeCertificate( - PROJECT_ID, LOCATION, CA_POOL_ID, CERTIFICATE_NAME); + PROJECT_ID, LOCATION, CA_poolId, CERTIFICATE_NAME); // Check if the certificate has revocation details. If it does, then the certificate is // considered as revoked. CertificateName certificateName = - CertificateName.of(PROJECT_ID, LOCATION, CA_POOL_ID, CERTIFICATE_NAME); + CertificateName.of(PROJECT_ID, LOCATION, CA_poolId, CERTIFICATE_NAME); Assert.assertTrue( certificateAuthorityServiceClient.getCertificate(certificateName).hasRevocationDetails()); } @@ -438,7 +438,7 @@ public void testCreateSubordinateCertificateAuthority() throws IOException { CertificateAuthorityServiceClient.create()) { CertificateAuthority response = certificateAuthorityServiceClient.getCertificateAuthority( - CertificateAuthorityName.of(PROJECT_ID, LOCATION, CA_POOL_ID, SUBORDINATE_CA_NAME) + CertificateAuthorityName.of(PROJECT_ID, LOCATION, CA_poolId, SUBORDINATE_CA_NAME) .toString()); Assert.assertTrue(response.hasCreateTime()); } @@ -450,7 +450,7 @@ public void testCreateCertificateWithCSR() throws IOException { CertificateAuthorityServiceClient.create()) { Certificate response = certificateAuthorityServiceClient.getCertificate( - CertificateName.of(PROJECT_ID, LOCATION, CA_POOL_ID, CSR_CERTIFICATE_NAME) + CertificateName.of(PROJECT_ID, LOCATION, CA_poolId, CSR_CERTIFICATE_NAME) .toString()); Assert.assertTrue(response.hasCreateTime()); } @@ -463,13 +463,13 @@ public void testActivateSubordinateCertificateAuthority() CertificateAuthorityServiceClient.create()) { Certificate response = certificateAuthorityServiceClient.getCertificate( - CertificateName.of(PROJECT_ID, LOCATION, CA_POOL_ID, CSR_CERTIFICATE_NAME) + CertificateName.of(PROJECT_ID, LOCATION, CA_poolId, CSR_CERTIFICATE_NAME) .toString()); String pemCertificate = response.getPemCertificate(); - privateca.ActivateSubordinateCa.activateSubordinateCA( - PROJECT_ID, LOCATION, CA_POOL_ID, CA_NAME, SUBORDINATE_CA_NAME, pemCertificate); + privateca.ActivateSubordinateCa.activateSubordinateCa( + PROJECT_ID, LOCATION, CA_poolId, CA_NAME, SUBORDINATE_CA_NAME, pemCertificate); assertThat(stdOut.toString()).contains("Current State: STAGED"); } }