2.3 KiB
Testing GitHub app auth
Step 1: Create and install a dummy GitHub app for testing with
Go to https://github.com/settings/apps/new
- Enter a name for the app (needs to be unique across GitHub).
- Set the required
homepage URLfield (can be any valid URL). - Under
Webhook, uncheck theActivecheckbox. - Click on
Repository permissionsunderPermissions, and setContentstoRead-only - Click on
Create GitHub Appat the bottom of the page. - You should be navigated to a new page with a
Registration successful. You must generate a private key in order to install your GitHub App.message. Click on thegenerate a private keylink, and then theGenerate a private keybutton, and save it somewhere; it will be used to test the app authentication. - Click on the
Install Apptab on the left, and then click onInstallon the right. - Select
Only select repositories, and pick any private repository that contains a "LICENSE" file (may need to be created beforehand).
Step 2: Export the necessary environment variables
The following environment variables are required to run the git-sync GitHub app auth tests:
TEST_GITHUB_APP_PRIVATE_KEYorTEST_GITHUB_APP_PRIVATE_KEY_FILE. If both are set,TEST_GITHUB_APP_PRIVATE_KEYoverwritesTEST_GITHUB_APP_PRIVATE_KEY_FILE.TEST_GITHUB_APP_APPLICATION_IDTEST_GITHUB_APP_CLIENT_IDTEST_GITHUB_APP_INSTALLATION_IDTEST_GITHUB_APP_AUTH_TEST_REPO
TEST_GITHUB_APP_PRIVATE_KEY
The content of the GitHub app's private key file. It should have been saved when creating the app.
If TEST_GITHUB_APP_PRIVATE_KEY_FILE is also set, it overwrites the file with the content.
Otherwise, it saves the content to /tmp/git-sync-e2e.random-id/github_app_private_key.pem.
TEST_GITHUB_APP_PRIVATE_KEY_FILE
The absolute path to the file that stores the GitHub app's private key file. It should have been saved when creating the app.
TEST_GITHUB_APP_APPLICATION_ID
The value after "App ID" in the app's settings page.
TEST_GITHUB_APP_CLIENT_ID
The value after "Client ID" in the app's settings page.
TEST_GITHUB_APP_INSTALLATION_ID
Found in the URL of the app's installation page if you installed it to a repository: https://github.com/settings/installations/<installation_id>
TEST_GITHUB_APP_AUTH_TEST_REPO.
Should be set to the repository that the GitHub app is installed to.