fix(oauth): separate implicit token scopes from explicit permission requests
This commit is contained in:
@@ -616,3 +616,23 @@ def test_permission_failed_restart_restores_overlay_and_plan(scenario,monkeypatc
|
||||
with pytest.raises(deploy.DeployError,match='restored'):deploy.update_permissions(scenario['output'],plan,scenario['profiles'],True)
|
||||
assert calls[0]==2
|
||||
for name,value in before.items():assert json.loads((scenario['output']/name).read_text())==json.loads(value)
|
||||
|
||||
|
||||
def test_permission_removal_requires_exact_explicit_scope_and_is_reviewed(scenario,monkeypatch,capsys):
|
||||
plan=permission_scenario(scenario,monkeypatch)
|
||||
# Existing synthetic profile has only read; replacing it must be explicit.
|
||||
scenario['profiles'].write_text(json.dumps({'product-v1':['wiki:wiki']}))
|
||||
with pytest.raises(deploy.DeployError,match='exact'):
|
||||
deploy.update_permissions(scenario['output'],plan,scenario['profiles'],False,['other:scope'])
|
||||
deploy.update_permissions(scenario['output'],plan,scenario['profiles'],False,['read'])
|
||||
assert 'Product scope removals' in capsys.readouterr().out
|
||||
assert not any('up' in c for c in scenario['calls'])
|
||||
deploy.update_permissions(scenario['output'],plan,scenario['profiles'],True,['read'])
|
||||
scopes=json.loads(json.loads((scenario['output']/'compose.broker.json').read_text())['services']['connector']['environment']['HN_CREDENTIAL_PERMISSION_PROFILES'])
|
||||
assert scopes=={'product-v1':['wiki:wiki']}
|
||||
|
||||
|
||||
def test_product_explicit_request_does_not_copy_implicit_token_scope():
|
||||
scopes=json.loads((ROOT/'examples/work-product-profiles.expanded.json').read_text())['current-config-v1']
|
||||
assert 'auth:user.id:read' not in scopes
|
||||
assert {'drive:drive','wiki:wiki','calendar:calendar'}<=set(scopes)
|
||||
|
||||
Reference in New Issue
Block a user