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

Fix GitHub basic token auth, upgrade GitHub API module, allow test suite to execute. #319

Merged
merged 19 commits into from
Dec 11, 2019

Conversation

alexwaibel
Copy link
Collaborator

@alexwaibel alexwaibel commented Nov 10, 2019

This is a step towards fixing #318 and though I haven't fixed the related test cases I figured it would be good to get this up here so others can start reviewing it.

I've bumped dev to the latest version of master. Most of these changes lie in Github.js and aim to simplify the authentication flow. I've preserved the version information which some other PRs have reverted.

From your previous commits @eduardoboucas , I believe the versioning intention to be:
V2 API: To be used with Github personal token authentication only
V3 API: To support Github bot authentication only

Can you confirm this?

Additionally, I've fixed the style warnings that were stopping the unit tests from running. I haven't yet fixed the unit tests for the GitHub library but I plan to before we merge this into master.

For a demonstration you can visit my test site, which should be working unless I change it to test something else.
That site is running this config and you can view the PRs it makes in that same repo.

@alexwaibel alexwaibel added needs docs Signifies that the issue requests a documentation update. in development Signifies that the issue is actively being worked on. labels Nov 10, 2019
Get the remainder of the GitHub libarary unit tests in
passing state. Should rewrite more of the tests to use
Nock rather than mocking the module with Jest at some
point in the future.

Bump Nock to latest version.

Use correct key import per RSA documentation

Enable logging. Use V2 requests for most of tests
@alexwaibel
Copy link
Collaborator Author

alexwaibel commented Nov 11, 2019

Ok, I got the unit test failures down from ~70 to a more manageable 20. I switched some of the GitHub tests to nock, though I think it would be good to switch all of those tests specifically to nock in the future as a backlog item. I know that makes it less of a unit test in the strict sense, but I think it's more useful to test that we're hitting the right github endpoints rather than that we're hitting the right api module methods..

@alexwaibel
Copy link
Collaborator Author

Alright, GitHub library is completely rewritten to use Nock. While I was at it, I converted the whole thing to ES6, with the exception of the imports which Jest didn't like as ES6.

@eduardoboucas
Copy link
Owner

From your previous commits @eduardoboucas , I believe the versioning intention to be:
V2 API: To be used with Github personal token authentication only
V3 API: To support Github bot authentication only

Can you confirm this?

I believe V3 was meant to support both methods, but yes; that's the general idea.

Changes look great, thank you! Feel free to merge. 👏 💪

@alexwaibel
Copy link
Collaborator Author

Thanks for the review Eduardo. I'm going to investigate the app auth a bit more before merging this. Once I've finished that, I'd like to merge this into dev and then merge dev into master with some documentation updates.

@eduardoboucas
Copy link
Owner

Sounds great!

@deadlydog
Copy link
Contributor

I'm so happy to see this repo/project getting some much needed love again. Thanks guys!

Instructions for creating a private instance hosted on the free tier of
Heroku have been added and all references to the public instance have
been removed. Heroku hosting is intended to provide users with a more
reliable alternative to the public instance, which we will be dropping
support for.

Many changes had to be made to enable authentication as a GitHub
application. This required a lot of methods to become async.
@alexwaibel
Copy link
Collaborator Author

Alright @eduardoboucas I think I have this in a state I would be comfortable merging into dev and master after another review since I made a lot of changes with my most recent commit. I've fixed GitHub app integration, which required a lot of async conversion.

I've updated the README to include instructions on Heroku deployment and removed all references to the public instance. I think it's best to stop recommending the public instance, but continue to leave it running as-is to avoid breaking anyone's implementations. Self-hosting on Heroku is free and very easy so this should provide an appropriate alternative.

@alexwaibel
Copy link
Collaborator Author

Resolves #317 and #318

Copy link
Owner

@eduardoboucas eduardoboucas left a comment

Choose a reason for hiding this comment

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

This looks great, thank you!

I added just a question and a nitpick suggestion. Great work. 💪

controllers/connect.js Outdated Show resolved Hide resolved
lib/Staticman.js Show resolved Hide resolved
@alexwaibel alexwaibel removed in development Signifies that the issue is actively being worked on. needs docs Signifies that the issue requests a documentation update. labels Dec 11, 2019
@jayliu50
Copy link

jayliu50 commented May 25, 2020

The v3 endpoint for connect is missing because of this fix. Without this, it doesn't connect to GitLab.

Can this be restored, please?

See changes made to server.js: https://github.com/eduardoboucas/staticman/pull/219/files#diff-78c12f5adc1848d13b1c6f07055d996e

Please LMK if I'm missing something. New to the project. Thanks for all your work!

@alexwaibel
Copy link
Collaborator Author

The v3 endpoint for connect is missing because of this fix. Without this, it doesn't connect to GitLab.

@jayliu50 I've been a bit swamped with other projects lately, but I'd happily accept a PR for a fix. I don't have time right now to dig too deep into this. I never got around to trying this out with GitLab, but it seems to me that GitLab never used the connect endpoint. If you look at the PR you linked, in connect.js the logic appears to only fetch GitHub tokens from the config. Additionally the endpoint you reference requires the service in the route to be github.

I believe @VincentTam worked with the GitLab parts of this project a lot. Vincent, do you have any insight here?

@VincentTam
Copy link
Contributor

My work mainly consists in testing the linked PR. Yeah GitLab doesn't use the /connect endpoint, as the PR says.

GitLab does not have collaborator invites, so this is currently not required for Staticman to collaborate on a project. The user can just add Staticman immediately.
Other changes

@VincentTam
Copy link
Contributor

From your previous commits @eduardoboucas , I believe the versioning intention to be:
V2 API: To be used with Github personal token authentication only
V3 API: To support Github bot authentication only

Can you confirm this?

I believe V3 was meant to support both methods, but yes; that's the general idea.

It seems that the connect route is only associately to versions 1 & 2.

staticman/server.js

Lines 48 to 54 in 5d7ed77

// Route: connect
this.server.get(
'/v:version/connect/:username/:repository',
this.bruteforce.prevent,
this.requireApiVersion([1, 2]),
this.controllers.connect
)

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

5 participants