Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@jtmcg
Copy link
Contributor

@jtmcg jtmcg commented Oct 14, 2024

Closes github/cli#577

Changes

  • Add test coverage to places where IsEnterprise incorrectly covers Tenancy
  • Upgrade go-gh to v2.11.0
  • Use go-gh/auth package for IsEnterprise, IsTenancy, and NormalizeHostname
  • auth: Removed redundant ghauth.IsTenancy(host) check

This adds test coverage to ensure orthogonality between IsEnterprise and IsTenancy functionality, then imports the functions from go-gh to fix the tests. There's some additional cleanup beyond this as well. See the commit messages for more details.

Testing

  1. Pull down branch gh pr checkout 9755
  2. Run all tests
  3. Login and logout with a tenancy stamp to verify the flow is working: gh auth login -h <tenancy-instance>
  4. Login and logout of a server stamp to verify the flow is working: gh auth login -h <server-instance>

@jtmcg jtmcg force-pushed the jtmcg/577 branch 2 times, most recently from feea80b to 66d5dd3 Compare October 14, 2024 21:11
@jtmcg jtmcg marked this pull request as ready for review October 14, 2024 21:23
@jtmcg jtmcg requested review from a team as code owners October 14, 2024 21:23
@jtmcg jtmcg requested a review from williammartin October 14, 2024 21:23
@cliAutomation cliAutomation added the external pull request originating outside of the CLI core team label Oct 14, 2024
@jtmcg jtmcg removed the external pull request originating outside of the CLI core team label Oct 14, 2024
Copy link
Member

@andyfeller andyfeller left a comment

Choose a reason for hiding this comment

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

Feels good to get rid of this logic and standardized on a single reusable set of functions! Handful of nits but solid overall.

jtmcg added 4 commits October 15, 2024 11:56
…ancy

IsEnterprise currently returns `true` when `IsTenancy` returns true. We
prefer that this behavior is orthogonal. This commit adds failing tests to
the instances where IsEnterprise should not behave the same as IsTenancy.

These test cases are expected to pass with the inclusion of the coming
improvements to go-gh to handle the orthogonality of IsEnterprise and
IsTenancy.
Copy link
Member

@andyfeller andyfeller left a comment

Choose a reason for hiding this comment

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

lgtm! so glad this finally happened!

Copy link
Member

@williammartin williammartin left a comment

Choose a reason for hiding this comment

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

I think that these branches can probably be removed now:

// Once we change Tenancy to no longer be treated as Enterprise, this
// conditional can be removed as the flow will fall through to the bottom.
// However, we can't do that until we've investigated all places in which
// Tenancy is currently treated as Enterprise.
if ghauth.IsTenancy(hostname) {
return fmt.Sprintf("https://api.%s/graphql", hostname)
}

// Once we change Tenancy to no longer be treated as Enterprise, this
// conditional can be removed as the flow will fall through to the bottom.
// However, we can't do that until we've investigated all places in which
// Tenancy is currently treated as Enterprise.
if ghauth.IsTenancy(hostname) {
return fmt.Sprintf("https://api.%s/", hostname)
}

Left a couple of comments for you to consider but otherwise LGTM thanks.

@jtmcg
Copy link
Contributor Author

jtmcg commented Oct 15, 2024

I think that these branches can probably be removed now:

Thanks for the callout, @williammartin. I've removed them 🙌

Copy link
Contributor

@phillmv phillmv left a comment

Choose a reason for hiding this comment

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

Seems straightforward for the parts @cli/package-security owns.

@jtmcg jtmcg merged commit b98c840 into trunk Oct 15, 2024
@jtmcg jtmcg deleted the jtmcg/577 branch October 15, 2024 21:09
tmeijn pushed a commit to tmeijn/dotfiles that referenced this pull request Oct 17, 2024
This MR contains the following updates:

| Package | Update | Change |
|---|---|---|
| [cli/cli](https://github.com/cli/cli) | minor | `v2.58.0` -> `v2.59.0` |

MR created with the help of [el-capitano/tools/renovate-bot](https://gitlab.com/el-capitano/tools/renovate-bot).

**Proposed changes to behavior should be submitted there as MRs.**

---

### Release Notes

<details>
<summary>cli/cli (cli/cli)</summary>

### [`v2.59.0`](https://github.com/cli/cli/releases/tag/v2.59.0): GitHub CLI 2.59.0

[Compare Source](cli/cli@v2.58.0...v2.59.0)

#### What's Changed

-   Allow community submitted design work by [@&#8203;BagToad](https://github.com/BagToad) in cli/cli#9683
-   Improve `SECURITY.md` with expectations for privately reported vulnerabilities by [@&#8203;BagToad](https://github.com/BagToad) in cli/cli#9687
-   Emit a log message when extension installation falls back to a `darwin-amd64` binary on an Apple Silicon macOS device by [@&#8203;timrogers](https://github.com/timrogers) in cli/cli#9650
-   Print the login URL even when opening a browser by [@&#8203;ulfjack](https://github.com/ulfjack) in cli/cli#7091
-   configurable maxwidth for markdown WithWrap() by [@&#8203;smemsh](https://github.com/smemsh) in cli/cli#9626
-   Handle errors when parsing hostname in auth flow by [@&#8203;BagToad](https://github.com/BagToad) in cli/cli#9729
-   Add `repo license list/view` and `repo gitignore list/view` by [@&#8203;BagToad](https://github.com/BagToad) in cli/cli#9721
-   Introduce testscript acceptance tests generally, and for the MR command specifically by [@&#8203;williammartin](https://github.com/williammartin) in cli/cli#9745
-   Support `GH_ACCEPTANCE_SCRIPT` env var to target a single script by [@&#8203;williammartin](https://github.com/williammartin) in cli/cli#9756
-   Ensure Acceptance defer failures are debuggable by [@&#8203;williammartin](https://github.com/williammartin) in cli/cli#9754
-   Add acceptance task to makefile by [@&#8203;williammartin](https://github.com/williammartin) in cli/cli#9748
-   Add Acceptance tests for `issue` command by [@&#8203;williammartin](https://github.com/williammartin) in cli/cli#9757
-   Update IsEnterprise and IsTenancy for orthogonality using go-gh by [@&#8203;jtmcg](https://github.com/jtmcg) in cli/cli#9755
-   Supporting filtering on `gist list` by [@&#8203;heaths](https://github.com/heaths) in cli/cli#9728

#### New Contributors

-   [@&#8203;ulfjack](https://github.com/ulfjack) made their first contribution in cli/cli#7091
-   [@&#8203;smemsh](https://github.com/smemsh) made their first contribution in cli/cli#9626

**Full Changelog**: cli/cli@v2.58.0...v2.59.0

</details>

---

### Configuration

📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined).

🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied.

♻ **Rebasing**: Whenever MR becomes conflicted, or you tick the rebase/retry checkbox.

🔕 **Ignore**: Close this MR and you won't be reminded about this update again.

---

 - [ ] <!-- rebase-check -->If you want to rebase/retry this MR, check this box

---

This MR has been generated by [Renovate Bot](https://github.com/renovatebot/renovate).
<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNy40NDAuNyIsInVwZGF0ZWRJblZlciI6IjM3LjQ0MC43IiwidGFyZ2V0QnJhbmNoIjoibWFpbiIsImxhYmVscyI6WyJSZW5vdmF0ZSBCb3QiXX0=-->
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.

6 participants