Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/google-cloud-recaptcha-enterprise/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ Python Client for reCAPTCHA Enterprise
.. |versions| image:: https://img.shields.io/pypi/pyversions/google-cloud-recaptcha-enterprise.svg
:target: https://pypi.org/project/google-cloud-recaptcha-enterprise/
.. _reCAPTCHA Enterprise: https://cloud.google.com/recaptcha-enterprise
.. _Client Library Documentation: https://cloud.google.com/python/docs/reference/recaptchaenterprise/latest
.. _Client Library Documentation: https://cloud.google.com/python/docs/reference/recaptchaenterprise/latest/summary_overview
.. _Product Documentation: https://cloud.google.com/recaptcha-enterprise

Quick Start
Expand Down
5 changes: 5 additions & 0 deletions packages/google-cloud-recaptcha-enterprise/docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,8 @@ For a list of all ``google-cloud-recaptcha-enterprise`` releases:
:maxdepth: 2

CHANGELOG

.. toctree::
:hidden:

summary_overview.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
[
This is a templated file. Adding content to this file may result in it being
reverted. Instead, if you want to place additional content, create an
"overview_content.md" file in `docs/` directory. The Sphinx tool will
pick up on the content and merge the content.
]: #

# reCAPTCHA Enterprise API

Overview of the APIs available for reCAPTCHA Enterprise API.

## All entries

Classes, methods and properties & attributes for
reCAPTCHA Enterprise API.

[classes](https://cloud.google.com/python/docs/reference/recaptchaenterprise/latest/summary_class.html)

[methods](https://cloud.google.com/python/docs/reference/recaptchaenterprise/latest/summary_method.html)

[properties and
attributes](https://cloud.google.com/python/docs/reference/recaptchaenterprise/latest/summary_property.html)
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@
ListRelatedAccountGroupsResponse,
Metrics,
MigrateKeyRequest,
PhoneFraudAssessment,
PrivatePasswordLeakVerification,
RelatedAccountGroup,
RelatedAccountGroupMembership,
Expand All @@ -72,6 +73,7 @@
ScoreMetrics,
SearchRelatedAccountGroupMembershipsRequest,
SearchRelatedAccountGroupMembershipsResponse,
SmsTollFraudVerdict,
TestingOptions,
TokenProperties,
TransactionData,
Expand Down Expand Up @@ -122,6 +124,7 @@
"ListRelatedAccountGroupsResponse",
"Metrics",
"MigrateKeyRequest",
"PhoneFraudAssessment",
"PrivatePasswordLeakVerification",
"RelatedAccountGroup",
"RelatedAccountGroupMembership",
Expand All @@ -134,6 +137,7 @@
"ScoreMetrics",
"SearchRelatedAccountGroupMembershipsRequest",
"SearchRelatedAccountGroupMembershipsResponse",
"SmsTollFraudVerdict",
"TestingOptions",
"TokenProperties",
"TransactionData",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@
ListRelatedAccountGroupsResponse,
Metrics,
MigrateKeyRequest,
PhoneFraudAssessment,
PrivatePasswordLeakVerification,
RelatedAccountGroup,
RelatedAccountGroupMembership,
Expand All @@ -70,6 +71,7 @@
ScoreMetrics,
SearchRelatedAccountGroupMembershipsRequest,
SearchRelatedAccountGroupMembershipsResponse,
SmsTollFraudVerdict,
TestingOptions,
TokenProperties,
TransactionData,
Expand Down Expand Up @@ -119,6 +121,7 @@
"ListRelatedAccountGroupsResponse",
"Metrics",
"MigrateKeyRequest",
"PhoneFraudAssessment",
"PrivatePasswordLeakVerification",
"RecaptchaEnterpriseServiceClient",
"RelatedAccountGroup",
Expand All @@ -132,6 +135,7 @@
"ScoreMetrics",
"SearchRelatedAccountGroupMembershipsRequest",
"SearchRelatedAccountGroupMembershipsResponse",
"SmsTollFraudVerdict",
"TestingOptions",
"TokenProperties",
"TransactionData",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
ListRelatedAccountGroupsResponse,
Metrics,
MigrateKeyRequest,
PhoneFraudAssessment,
PrivatePasswordLeakVerification,
RelatedAccountGroup,
RelatedAccountGroupMembership,
Expand All @@ -61,6 +62,7 @@
ScoreMetrics,
SearchRelatedAccountGroupMembershipsRequest,
SearchRelatedAccountGroupMembershipsResponse,
SmsTollFraudVerdict,
TestingOptions,
TokenProperties,
TransactionData,
Expand Down Expand Up @@ -109,6 +111,7 @@
"ListRelatedAccountGroupsResponse",
"Metrics",
"MigrateKeyRequest",
"PhoneFraudAssessment",
"PrivatePasswordLeakVerification",
"RelatedAccountGroup",
"RelatedAccountGroupMembership",
Expand All @@ -121,6 +124,7 @@
"ScoreMetrics",
"SearchRelatedAccountGroupMembershipsRequest",
"SearchRelatedAccountGroupMembershipsResponse",
"SmsTollFraudVerdict",
"TestingOptions",
"TokenProperties",
"TransactionData",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@
"TokenProperties",
"FraudPreventionAssessment",
"FraudSignals",
"SmsTollFraudVerdict",
"PhoneFraudAssessment",
"AccountDefenderAssessment",
"CreateKeyRequest",
"ListKeysRequest",
Expand Down Expand Up @@ -674,6 +676,10 @@ class Assessment(proto.Message):
fraud_signals (google.cloud.recaptchaenterprise_v1.types.FraudSignals):
Output only. Fraud Signals specific to the
users involved in a payment transaction.
phone_fraud_assessment (google.cloud.recaptchaenterprise_v1.types.PhoneFraudAssessment):
Output only. Assessment returned when a site key, a token,
and a phone number as ``user_id`` are provided. Account
defender and SMS toll fraud protection need to be enabled.
"""

name: str = proto.Field(
Expand Down Expand Up @@ -725,6 +731,11 @@ class Assessment(proto.Message):
number=13,
message="FraudSignals",
)
phone_fraud_assessment: "PhoneFraudAssessment" = proto.Field(
proto.MESSAGE,
number=12,
message="PhoneFraudAssessment",
)


class Event(proto.Message):
Expand Down Expand Up @@ -1615,6 +1626,58 @@ class CardLabel(proto.Enum):
)


class SmsTollFraudVerdict(proto.Message):
r"""Information about SMS toll fraud.

Attributes:
risk (float):
Output only. Probability of an SMS event
being fraudulent. Values are from 0.0 (lowest)
to 1.0 (highest).
reasons (MutableSequence[google.cloud.recaptchaenterprise_v1.types.SmsTollFraudVerdict.SmsTollFraudReason]):
Output only. Reasons contributing to the SMS
toll fraud verdict.
"""

class SmsTollFraudReason(proto.Enum):
r"""Reasons contributing to the SMS toll fraud verdict.

Values:
SMS_TOLL_FRAUD_REASON_UNSPECIFIED (0):
Default unspecified reason
INVALID_PHONE_NUMBER (1):
The provided phone number was invalid
"""
SMS_TOLL_FRAUD_REASON_UNSPECIFIED = 0
INVALID_PHONE_NUMBER = 1

risk: float = proto.Field(
proto.FLOAT,
number=1,
)
reasons: MutableSequence[SmsTollFraudReason] = proto.RepeatedField(
proto.ENUM,
number=2,
enum=SmsTollFraudReason,
)


class PhoneFraudAssessment(proto.Message):
r"""Assessment for Phone Fraud

Attributes:
sms_toll_fraud_verdict (google.cloud.recaptchaenterprise_v1.types.SmsTollFraudVerdict):
Output only. Assessment of this phone event
for risk of SMS toll fraud.
"""

sms_toll_fraud_verdict: "SmsTollFraudVerdict" = proto.Field(
proto.MESSAGE,
number=1,
message="SmsTollFraudVerdict",
)


class AccountDefenderAssessment(proto.Message):
r"""Account defender risk assessment.

Expand Down
46 changes: 35 additions & 11 deletions packages/google-cloud-recaptcha-enterprise/noxfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,14 +160,28 @@ def install_unittest_dependencies(session, *constraints):
session.install("-e", ".", *constraints)


def default(session):
@nox.session(python=UNIT_TEST_PYTHON_VERSIONS)
@nox.parametrize(
"protobuf_implementation",
["python", "upb", "cpp"],
)
def unit(session, protobuf_implementation):
# Install all test dependencies, then install this package in-place.

if protobuf_implementation == "cpp" and session.python in ("3.11", "3.12"):
session.skip("cpp implementation is not supported in python 3.11+")

constraints_path = str(
CURRENT_DIRECTORY / "testing" / f"constraints-{session.python}.txt"
)
install_unittest_dependencies(session, "-c", constraints_path)

# TODO(https://github.com/googleapis/synthtool/issues/1976):
# Remove the 'cpp' implementation once support for Protobuf 3.x is dropped.
# The 'cpp' implementation requires Protobuf<4.
if protobuf_implementation == "cpp":
session.install("protobuf<4")

# Run py.test against the unit tests.
session.run(
"py.test",
Expand All @@ -181,15 +195,12 @@ def default(session):
"--cov-fail-under=0",
os.path.join("tests", "unit"),
*session.posargs,
env={
"PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION": protobuf_implementation,
},
)


@nox.session(python=UNIT_TEST_PYTHON_VERSIONS)
def unit(session):
"""Run the unit test suite."""
default(session)


def install_systemtest_dependencies(session, *constraints):
# Use pre-release gRPC for system tests.
# Exclude version 1.52.0rc1 which has a known issue.
Expand Down Expand Up @@ -358,9 +369,16 @@ def docfx(session):


@nox.session(python="3.12")
def prerelease_deps(session):
@nox.parametrize(
"protobuf_implementation",
["python", "upb", "cpp"],
)
def prerelease_deps(session, protobuf_implementation):
"""Run all tests with prerelease versions of dependencies installed."""

if protobuf_implementation == "cpp" and session.python in ("3.11", "3.12"):
session.skip("cpp implementation is not supported in python 3.11+")

# Install all dependencies
session.install("-e", ".[all, tests, tracing]")
unit_deps_all = UNIT_TEST_STANDARD_DEPENDENCIES + UNIT_TEST_EXTERNAL_DEPENDENCIES
Expand Down Expand Up @@ -397,9 +415,9 @@ def prerelease_deps(session):
"protobuf",
# dependency of grpc
"six",
"grpc-google-iam-v1",
"googleapis-common-protos",
# Exclude version 1.52.0rc1 which has a known issue. See https://github.com/grpc/grpc/issues/32163
"grpcio!=1.52.0rc1",
"grpcio",
"grpcio-status",
"google-api-core",
"google-auth",
Expand All @@ -425,4 +443,10 @@ def prerelease_deps(session):
session.run("python", "-c", "import grpc; print(grpc.__version__)")
session.run("python", "-c", "import google.auth; print(google.auth.__version__)")

session.run("py.test", "tests/unit")
session.run(
"py.test",
"tests/unit",
env={
"PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION": protobuf_implementation,
},
)