Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Arc-1455 server url to app creation #1312

Merged
merged 62 commits into from
Jul 5, 2022

Conversation

rachellerathbone
Copy link
Contributor

@rachellerathbone rachellerathbone commented Jun 29, 2022

Rationale:
Continuing task of wiring up the UI screens. This PR focuses on navigating from the GHE server URL screen to the app creation screen.

Changes:

  • Added 2 new routes: JiraVerifyServerUrlRouter to handle routing a post request (JiraVerifyServerUrlPost) to validate the passed url is a valid url, check the db for existing apps and verify we can hit the provided url. JiraAppCreationRouter handles the get request after the validation passes.
  • New JiraVerifyServerUrlPost middleware which takes in the provided url and makes a simple get request to check that we ping the provided url. If customers have opened a hole in their firewall, we should get a successful response back, otherwise, it will fail.
  • From here, we either navigate to the app creation page or render the list of GH apps (this part of the flow is yet to be implemented). https://github.com/atlassian/github-for-jira/pull/1312/files#r909455400
  • New module in connect and updated snapshots of the connect object.
  • Modifications to static/js/jira-server-url.js to handle making requests to our new route.
  • What's not included: styling clean-up. There's a noticeable size difference in the containers between these 2 views but we can clean this up later on.

Demo:
Like the last 2 PRs, the new path is hidden behind a FF.

With FF set to false we still navigate from the config screen to the connect an org screen:

176094892-a9aea163-eca0-493c-8365-111f24b6ae07.mov

With the FF set to true (done manually on my local for demo purposes only) we can navigate from the config page to the server url screen. In the scenario where I have 'opened a hole in the firewall' (aka connected to the VPN) and I have no existing GH apps, I'm navigated to the auto/manual app creation page.

Screen.Recording.2022-06-29.at.8.23.33.pm.mov

If I do have existing apps, instead of being navigated to /github-app-creation-page I'll be navigated to github-list-apps-page (the view and the module for this don't exist yet so it renders nothing and the error flag pops up but not the path)

Screen.Recording.2022-06-29.at.8.27.51.pm.mov

If we can't verify the url, we'll render an error (this component hasn't been created yet but note the response in my terminal ). For demo purposes, I'm disconnected from my VPN for this one.

Screen.Recording.2022-06-29.at.8.31.10.pm.mov

To test locally:
In src/routes/jira/configuration/jira-configuration-get.ts change the value from false to true for the FF check for handleNavigationClassName. You will be able to test these changes again once this has been deployed to prod as the FF is on for our segment 🎉

What's up next:
In ARC 1456 I'll be implementing the auto app creation flow, saving the data from the response to the db, and wrapping out the first-time install flow. I'm going to tackle a couple of clean-up items and some documentation so I can give this bad boy a chance to get approved and merged so I stop branching off my previous branch and blowing out my commit history 🙃

Also ARC 1473 to map errors when the verify server post fails and rendering the error in the UI.

@rachellerathbone rachellerathbone marked this pull request as ready for review July 4, 2022 06:44
@rachellerathbone rachellerathbone force-pushed the ARC-1455-server-url-to-app-creation branch from 77c88a6 to 669b3c6 Compare July 4, 2022 07:21
@rachellerathbone rachellerathbone force-pushed the ARC-1455-server-url-to-app-creation branch from bb11730 to 06755cc Compare July 4, 2022 07:35
@rachellerathbone rachellerathbone force-pushed the ARC-1455-server-url-to-app-creation branch 2 times, most recently from a95a720 to a3be4b5 Compare July 4, 2022 10:50
@@ -176,6 +154,16 @@ describe("await jirahostMiddleware", () => {
req.cookies.jwt = TEST_JWT_TOKEN;
});

it("cookie should have priority", async () => {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Moved this down to make sure this test runs when req.method is GET

@rachellerathbone rachellerathbone force-pushed the ARC-1455-server-url-to-app-creation branch from b97fe6b to aaa6133 Compare July 4, 2022 10:53
@rachellerathbone rachellerathbone force-pushed the ARC-1455-server-url-to-app-creation branch from bb9f0d4 to 5f59dd2 Compare July 4, 2022 11:14
@@ -147,17 +147,6 @@ describe("await jirahostMiddleware", () => {
expect(next).not.toBeCalled();
});

it("should not be validated and used when wrong URL", async ()=>{
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Removing this because it's no longer relevant since I changed the second conditional check in extractUnsafeJiraHost


const extractUnsafeJiraHost = (req: Request): string | null => {
if (moduleUrls.includes(req.path) && req.method == "GET") {
// Only save xdm_e query when on the GET post install url (iframe url)
return req.query.xdm_e as string;
} else if ((req.path == postInstallUrl && req.method != "GET") || req.path == "/jira/sync") {
// Only save the jiraHost from the body for specific routes that use it
} else if (["POST", "DELETE", "PUT"].includes(req.method)) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Now that we are/will be making POST/DELETE/PUT requests outside of the GH config page and outside of the /jira/sync route, modified this second conditional the return the jirahost from req.body for any POST/DELETE/PUT req.

}
} catch (err) {
req.log.debug(`Something went wrong: ${gheServerURL}`, err);
// TODO - adding error mapping (create confluence page with error codes)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Already started page and wokring on ARC-1473

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.

None yet

4 participants