Skip to content
This repository was archived by the owner on Sep 30, 2024. It is now read-only.

internal/authz/azuredevops: Implement ValidateConnection#48465

Merged
indradhanush merged 2 commits into
mainfrom
ig/ado-validation-check
Mar 2, 2023
Merged

internal/authz/azuredevops: Implement ValidateConnection#48465
indradhanush merged 2 commits into
mainfrom
ig/ado-validation-check

Conversation

@indradhanush

@indradhanush indradhanush commented Mar 1, 2023

Copy link
Copy Markdown
Contributor

Follow up on #48209. Part of #47165.

Test plan

  • Tested locally
  • Builds should pass
  • Added tests

@cla-bot cla-bot Bot added the cla-signed label Mar 1, 2023
@indradhanush indradhanush changed the title internal/authz/azuredevops: Implement ValidateConnectoin internal/authz/azuredevops: Implement ValidateConnection Mar 1, 2023
@indradhanush indradhanush requested a review from a team March 1, 2023 15:37
@indradhanush indradhanush self-assigned this Mar 1, 2023
@indradhanush indradhanush added the ADO Tier 1 support for Azure DevOps label Mar 1, 2023

@sashaostrikov sashaostrikov left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

You have a nil-pointer dereference probability in your code which needs to be fixed :)

We should add tests which would have caught it, shouldn't we?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

nil-pointer dereference alert :)
when err above is not nil, then the client is nil

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

That's a great catch - especially because my default test would not have caught that. Thank you. ❤️

I'm going to add a test case specifically to catch this as well.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Hmm, seems like it's not that easy to test that without adding more if-this-is-a-test logic in the NewClient method. Let me know if the current tests look good or if I should do this anyway.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

yep, I can see that the only way to provoke an error is to break the URL. I think in this case we're fine :)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
allErrors = append(allErrors, fmt.Sprintf("%s:%s", conn.URN, err.Error()))
allErrors = append(allErrors, fmt.Sprintf("%s:%s", conn.URN, err.Error()))
continue

@indradhanush indradhanush force-pushed the ig/ado-validation-check branch from 70cf7b3 to 26f8c1c Compare March 2, 2023 09:03
@sourcegraph-bot

sourcegraph-bot commented Mar 2, 2023

Copy link
Copy Markdown
Contributor

Codenotify: Notifying subscribers in CODENOTIFY files for diff 5c25d9aeed959068c6cfb6edc9c2429bc2a44f72...26f8c1c63d7887cb4df9282414723c3c7d510f57.

Notify File(s)
@eseliger internal/extsvc/azuredevops/client.go
internal/extsvc/azuredevops/users.go
@unknwon enterprise/cmd/frontend/internal/auth/azureoauth/login.go
enterprise/cmd/frontend/internal/auth/azureoauth/provider.go
enterprise/cmd/frontend/internal/auth/azureoauth/session.go
enterprise/internal/authz/azuredevops/provider.go
enterprise/internal/authz/azuredevops/provider_test.go

@sashaostrikov sashaostrikov left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

:shipit::shipit::shipit:

Base automatically changed from ig/ado-user-perms-backup to main March 2, 2023 12:15
@indradhanush indradhanush force-pushed the ig/ado-validation-check branch from 26f8c1c to 77d8178 Compare March 2, 2023 12:23
@indradhanush indradhanush enabled auto-merge (squash) March 2, 2023 12:25
@indradhanush

Copy link
Copy Markdown
Contributor Author

Rebased off main after merging #48209. Had to force pushed. Nothing changed since the last review.

@indradhanush indradhanush merged commit a9becbb into main Mar 2, 2023
@indradhanush indradhanush deleted the ig/ado-validation-check branch March 2, 2023 12:39
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

ADO Tier 1 support for Azure DevOps cla-signed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants