Skip to content

[JENKINS-48437] Use the new API passing the Run to retrieve the token#141

Merged
dwnusbaum merged 6 commits intojenkinsci:masterfrom
Dohbedoh:JENKINS-48437
Apr 2, 2019
Merged

[JENKINS-48437] Use the new API passing the Run to retrieve the token#141
dwnusbaum merged 6 commits intojenkinsci:masterfrom
Dohbedoh:JENKINS-48437

Conversation

@Dohbedoh
Copy link
Contributor

JENKINS-48437

Consume a new API introduced in jenkinsci/docker-commons-plugin#68 that accepts a Run to resolve the credentials ID.

Copy link
Member

@jglick jglick left a comment

Choose a reason for hiding this comment

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

What about ServerEndpointStep?

@jglick jglick self-requested a review March 5, 2019 14:18
Copy link
Member

@jglick jglick left a comment

Choose a reason for hiding this comment

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

Possibly right. Not sure I understand the nature of the bug or its fix.

"node {\n" +
" mockDockerLoginWithEcho {\n" +
" withDockerRegistry(url: 'https://my-reg:1234', credentialsId: 'registryCreds') {\n" +
" echo 'config would be set up to connect to https://my-reg:1234'\n" +
Copy link
Member

Choose a reason for hiding this comment

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

I am not sure what this is proving. You print a literal message, then later assert that the identical message got printed?

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 echo is not needed for the test. I can remove it. The real test here is that the credentials passed to withDockerRegistry results in the expected docker login command.

MockAuthorizationStrategy auth = new MockAuthorizationStrategy()
.grant(Jenkins.READ).everywhere().to("alice")
.grant(Computer.BUILD).everywhere().to("alice")
.grant(Item.CONFIGURE).everywhere().to("alice");
Copy link
Member

Choose a reason for hiding this comment

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

I guess for purposes of this test you could just use FullControlOnceLoggedInAuthorizationStrategy or .grant(Jenkins.ADMINISTER).everywhere().toAuthenticated() since the ACL checks are not part of the test, unless I am misunderstanding the nature of the problem.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The ACL is what JENKINS-48437 is about. When the build runs as a specific user, the credentials cannot be found.

        try (ACLContext as = ACL.as(User.getById("alice", false))) {
            b = r.buildAndAssertSuccess(p);
        }

This tests fails without our fix.

" }\n" +
"}", true));
WorkflowRun b = story.j.buildAndAssertSuccess(p);
story.j.assertLogContains("would be connecting to tcp://host:1234", b);
Copy link
Member

Choose a reason for hiding this comment

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

But you are not actually testing the credentials here. What then happens with src/main/ reverted? Is there a build failure, or are the credentials ignored, or a warning logged?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

You're right. I am going to add test on DOCKER_TLS_VERIFY and DOCKER_CERT_PATH that should be injected by the step. I have noticed that in the case of JENKINS-48437, there is not failure but those variables are not filled.

@Dohbedoh
Copy link
Contributor Author

(Build failure caused by infra "No Space Left on Device")

Copy link
Member

@dwnusbaum dwnusbaum left a comment

Choose a reason for hiding this comment

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

Looks good to me. I expanded the test cases slightly in #168 for clarity.

@dwnusbaum dwnusbaum merged commit 09c810b into jenkinsci:master Apr 2, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants