Skip to content
This repository has been archived by the owner on Dec 3, 2023. It is now read-only.

tests: clean up tests for IAM condition support #224

Merged
merged 3 commits into from May 28, 2020

Conversation

athakor
Copy link
Contributor

@athakor athakor commented May 27, 2020

Fixes #169

@googlebot googlebot added the cla: yes This human has signed the Contributor License Agreement. label May 27, 2020
@athakor athakor requested a review from frankyn May 27, 2020 14:22
@codecov
Copy link

codecov bot commented May 27, 2020

Codecov Report

Merging #224 into master will increase coverage by 0.01%.
The diff coverage is n/a.

Impacted file tree graph

@@             Coverage Diff              @@
##             master     #224      +/-   ##
============================================
+ Coverage     67.61%   67.62%   +0.01%     
- Complexity      379      384       +5     
============================================
  Files            36       36              
  Lines          1976     1986      +10     
  Branches        262      269       +7     
============================================
+ Hits           1336     1343       +7     
- Misses          532      535       +3     
  Partials        108      108              
Impacted Files Coverage Δ Complexity Δ
...re/src/main/java/com/google/cloud/RetryHelper.java 50.00% <0.00%> (-3.85%) 2.00% <0.00%> (ø%)
...d-core/src/main/java/com/google/cloud/Binding.java 100.00% <0.00%> (ø) 2.00% <0.00%> (ø%)
...core/src/main/java/com/google/cloud/Condition.java 100.00% <0.00%> (ø) 2.00% <0.00%> (ø%)
...ud-core/src/main/java/com/google/cloud/Policy.java 92.15% <0.00%> (+0.03%) 20.00% <0.00%> (ø%)
...src/main/java/com/google/cloud/ServiceOptions.java 43.87% <0.00%> (+0.04%) 33.00% <0.00%> (+1.00%)
...a/com/google/cloud/testing/BaseEmulatorHelper.java 31.42% <0.00%> (+0.21%) 5.00% <0.00%> (ø%)
.../com/google/cloud/MonitoredResourceDescriptor.java 84.03% <0.00%> (+0.27%) 24.00% <0.00%> (+4.00%)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update e86dbe7...0d695bc. Read the comment docs.

@athakor
Copy link
Contributor Author

athakor commented May 27, 2020

@frankyn @netdpb PTAL when you have a moment

private static final Binding VIEWER_BINDING =
Binding.newBuilder().setRole(VIEWER).setMembers(MEMBERS_LIST_1).build();
private static final Binding EDITOR_BINDING =
Binding.newBuilder().setRole(EDITOR).setMembers(MEMBERS_LIST_2).build();
private static final List<Binding> BINDINGS_NO_CONDITIONS =
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
private static final List<Binding> BINDINGS_NO_CONDITIONS =
private static final ImmutableList<Binding> BINDINGS_NO_CONDITIONS =

ImmutableList and friends are especially useful as parameter, method, field, and local variable types, so that users know they are immutable. (For example, the mutation methods are all deprecated, so IDEs will warn about their use.) Please do this throughout the file.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

Comment on lines 63 to 64
ImmutableList.copyOf(BINDINGS_NO_CONDITIONS)
.of(
Binding.newBuilder()
.setRole(VIEWER)
.setMembers(MEMBERS_LIST_1)
.setCondition(
Condition.newBuilder()
.setTitle("Condition")
.setDescription("Condition")
.setExpression("Expr")
.build())
.build(),
Binding.newBuilder().setRole(EDITOR).setMembers(MEMBERS_LIST_2).build());
.of(VIEWER_BINDING.toBuilder().setCondition(CONDITION).build(), EDITOR_BINDING);
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ImmutableList.of() is a static method. Here you're calling a static method on an instance (returned by ImmutableList.copyOf()), which basically throws the instance away.

I think you can delete line 63 and just do ImmutableList.of(VIEWER_BINDING.toBuilder()…, EDITOR_BINDING).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@athakor
Copy link
Contributor Author

athakor commented May 28, 2020

@netdpb PTAL

@athakor athakor added the automerge Merge the pull request once unit tests and other checks pass. label May 28, 2020
@frankyn frankyn merged commit db345f4 into googleapis:master May 28, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
automerge Merge the pull request once unit tests and other checks pass. cla: yes This human has signed the Contributor License Agreement.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Clean up tests for IAM Condition Support
4 participants