Skip to content

Commit

Permalink
chore(python): run blacken session for all directories with a noxfile (
Browse files Browse the repository at this point in the history
…#150)

Source-Link: googleapis/synthtool@bc0de6e
Post-Processor: gcr.io/cloud-devrel-public-resources/owlbot-python:latest@sha256:39ad8c0570e4f5d2d3124a509de4fe975e799e2b97e0f58aed88f8880d5a8b60

Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com>
  • Loading branch information
2 people authored and m-strzelczyk committed Jan 25, 2023
1 parent ed129cd commit 2272afb
Show file tree
Hide file tree
Showing 8 changed files with 14 additions and 44 deletions.
4 changes: 1 addition & 3 deletions privateca/snippets/create_ca_pool.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,7 @@ def create_ca_pool(project_id: str, location: str, ca_pool_name: str) -> None:

# Create the pool request.
request = privateca_v1.CreateCaPoolRequest(
parent=location_path,
ca_pool_id=ca_pool_name,
ca_pool=ca_pool,
parent=location_path, ca_pool_id=ca_pool_name, ca_pool=ca_pool,
)

# Create the CA pool.
Expand Down
9 changes: 3 additions & 6 deletions privateca/snippets/create_certificate.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,7 @@ def create_certificate(

# Set the Public Key and its format.
public_key = privateca_v1.PublicKey(
key=public_key_bytes,
format_=privateca_v1.PublicKey.KeyFormat.PEM,
key=public_key_bytes, format_=privateca_v1.PublicKey.KeyFormat.PEM,
)

subject_config = privateca_v1.CertificateConfig.SubjectConfig(
Expand All @@ -67,12 +66,10 @@ def create_certificate(
x509_parameters = privateca_v1.X509Parameters(
key_usage=privateca_v1.KeyUsage(
base_key_usage=privateca_v1.KeyUsage.KeyUsageOptions(
digital_signature=True,
key_encipherment=True,
digital_signature=True, key_encipherment=True,
),
extended_key_usage=privateca_v1.KeyUsage.ExtendedKeyUsageOptions(
server_auth=True,
client_auth=True,
server_auth=True, client_auth=True,
),
),
)
Expand Down
10 changes: 3 additions & 7 deletions privateca/snippets/create_certificate_authority.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,13 +58,10 @@ def create_certificate_authority(
x509_parameters = privateca_v1.X509Parameters(
key_usage=privateca_v1.KeyUsage(
base_key_usage=privateca_v1.KeyUsage.KeyUsageOptions(
crl_sign=True,
cert_sign=True,
crl_sign=True, cert_sign=True,
)
),
ca_options=privateca_v1.X509Parameters.CaOptions(
is_ca=True,
),
ca_options=privateca_v1.X509Parameters.CaOptions(is_ca=True,),
)

# Set certificate authority settings.
Expand All @@ -73,8 +70,7 @@ def create_certificate_authority(
type_=privateca_v1.CertificateAuthority.Type.SELF_SIGNED,
key_spec=key_version_spec,
config=privateca_v1.CertificateConfig(
subject_config=subject_config,
x509_config=x509_parameters,
subject_config=subject_config, x509_config=x509_parameters,
),
lifetime=duration_pb2.Duration(seconds=ca_duration),
)
Expand Down
4 changes: 1 addition & 3 deletions privateca/snippets/enable_certificate_authority.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,7 @@ def enable_certificate_authority(
)

# Create the Enable Certificate Authority Request.
request = privateca_v1.EnableCertificateAuthorityRequest(
name=ca_path,
)
request = privateca_v1.EnableCertificateAuthorityRequest(name=ca_path,)

# Enable the Certificate Authority.
operation = caServiceClient.enable_certificate_authority(request=request)
Expand Down
6 changes: 1 addition & 5 deletions privateca/snippets/list_certificates.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,7 @@
import google.cloud.security.privateca_v1 as privateca_v1


def list_certificates(
project_id: str,
location: str,
ca_pool_name: str,
) -> None:
def list_certificates(project_id: str, location: str, ca_pool_name: str,) -> None:
"""
List Certificates present in the given CA pool.
Expand Down
5 changes: 1 addition & 4 deletions privateca/snippets/revoke_certificate.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,7 @@


def revoke_certificate(
project_id: str,
location: str,
ca_pool_name: str,
certificate_name: str,
project_id: str, location: str, ca_pool_name: str, certificate_name: str,
) -> None:
"""
Revoke an issued certificate. Once revoked, the certificate will become invalid and will expire post its lifetime.
Expand Down
15 changes: 3 additions & 12 deletions privateca/snippets/test_certificate_authorities.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,14 +67,8 @@ def test_enable_and_disable_certificate_authority(

out, _ = capsys.readouterr()

assert re.search(
f"Enabled Certificate Authority: {CA_NAME}",
out,
)
assert re.search(
f"Disabled Certificate Authority: {CA_NAME}",
out,
)
assert re.search(f"Enabled Certificate Authority: {CA_NAME}", out,)
assert re.search(f"Disabled Certificate Authority: {CA_NAME}", out,)


def test_delete_certificate_authority(capsys: typing.Any) -> None:
Expand All @@ -90,7 +84,4 @@ def test_delete_certificate_authority(capsys: typing.Any) -> None:

out, _ = capsys.readouterr()

assert re.search(
f"Successfully deleted Certificate Authority: {CA_NAME}",
out,
)
assert re.search(f"Successfully deleted Certificate Authority: {CA_NAME}", out,)
5 changes: 1 addition & 4 deletions privateca/snippets/test_certificates.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,10 +75,7 @@ def test_create_and_revoke_certificate_authority(
)

revoke_certificate(
PROJECT,
LOCATION,
CA_POOL_NAME,
CERT_NAME,
PROJECT, LOCATION, CA_POOL_NAME, CERT_NAME,
)

disable_certificate_authority(PROJECT, LOCATION, CA_POOL_NAME, CA_NAME)
Expand Down

0 comments on commit 2272afb

Please sign in to comment.