Skip to content

Commit 51b6b0a

Browse files
heiskrCopilot
andauthored
Article API: simplify GitHub Apps permissions token indicators (#60075)
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent fe1e7ae commit 51b6b0a

File tree

2 files changed

+23
-19
lines changed

2 files changed

+23
-19
lines changed

src/article-api/tests/github-apps-transformer.ts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -164,9 +164,12 @@ describe('GitHub Apps transformer', () => {
164164
const res = await get(makeURL('/en/rest/authentication/permissions-required-for-github-apps'))
165165
expect(res.statusCode).toBe(200)
166166

167-
// Check for IAT and UAT links in Tokens column
168-
expect(res.body).toMatch(/\[IAT\]\(\/en\/apps\/creating-github-apps\//)
169-
expect(res.body).toMatch(/\[UAT\]\(\/en\/apps\/creating-github-apps\//)
167+
// Check for legend
168+
expect(res.body).toContain('UAT = user access token')
169+
expect(res.body).toContain('IAT = installation access token')
170+
171+
// Check that token types appear in actual table rows (not just the legend)
172+
expect(res.body).toMatch(/\|\s*(?:UAT|IAT|UAT, IAT|None)\s*\|/)
170173
})
171174

172175
test('table shows additional permissions with checkmark/cross', async () => {
@@ -221,8 +224,6 @@ describe('GitHub Apps transformer', () => {
221224

222225
// Check that AUTOTITLE has been resolved
223226
expect(res.body).not.toContain('[AUTOTITLE]')
224-
// Should have actual link text
225-
expect(res.body).toMatch(/\[.*?\]\(\/en\/apps\//)
226227
})
227228

228229
test('API version parameter is supported', async () => {

src/article-api/transformers/github-apps-transformer.ts

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -173,28 +173,31 @@ export class GithubAppsTransformer implements PageTransformer {
173173
introMarkdown += `${templateData.manualContent}\n\n`
174174
}
175175

176+
// Add token type legend (only for GitHub App permissions, not fine-grained PAT)
177+
if (pageType === 'server-to-server-permissions') {
178+
introMarkdown += `**Token types:** UAT = user access token, IAT = installation access token\n\n`
179+
}
180+
176181
// Build the tables manually
177182
let tablesMarkdown = ''
178183
for (const item of templateData.items as PreparedPermissionItem[]) {
179184
tablesMarkdown += `## ${item.displayTitle}\n\n`
180185
tablesMarkdown += '| Endpoint | Access | Tokens | Additional Permissions |\n'
181186
tablesMarkdown += '|----------|--------|--------|------------------------|\n'
182187

188+
const isFineGrainedPat = pageType === 'fine-grained-pat-permissions'
189+
183190
for (const perm of item.permissions) {
184-
const lang = context.currentLanguage || 'en'
185-
const version =
186-
context.currentVersion === 'free-pro-team@latest' ? '' : `${context.currentVersion}/`
187-
const endpoint = `[\`${perm.verb} ${perm.requestPath}\`](/${lang}/${version}rest/${perm.category}#${perm.slug})`
188-
189-
let tokens = ''
190-
if (perm.userToServer) {
191-
tokens += `[UAT](/${lang}/${version}apps/creating-github-apps/authenticating-with-a-github-app/authenticating-with-a-github-app-on-behalf-of-a-user)`
192-
}
193-
if (perm.userToServer && perm.serverToServer) {
194-
tokens += '<br>'
195-
}
196-
if (perm.serverToServer) {
197-
tokens += `[IAT](/${lang}/${version}apps/creating-github-apps/authenticating-with-a-github-app/authenticating-as-a-github-app-installation)`
191+
const endpoint = `\`${perm.verb} ${perm.requestPath}\``
192+
193+
let tokens: string
194+
if (isFineGrainedPat) {
195+
tokens = 'PAT'
196+
} else {
197+
const tokenParts: string[] = []
198+
if (perm.userToServer) tokenParts.push('UAT')
199+
if (perm.serverToServer) tokenParts.push('IAT')
200+
tokens = tokenParts.join(', ') || 'None'
198201
}
199202

200203
const additionalPerms = perm.additionalPermissions ? '✓' : '✗'

0 commit comments

Comments
 (0)