imbi-plugin-github 2.58.0__tar.gz → 2.60.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {imbi_plugin_github-2.58.0 → imbi_plugin_github-2.60.0}/PKG-INFO +2 -2
- {imbi_plugin_github-2.58.0 → imbi_plugin_github-2.60.0}/pyproject.toml +2 -2
- {imbi_plugin_github-2.58.0 → imbi_plugin_github-2.60.0}/src/imbi/plugins/github/secret_provider.py +6 -3
- {imbi_plugin_github-2.58.0 → imbi_plugin_github-2.60.0}/tests/test_commits.py +10 -15
- {imbi_plugin_github-2.58.0 → imbi_plugin_github-2.60.0}/tests/test_lifecycle.py +12 -9
- {imbi_plugin_github-2.58.0 → imbi_plugin_github-2.60.0}/tests/test_secret_provider.py +40 -0
- {imbi_plugin_github-2.58.0 → imbi_plugin_github-2.60.0}/.gitignore +0 -0
- {imbi_plugin_github-2.58.0 → imbi_plugin_github-2.60.0}/README.md +0 -0
- {imbi_plugin_github-2.58.0 → imbi_plugin_github-2.60.0}/moon.yml +0 -0
- {imbi_plugin_github-2.58.0 → imbi_plugin_github-2.60.0}/src/imbi/plugins/github/README.md +0 -0
- {imbi_plugin_github-2.58.0 → imbi_plugin_github-2.60.0}/src/imbi/plugins/github/__init__.py +0 -0
- {imbi_plugin_github-2.58.0 → imbi_plugin_github-2.60.0}/src/imbi/plugins/github/_app_auth.py +0 -0
- {imbi_plugin_github-2.58.0 → imbi_plugin_github-2.60.0}/src/imbi/plugins/github/_hosts.py +0 -0
- {imbi_plugin_github-2.58.0 → imbi_plugin_github-2.60.0}/src/imbi/plugins/github/_repos.py +0 -0
- {imbi_plugin_github-2.58.0 → imbi_plugin_github-2.60.0}/src/imbi/plugins/github/commits.py +0 -0
- {imbi_plugin_github-2.58.0 → imbi_plugin_github-2.60.0}/src/imbi/plugins/github/deployment.py +0 -0
- {imbi_plugin_github-2.58.0 → imbi_plugin_github-2.60.0}/src/imbi/plugins/github/doctor.py +0 -0
- {imbi_plugin_github-2.58.0 → imbi_plugin_github-2.60.0}/src/imbi/plugins/github/identity.py +0 -0
- {imbi_plugin_github-2.58.0 → imbi_plugin_github-2.60.0}/src/imbi/plugins/github/lifecycle.py +0 -0
- {imbi_plugin_github-2.58.0 → imbi_plugin_github-2.60.0}/src/imbi/plugins/github/plugin.py +0 -0
- {imbi_plugin_github-2.58.0 → imbi_plugin_github-2.60.0}/src/imbi/plugins/github/public.py +0 -0
- {imbi_plugin_github-2.58.0 → imbi_plugin_github-2.60.0}/src/imbi/plugins/github/pull_requests.py +0 -0
- {imbi_plugin_github-2.58.0 → imbi_plugin_github-2.60.0}/src/imbi/plugins/github/py.typed +0 -0
- {imbi_plugin_github-2.58.0 → imbi_plugin_github-2.60.0}/tests/__init__.py +0 -0
- {imbi_plugin_github-2.58.0 → imbi_plugin_github-2.60.0}/tests/test_app_auth_scopes.py +0 -0
- {imbi_plugin_github-2.58.0 → imbi_plugin_github-2.60.0}/tests/test_deployment.py +0 -0
- {imbi_plugin_github-2.58.0 → imbi_plugin_github-2.60.0}/tests/test_doctor.py +0 -0
- {imbi_plugin_github-2.58.0 → imbi_plugin_github-2.60.0}/tests/test_hosts.py +0 -0
- {imbi_plugin_github-2.58.0 → imbi_plugin_github-2.60.0}/tests/test_identity.py +0 -0
- {imbi_plugin_github-2.58.0 → imbi_plugin_github-2.60.0}/tests/test_public.py +0 -0
- {imbi_plugin_github-2.58.0 → imbi_plugin_github-2.60.0}/tests/test_pull_requests.py +0 -0
- {imbi_plugin_github-2.58.0 → imbi_plugin_github-2.60.0}/tests/test_repos.py +0 -0
- {imbi_plugin_github-2.58.0 → imbi_plugin_github-2.60.0}/tests/test_secret_provider_live.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.5
|
|
2
2
|
Name: imbi-plugin-github
|
|
3
|
-
Version: 2.
|
|
3
|
+
Version: 2.60.0
|
|
4
4
|
Summary: GitHub identity plugin for Imbi (github.com / GHEC / GHES)
|
|
5
5
|
Author-email: "Gavin M. Roy" <gavinr@aweber.com>
|
|
6
6
|
License-Expression: BSD-3-Clause
|
|
@@ -12,7 +12,7 @@ Classifier: Programming Language :: Python :: 3
|
|
|
12
12
|
Classifier: Programming Language :: Python :: 3.14
|
|
13
13
|
Requires-Python: >=3.14
|
|
14
14
|
Requires-Dist: httpx>=0.27
|
|
15
|
-
Requires-Dist: imbi-common[databases]==2.
|
|
15
|
+
Requires-Dist: imbi-common[databases]==2.60.0
|
|
16
16
|
Requires-Dist: pydantic>=2
|
|
17
17
|
Requires-Dist: pyjwt[crypto]>=2.8
|
|
18
18
|
Description-Content-Type: text/markdown
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
[project]
|
|
2
2
|
name = "imbi-plugin-github"
|
|
3
|
-
version = "2.
|
|
3
|
+
version = "2.60.0"
|
|
4
4
|
description = "GitHub identity plugin for Imbi (github.com / GHEC / GHES)"
|
|
5
5
|
readme = "README.md"
|
|
6
6
|
requires-python = ">=3.14"
|
|
@@ -18,7 +18,7 @@ classifiers = [
|
|
|
18
18
|
]
|
|
19
19
|
dependencies = [
|
|
20
20
|
"httpx>=0.27",
|
|
21
|
-
"imbi-common[databases]==2.
|
|
21
|
+
"imbi-common[databases]==2.60.0",
|
|
22
22
|
"pydantic>=2",
|
|
23
23
|
"pyjwt[crypto]>=2.8",
|
|
24
24
|
]
|
{imbi_plugin_github-2.58.0 → imbi_plugin_github-2.60.0}/src/imbi/plugins/github/secret_provider.py
RENAMED
|
@@ -76,15 +76,18 @@ PURPOSE_PERMISSIONS: dict[str, dict[str, str]] = {
|
|
|
76
76
|
},
|
|
77
77
|
}
|
|
78
78
|
|
|
79
|
-
#:
|
|
80
|
-
#:
|
|
81
|
-
#:
|
|
79
|
+
#: Permissions that a purpose adds when the installation grants them:
|
|
80
|
+
#: CI reads, so an agent can wait for and read checks, and for
|
|
81
|
+
#: ``github_write`` also ``workflows``, which GitHub requires to push a
|
|
82
|
+
#: change under ``.github/workflows/``. Asking for one the installation
|
|
83
|
+
#: lacks would make GitHub refuse the whole token (422).
|
|
82
84
|
PURPOSE_OPTIONAL_PERMISSIONS: dict[str, dict[str, str]] = {
|
|
83
85
|
'github_read': {'checks': 'read', 'statuses': 'read'},
|
|
84
86
|
'github_write': {
|
|
85
87
|
'actions': 'read',
|
|
86
88
|
'checks': 'read',
|
|
87
89
|
'statuses': 'read',
|
|
90
|
+
'workflows': 'write',
|
|
88
91
|
},
|
|
89
92
|
}
|
|
90
93
|
|
|
@@ -2553,9 +2553,8 @@ class RequestTestCase(unittest.IsolatedAsyncioTestCase):
|
|
|
2553
2553
|
httpx.Response(403, headers={'retry-after': '7'}),
|
|
2554
2554
|
httpx.Response(200, json={'ok': True}),
|
|
2555
2555
|
)
|
|
2556
|
-
|
|
2557
|
-
|
|
2558
|
-
) as slept:
|
|
2556
|
+
slept = mock.AsyncMock()
|
|
2557
|
+
with mock.patch.object(commits, 'asyncio', wraps=asyncio, sleep=slept):
|
|
2559
2558
|
resp = await commits._request(client, 'GET', '/x', max_wait=60.0)
|
|
2560
2559
|
self.assertEqual(200, resp.status_code)
|
|
2561
2560
|
slept.assert_awaited_once_with(7.0)
|
|
@@ -2573,9 +2572,8 @@ class RequestTestCase(unittest.IsolatedAsyncioTestCase):
|
|
|
2573
2572
|
json={'ok': True},
|
|
2574
2573
|
),
|
|
2575
2574
|
)
|
|
2576
|
-
|
|
2577
|
-
|
|
2578
|
-
) as slept:
|
|
2575
|
+
slept = mock.AsyncMock()
|
|
2576
|
+
with mock.patch.object(commits, 'asyncio', wraps=asyncio, sleep=slept):
|
|
2579
2577
|
resp = await commits._request(client, 'GET', '/x', max_wait=60.0)
|
|
2580
2578
|
self.assertEqual(200, resp.status_code)
|
|
2581
2579
|
slept.assert_awaited_once()
|
|
@@ -2593,9 +2591,8 @@ class RequestTestCase(unittest.IsolatedAsyncioTestCase):
|
|
|
2593
2591
|
},
|
|
2594
2592
|
),
|
|
2595
2593
|
)
|
|
2596
|
-
|
|
2597
|
-
|
|
2598
|
-
) as slept:
|
|
2594
|
+
slept = mock.AsyncMock()
|
|
2595
|
+
with mock.patch.object(commits, 'asyncio', wraps=asyncio, sleep=slept):
|
|
2599
2596
|
with self.assertRaises(PluginRateLimited) as caught:
|
|
2600
2597
|
await commits._request(client, 'GET', '/x', max_wait=60.0)
|
|
2601
2598
|
# Bails to the host without sleeping, carrying the resume time.
|
|
@@ -2607,9 +2604,8 @@ class RequestTestCase(unittest.IsolatedAsyncioTestCase):
|
|
|
2607
2604
|
client = self._client(
|
|
2608
2605
|
httpx.Response(429, headers={'retry-after': '1'})
|
|
2609
2606
|
)
|
|
2610
|
-
|
|
2611
|
-
|
|
2612
|
-
) as slept:
|
|
2607
|
+
slept = mock.AsyncMock()
|
|
2608
|
+
with mock.patch.object(commits, 'asyncio', wraps=asyncio, sleep=slept):
|
|
2613
2609
|
with self.assertRaises(PluginRateLimited):
|
|
2614
2610
|
await commits._request(client, 'GET', '/x', max_wait=60.0)
|
|
2615
2611
|
self.assertEqual(commits._MAX_THROTTLE_RETRIES, slept.await_count)
|
|
@@ -2631,9 +2627,8 @@ class SyncCommitsThrottleTestCase(unittest.IsolatedAsyncioTestCase):
|
|
|
2631
2627
|
httpx.Response(200, json={'commits': [_commit('1' * 40)]}),
|
|
2632
2628
|
]
|
|
2633
2629
|
)
|
|
2634
|
-
|
|
2635
|
-
|
|
2636
|
-
) as slept:
|
|
2630
|
+
slept = mock.AsyncMock()
|
|
2631
|
+
with mock.patch.object(commits, 'asyncio', wraps=asyncio, sleep=slept):
|
|
2637
2632
|
with mock.patch(_INSERT, new=mock.AsyncMock()) as insert:
|
|
2638
2633
|
await commits.sync_commits(
|
|
2639
2634
|
ctx=_ctx(),
|
|
@@ -267,8 +267,9 @@ class ArchiveTestCase(unittest.IsolatedAsyncioTestCase):
|
|
|
267
267
|
|
|
268
268
|
plugin = GitHubLifecycle()
|
|
269
269
|
with unittest.mock.patch(
|
|
270
|
-
'imbi.plugins.github.lifecycle.asyncio
|
|
271
|
-
|
|
270
|
+
'imbi.plugins.github.lifecycle.asyncio',
|
|
271
|
+
sleep=unittest.mock.AsyncMock(),
|
|
272
|
+
) as asyncio_mod:
|
|
272
273
|
result = await plugin.on_project_archived(
|
|
273
274
|
_ctx(options={'archive_target_org': 'octo-archive'}),
|
|
274
275
|
_CREDS,
|
|
@@ -277,7 +278,7 @@ class ArchiveTestCase(unittest.IsolatedAsyncioTestCase):
|
|
|
277
278
|
self.assertEqual(result.status, 'ok')
|
|
278
279
|
self.assertEqual(archive_route.calls.call_count, 3)
|
|
279
280
|
# Two failed attempts → two backoff sleeps before success.
|
|
280
|
-
self.assertEqual(sleep.await_count, 2)
|
|
281
|
+
self.assertEqual(asyncio_mod.sleep.await_count, 2)
|
|
281
282
|
|
|
282
283
|
@respx.mock
|
|
283
284
|
async def test_archive_transfer_exhausts_retries_on_persistent_404(
|
|
@@ -307,8 +308,9 @@ class ArchiveTestCase(unittest.IsolatedAsyncioTestCase):
|
|
|
307
308
|
|
|
308
309
|
plugin = GitHubLifecycle()
|
|
309
310
|
with unittest.mock.patch(
|
|
310
|
-
'imbi.plugins.github.lifecycle.asyncio
|
|
311
|
-
|
|
311
|
+
'imbi.plugins.github.lifecycle.asyncio',
|
|
312
|
+
sleep=unittest.mock.AsyncMock(),
|
|
313
|
+
) as asyncio_mod:
|
|
312
314
|
with self.assertRaises(httpx.HTTPStatusError):
|
|
313
315
|
await plugin.on_project_archived(
|
|
314
316
|
_ctx(options={'archive_target_org': 'octo-archive'}),
|
|
@@ -317,7 +319,7 @@ class ArchiveTestCase(unittest.IsolatedAsyncioTestCase):
|
|
|
317
319
|
|
|
318
320
|
# Three backoffs configured → four total attempts.
|
|
319
321
|
self.assertEqual(archive_route.calls.call_count, 4)
|
|
320
|
-
self.assertEqual(sleep.await_count, 3)
|
|
322
|
+
self.assertEqual(asyncio_mod.sleep.await_count, 3)
|
|
321
323
|
|
|
322
324
|
@respx.mock
|
|
323
325
|
async def test_archive_transfer_does_not_retry_non_404(self) -> None:
|
|
@@ -344,8 +346,9 @@ class ArchiveTestCase(unittest.IsolatedAsyncioTestCase):
|
|
|
344
346
|
|
|
345
347
|
plugin = GitHubLifecycle()
|
|
346
348
|
with unittest.mock.patch(
|
|
347
|
-
'imbi.plugins.github.lifecycle.asyncio
|
|
348
|
-
|
|
349
|
+
'imbi.plugins.github.lifecycle.asyncio',
|
|
350
|
+
sleep=unittest.mock.AsyncMock(),
|
|
351
|
+
) as asyncio_mod:
|
|
349
352
|
with self.assertRaises(httpx.HTTPStatusError):
|
|
350
353
|
await plugin.on_project_archived(
|
|
351
354
|
_ctx(options={'archive_target_org': 'octo-archive'}),
|
|
@@ -353,7 +356,7 @@ class ArchiveTestCase(unittest.IsolatedAsyncioTestCase):
|
|
|
353
356
|
)
|
|
354
357
|
|
|
355
358
|
self.assertEqual(archive_route.calls.call_count, 1)
|
|
356
|
-
self.assertEqual(sleep.await_count, 0)
|
|
359
|
+
self.assertEqual(asyncio_mod.sleep.await_count, 0)
|
|
357
360
|
|
|
358
361
|
@respx.mock
|
|
359
362
|
async def test_archive_transfer_when_already_archived(self) -> None:
|
|
@@ -447,6 +447,46 @@ class GitHubAppTestCase(unittest.IsolatedAsyncioTestCase):
|
|
|
447
447
|
},
|
|
448
448
|
)
|
|
449
449
|
|
|
450
|
+
@respx.mock
|
|
451
|
+
async def test_workflows_write_only_when_the_installation_grants_it(
|
|
452
|
+
self,
|
|
453
|
+
) -> None:
|
|
454
|
+
"""A write token can push workflow files when the App may."""
|
|
455
|
+
respx.get(INSTALLATION_URL).mock(
|
|
456
|
+
return_value=httpx.Response(
|
|
457
|
+
200,
|
|
458
|
+
json=INSTALLATION
|
|
459
|
+
| {
|
|
460
|
+
'permissions': {
|
|
461
|
+
'contents': 'write',
|
|
462
|
+
'workflows': 'write',
|
|
463
|
+
'metadata': 'read',
|
|
464
|
+
}
|
|
465
|
+
},
|
|
466
|
+
)
|
|
467
|
+
)
|
|
468
|
+
route = respx.post(TOKENS_URL).mock(
|
|
469
|
+
return_value=httpx.Response(
|
|
470
|
+
201,
|
|
471
|
+
json={'token': TOKEN, 'expires_at': '2099-01-01T00:00:00Z'},
|
|
472
|
+
)
|
|
473
|
+
)
|
|
474
|
+
await APP.resolve(CONFIG, LOCATOR, None, _context('github_write'))
|
|
475
|
+
self.assertEqual(
|
|
476
|
+
json.loads(route.calls.last.request.content)['permissions'],
|
|
477
|
+
{
|
|
478
|
+
'contents': 'write',
|
|
479
|
+
'issues': 'write',
|
|
480
|
+
'pull_requests': 'write',
|
|
481
|
+
'workflows': 'write',
|
|
482
|
+
},
|
|
483
|
+
)
|
|
484
|
+
await APP.resolve(CONFIG, LOCATOR, None, _context('github_read'))
|
|
485
|
+
self.assertNotIn(
|
|
486
|
+
'workflows',
|
|
487
|
+
json.loads(route.calls.last.request.content)['permissions'],
|
|
488
|
+
)
|
|
489
|
+
|
|
450
490
|
@respx.mock
|
|
451
491
|
async def test_disallowed_host_gets_no_jwt(self) -> None:
|
|
452
492
|
"""A host that left the allowlist after the provider was saved."""
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{imbi_plugin_github-2.58.0 → imbi_plugin_github-2.60.0}/src/imbi/plugins/github/_app_auth.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{imbi_plugin_github-2.58.0 → imbi_plugin_github-2.60.0}/src/imbi/plugins/github/deployment.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
{imbi_plugin_github-2.58.0 → imbi_plugin_github-2.60.0}/src/imbi/plugins/github/lifecycle.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
{imbi_plugin_github-2.58.0 → imbi_plugin_github-2.60.0}/src/imbi/plugins/github/pull_requests.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|