Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Use bindings for resolving multi pattern resources #1818

Merged
merged 24 commits into from
Jul 17, 2023

Conversation

lqiu96
Copy link
Contributor

@lqiu96 lqiu96 commented Jun 29, 2023

Thank you for opening a Pull Request! For general contributing guidelines, please refer to contributing guide

Before submitting your PR, there are a few things you can do to make sure it goes smoothly:

  • Make sure to open an issue as a bug/issue before writing your code! That way we can discuss the change, evaluate designs, and agree on the general idea
  • Ensure the tests and linter pass
  • Code coverage does not decrease (if any source code was changed)
  • Appropriate docs were updated (if necessary)

Fixes #1547 ☕️

This seems to impact Resources that have multiple patterns. The original intended behavior is to try and use the HttpBindings to match one of the patterns. However, the bindings weren't being passed for any nested field.

For example, messaging.proto's UpdateBlurb RPCs: https://github.com/googleapis/gapic-showcase/blob/082b527b3b91c890bd3951d44e18fdfc76cdb5a3/schema/google/showcase/v1beta1/messaging.proto#L110-L117, it will attempt to match the default option before running through the additional_bindings.

  • First checks that /v1beta1/{blurb.name=rooms/*/blurbs/*} is a possible match before /v1beta1/{blurb.name=users/*/profile/blurbs/*}. If there are no matches, it will pick the first out of the list of patterns in the resource definition.

The behavior should not impact any resource with a single pattern as that pattern will be used even if the httpbindings match or not.

@product-auto-label product-auto-label bot added the size: s Pull request size is small. label Jun 29, 2023
@lqiu96 lqiu96 marked this pull request as ready for review July 5, 2023 19:56
@lqiu96 lqiu96 requested a review from a team as a code owner July 5, 2023 19:56
@lqiu96 lqiu96 added the owlbot:run Add this label to trigger the Owlbot post processor. label Jul 5, 2023
@gcf-owl-bot gcf-owl-bot bot removed the owlbot:run Add this label to trigger the Owlbot post processor. label Jul 5, 2023
@lqiu96 lqiu96 marked this pull request as draft July 5, 2023 21:49
@product-auto-label product-auto-label bot added size: m Pull request size is medium. and removed size: s Pull request size is small. labels Jul 5, 2023
lqiu96 and others added 14 commits July 6, 2023 10:58
* chore: initial additions to handle GDC-H API audience

* chore: add unit tests for GDC-H

* chore: cleanup of logic

* chore: decompose tests into separate methods

* chore: fix clirr diff check

* chore: fmt:format

* chore: add support in `ClientSettings`

* chore: add showcase IT for GDCH credentials

* chore: comments

* chore: improve tests

* chore: add partial IT for testing context credential

* chore: recreate GdchCredentials with audience using convenience method

* chore: more readable api audience logic

* chore: no wildcard imports

* chore: javadoc for public methods

* chore: gdch test to use default null initialization

* chore: tear down for gdch IT

* chore: `assertThrows` for gdch ITs

* chore: mvn fmt:format

* test: remove context test

* docs: explain that audience will be overriden if set through client/stub settings

* test: test audience setting should modify initial credentials

* chore: clirr check

* chore: ignore gdch changes

* chore: format

* chore: default to endpoint if audience not provided

* test: refresh gdch creds to confirm audience works

* chore: fmt

* chore: fmt

* chore: better test names in ClientContextTest

* chore: better test names for showcase tests

* chore: simplify refresh verification logic

* chore: include outcome in gdch it test names

* chore: expand comments in GDCH ITs

* test: intercept mock transport to verify audience

* chore: fmt

* chore: move auth test-jar to shared dependencies

* chore: cleanup

* chore: use inferred version for auth library

* deps: update google-auth-java-library to 1.19.0

* choreL fmt ITGdch.java

* chore: import auth test-jar using common version variable

* chore: remove auth test-jar import from first-party-dependencies

* chore: add license headers to new files

* chore: revert google-auth-version to be obtained from main branch

* chore: correct showcase parent pom indentation

* chore: remove resource declaration for native test build
* chore: Bump guava version to 32.1.1-jre

* chore: Add guava to gradle template
Install sdk-platform-java before performing final clirr check, so version changes are available in the local repository
Co-authored-by: release-please[bot] <55107282+release-please[bot]@users.noreply.github.com>
Co-authored-by: release-please[bot] <55107282+release-please[bot]@users.noreply.github.com>
* chore: Add framework for iam showcase tests

* chore: Generate clients with IAM stubs

* chore: Add IAM showcase tests

* chore: Add samples

* chore: Exclude httpjson tests

* chore: Use @before to create the resource

* chore: Use constant for policy

* chore: Log resource name

* chore: Test use setPolicyRequest's resourceName

* chore: run mvn clean before showcase tests

* chore: Attempt again with cache deleted

* chore: Add logging for test

* chore: Sleep for 1s

* chore: Use resource from setPolicyRequest

* chore: Ignore failing HttpJson test for now

* chore: Un-ignore test

* chore: Fix lint issues

* chore: Test with rooms/ prefix

* chore: Use Identity client for Users

* chore: Create user resource to assign policy to

* chore: Use user's name as resource id

* chore: Change resource name before each test

* chore: Add iam-grpc in pom

* chore: Resolve sonar issues

* chore: Add comment for testIamPolicy

* chore: Address PR comments
* ci: showcase native check

* fix: add explicit java version

* fix: adjust syntax

* fix: add resource-config entry for ITGdch

* fix: copy file to temp folder so it can be accessed by path

* chore: formatting

* fix: prevent shutdown warnings with client.awaitTermination

* ci: fix build file location for downstream test

* chore: use static imports for Truth assertions
@product-auto-label product-auto-label bot added size: l Pull request size is large. and removed size: m Pull request size is medium. labels Jul 12, 2023
@product-auto-label product-auto-label bot added size: m Pull request size is medium. and removed size: l Pull request size is large. labels Jul 12, 2023
@product-auto-label product-auto-label bot added size: l Pull request size is large. and removed size: m Pull request size is medium. labels Jul 13, 2023
@sonarcloud
Copy link

sonarcloud bot commented Jul 14, 2023

[gapic-generator-java-root] SonarCloud Quality Gate failed.    Quality Gate failed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 1 Code Smell

100.0% 100.0% Coverage
12.8% 12.8% Duplication

idea Catch issues before they fail your Quality Gate with our IDE extension sonarlint SonarLint

@sonarcloud
Copy link

sonarcloud bot commented Jul 14, 2023

[java_showcase_integration_tests] SonarCloud Quality Gate failed.    Quality Gate failed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
32.7% 32.7% Duplication

idea Catch issues before they fail your Quality Gate with our IDE extension sonarlint SonarLint

@sonarcloud
Copy link

sonarcloud bot commented Jul 14, 2023

[java_showcase_unit_tests] SonarCloud Quality Gate failed.    Quality Gate failed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
32.7% 32.7% Duplication

idea Catch issues before they fail your Quality Gate with our IDE extension sonarlint SonarLint

@lqiu96 lqiu96 marked this pull request as ready for review July 17, 2023 13:56
@lqiu96 lqiu96 added the owlbot:run Add this label to trigger the Owlbot post processor. label Jul 17, 2023
@gcf-owl-bot gcf-owl-bot bot removed the owlbot:run Add this label to trigger the Owlbot post processor. label Jul 17, 2023
@lqiu96 lqiu96 requested a review from blakeli0 July 17, 2023 13:56
@lqiu96 lqiu96 merged commit 1352fab into main Jul 17, 2023
19 of 22 checks passed
@lqiu96 lqiu96 deleted the fix-default-resource-name branch July 17, 2023 17:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
size: l Pull request size is large.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

com.google.showcase.v1beta1.MessagingClientHttpJsonTest#updateBlurbTest failing with 404 error
5 participants