Skip to content

Conversation

@awkoren
Copy link
Contributor

@awkoren awkoren commented Aug 3, 2018

Snippets for:

  • Quickstart
  • Query grantable roles
  • Service accounts
  • Service account keys

@googlebot googlebot added the cla: yes This human has signed the Contributor License Agreement. label Aug 3, 2018
@awkoren
Copy link
Contributor Author

awkoren commented Aug 6, 2018

  1. Permissions needed for tests:

roles/iam.securityReviewer
roles/iam.serviceAccountAdmin
roles/iam.serviceAccountKeyAdmin

  1. The error below seems to indicate the test cannot find the default project. Is GOOGLE_PROJECT_ID set in the test harness?

"message" : "You don't have permission to query grantable roles for //cloudresourcemanager.googleapis.com/projects/null.",

@dzlier-gcp
Copy link
Member

The "GOOGLE_CLOUD_PROJECT" environment variable is set with the project ID during tests in this package.

@@ -0,0 +1,59 @@
// Copyright 2018 Google Inc.
Copy link
Member

Choose a reason for hiding this comment

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

Please use "LLC", as well as javadoc style comments in this and all other java files, i.e.

/** Copyright 2018 Google LLC
*

  • Licensed...
    */

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 -- however, this now causes the tests to fail:

RegexpHeader: Line does not match expected header line of '^\W+*?\W*Copyright 20\d\d Google Inc.$'.

Seems like the test needs to be updated to use LLC...

<parent>
<groupId>com.google.cloud.samples</groupId>
<artifactId>shared-configuration</artifactId>
<version>1.0.9</version>
Copy link
Member

Choose a reason for hiding this comment

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

Please update this to version 1.0.11.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This results in an error. Also the root pom.xml and many of the other samples I looked at use 1.0.9 so I'm not sure why this change is needed?

Failure to find com.google.cloud.samples:shared-configuration:pom:1.0.11 in https://repo.maven.apache.org/maven2 was cached in the local repository, resolution will not be reattempted until the update interval of central has elapsed or updates are forced

String project = System.getenv("GOOGLE_CLOUD_PROJECT");
String resource = "//cloudresourcemanager.googleapis.com/projects/" + project;

GrantableRoles.main(new String[] {resource});
Copy link
Member

Choose a reason for hiding this comment

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

Can you intercept the output of the program running and then verify that the output is what you'd expect? There are several examples of doing this in other IT's in this repo, just search for "bout" and you'll find one.

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


@Test
public void testQuickstart() throws Exception {
Quickstart.main(new String[0]);
Copy link
Member

Choose a reason for hiding this comment

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

Here as well, please verify the output matches what is expected when this runs. We don't just want to catch exceptions, we want the tests to verify that the output hasn't changed. Some calls will return error messages without actually throwing any exceptions.

@Test
public void testServiceAccounts() throws Exception {

String projectId = System.getenv("GOOGLE_CLOUD_PROJECT");
Copy link
Member

Choose a reason for hiding this comment

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

Same

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

@awkoren
Copy link
Contributor Author

awkoren commented Aug 21, 2018

Addressed all feedback.
Note that changing "Google Inc" to "Google LLC" is causing the tests to fail:
RegexpHeader: Line does not match expected header line of '^\W+*?\W*Copyright 20\d\d Google Inc.$'.

@dzlier-gcp
Copy link
Member

Ah, I thought 1.0.11 was available, but try 1.0.10. If the tests still fail with that LLC/Inc change, then you can change them back and hopefully 1.0.11 will address it.

@awkoren
Copy link
Contributor Author

awkoren commented Aug 21, 2018

10.0.10 worked

@dzlier-gcp
Copy link
Member

@dpebot Merge when green

@dpebot
Copy link
Contributor

dpebot commented Sep 4, 2018

Okay! I'll merge when all statuses are green and all reviewers approve.

@dpebot dpebot self-assigned this Sep 4, 2018
@awkoren
Copy link
Contributor Author

awkoren commented Sep 7, 2018

It looks like all statuses are green and a reviewer has approved -- what else needs to happen to trigger dpebot?

@dzlier-gcp dzlier-gcp merged commit 85ef6f2 into GoogleCloudPlatform:master Sep 12, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cla: yes This human has signed the Contributor License Agreement.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants