Skip to content

Commit fa10401

Browse files
authored
Merge pull request #15 from github/handle-github-emu-usernames
Handle GitHub EMU usernames
2 parents 9d1a5c2 + 5a88cc3 commit fa10401

File tree

7 files changed

+158
-14
lines changed

7 files changed

+158
-14
lines changed

__tests__/functions/allowlist.test.js

+22
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,17 @@ test('runs isAllowed checks and finds a valid admin via handle reference', async
6161
)
6262
})
6363

64+
test('runs isAllowed checks and finds a valid handle that is a GitHub EMU', async () => {
65+
process.env.INPUT_ALLOWLIST = 'username_company'
66+
const contextNoAdmin = {
67+
actor: 'username_company'
68+
}
69+
expect(await isAllowed(contextNoAdmin)).toStrictEqual(true)
70+
expect(debugMock).toHaveBeenCalledWith(
71+
'username_company is an allowlisted operator via handle reference'
72+
)
73+
})
74+
6475
test('runs isAllowed checks and does not find a valid admin', async () => {
6576
process.env.INPUT_ALLOWLIST = 'monalisa'
6677
const contextNoAdmin = {
@@ -72,6 +83,17 @@ test('runs isAllowed checks and does not find a valid admin', async () => {
7283
)
7384
})
7485

86+
test('runs isAllowed checks and does not find a valid admin due to a bad GitHub handle', async () => {
87+
process.env.INPUT_ALLOWLIST = 'mona%lisa-'
88+
const contextNoAdmin = {
89+
actor: 'mona%lisa-'
90+
}
91+
expect(await isAllowed(contextNoAdmin)).toStrictEqual(false)
92+
expect(debugMock).toHaveBeenCalledWith(
93+
'mona%lisa- is not a valid GitHub username... skipping allowlist check'
94+
)
95+
})
96+
7597
test('runs isAllowed checks and determines that all users are allowed because it is unset', async () => {
7698
process.env.INPUT_ALLOWLIST = 'false'
7799
expect(await isAllowed(context)).toStrictEqual(true)

dist/index.js

+6-6
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/index.js.map

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/licenses.txt

+123-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package-lock.json

+4-4
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
"@actions/github": "^6.0.0",
3131
"@octokit/plugin-retry": "^6.0.1",
3232
"dedent-js": "^1.0.1",
33-
"github-username-regex": "^1.0.0"
33+
"github-username-regex-js": "^1.0.0"
3434
},
3535
"jest": {
3636
"coverageReporters": [

src/functions/allowlist.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import * as core from '@actions/core'
22
import * as github from '@actions/github'
3-
import githubUsernameRegex from 'github-username-regex'
3+
import githubUsernameRegex from 'github-username-regex-js'
44

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

0 commit comments

Comments
 (0)