Skip to content

Commit

Permalink
Merge pull request #15 from github/handle-github-emu-usernames
Browse files Browse the repository at this point in the history
Handle GitHub EMU usernames
  • Loading branch information
GrantBirki authored Dec 2, 2023
2 parents 9d1a5c2 + 5a88cc3 commit fa10401
Show file tree
Hide file tree
Showing 7 changed files with 158 additions and 14 deletions.
22 changes: 22 additions & 0 deletions __tests__/functions/allowlist.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,17 @@ test('runs isAllowed checks and finds a valid admin via handle reference', async
)
})

test('runs isAllowed checks and finds a valid handle that is a GitHub EMU', async () => {
process.env.INPUT_ALLOWLIST = 'username_company'
const contextNoAdmin = {
actor: 'username_company'
}
expect(await isAllowed(contextNoAdmin)).toStrictEqual(true)
expect(debugMock).toHaveBeenCalledWith(
'username_company is an allowlisted operator via handle reference'
)
})

test('runs isAllowed checks and does not find a valid admin', async () => {
process.env.INPUT_ALLOWLIST = 'monalisa'
const contextNoAdmin = {
Expand All @@ -72,6 +83,17 @@ test('runs isAllowed checks and does not find a valid admin', async () => {
)
})

test('runs isAllowed checks and does not find a valid admin due to a bad GitHub handle', async () => {
process.env.INPUT_ALLOWLIST = 'mona%lisa-'
const contextNoAdmin = {
actor: 'mona%lisa-'
}
expect(await isAllowed(contextNoAdmin)).toStrictEqual(false)
expect(debugMock).toHaveBeenCalledWith(
'mona%lisa- is not a valid GitHub username... skipping allowlist check'
)
})

test('runs isAllowed checks and determines that all users are allowed because it is unset', async () => {
process.env.INPUT_ALLOWLIST = 'false'
expect(await isAllowed(context)).toStrictEqual(true)
Expand Down
12 changes: 6 additions & 6 deletions dist/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/index.js.map

Large diffs are not rendered by default.

124 changes: 123 additions & 1 deletion dist/licenses.txt

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
"@actions/github": "^6.0.0",
"@octokit/plugin-retry": "^6.0.1",
"dedent-js": "^1.0.1",
"github-username-regex": "^1.0.0"
"github-username-regex-js": "^1.0.0"
},
"jest": {
"coverageReporters": [
Expand Down
2 changes: 1 addition & 1 deletion src/functions/allowlist.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import * as core from '@actions/core'
import * as github from '@actions/github'
import githubUsernameRegex from 'github-username-regex'
import githubUsernameRegex from 'github-username-regex-js'

// Helper function to check if a user exists in an org team
// :param actor: The user to check
Expand Down

0 comments on commit fa10401

Please sign in to comment.