fix(webui): allow switching Default permissions back to Full Access (#6175)
* fix(webui): allow authenticated access mode switching * refactor(webui): remove constant full access eligibility helpers * refactor(webui): remove obsolete full access policy parameter * docs(webui): remove redundant access switching paragraph * refactor(webui): remove obsolete full access capability
This commit is contained in:
1 parent
ae186cb18d
commit
73af08efab
14 files changed
+87
-204
No files matched your search
@@ -36,7 +36,6 @@ def test_workspace_payload_is_config_data_dir_scoped(tmp_path, monkeypatch) -> N
|
||||
default_workspace=default,
|
||||
default_restrict_to_workspace=False,
|
||||
can_change_project=True,
|
||||
can_use_full_access=True,
|
||||
)
|
||||
|
||||
assert payload["default_scope"]["project_path"] == str(default.resolve())
|
||||
@@ -45,26 +44,6 @@ def test_workspace_payload_is_config_data_dir_scoped(tmp_path, monkeypatch) -> N
|
||||
assert payload["controls"]["can_change_project"] is True
|
||||
|
||||
|
||||
def test_workspace_payload_allows_remote_project_selection_without_full_access(
|
||||
tmp_path,
|
||||
monkeypatch,
|
||||
) -> None:
|
||||
monkeypatch.setattr("nanobot.webui.workspaces.get_webui_dir", lambda: tmp_path / "webui")
|
||||
default = tmp_path / "default"
|
||||
default.mkdir()
|
||||
|
||||
payload = workspaces_payload(
|
||||
default_workspace=default,
|
||||
default_restrict_to_workspace=False,
|
||||
can_change_project=True,
|
||||
can_use_full_access=False,
|
||||
)
|
||||
|
||||
assert payload["default_scope"]["project_path"] == str(default.resolve())
|
||||
assert payload["controls"]["can_change_project"] is True
|
||||
assert payload["controls"]["can_use_full_access"] is False
|
||||
|
||||
|
||||
def test_workspace_payload_hides_project_selection_when_unavailable(
|
||||
tmp_path,
|
||||
monkeypatch,
|
||||
@@ -77,11 +56,9 @@ def test_workspace_payload_hides_project_selection_when_unavailable(
|
||||
default_workspace=default,
|
||||
default_restrict_to_workspace=False,
|
||||
can_change_project=False,
|
||||
can_use_full_access=False,
|
||||
)
|
||||
|
||||
assert payload["controls"]["can_change_project"] is False
|
||||
assert payload["controls"]["can_use_full_access"] is False
|
||||
|
||||
|
||||
def test_workspace_payload_uses_webui_default_access_mode(tmp_path, monkeypatch) -> None:
|
||||
@@ -96,7 +73,6 @@ def test_workspace_payload_uses_webui_default_access_mode(tmp_path, monkeypatch)
|
||||
default_workspace=default,
|
||||
default_restrict_to_workspace=True,
|
||||
can_change_project=True,
|
||||
can_use_full_access=True,
|
||||
)
|
||||
|
||||
assert payload["default_access_mode"] == "full"
|
||||
@@ -128,7 +104,6 @@ def test_webui_default_access_applies_to_unscoped_old_sessions(tmp_path, monkeyp
|
||||
new_scope = controller.scope_for_new_chat(
|
||||
{},
|
||||
can_change_project=True,
|
||||
can_use_full_access=True,
|
||||
)
|
||||
|
||||
assert scope.project_path == default.resolve()
|
||||
@@ -311,7 +286,6 @@ def test_remote_existing_chat_can_reduce_its_workspace_access(tmp_path, monkeypa
|
||||
chat_id="remote-chat",
|
||||
chat_running=False,
|
||||
can_change_project=True,
|
||||
can_use_full_access=False,
|
||||
)
|
||||
|
||||
assert scope.project_path == project.resolve()
|
||||
@@ -319,21 +293,20 @@ def test_remote_existing_chat_can_reduce_its_workspace_access(tmp_path, monkeypa
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
("default_restricted", "project_name", "access_mode", "allowed"),
|
||||
("default_restricted", "project_name", "access_mode"),
|
||||
[
|
||||
(False, "default", "restricted", True),
|
||||
(True, "default", "full", False),
|
||||
(False, "other", "restricted", True),
|
||||
(False, "other", "full", False),
|
||||
(False, "default", "restricted"),
|
||||
(True, "default", "full"),
|
||||
(False, "other", "restricted"),
|
||||
(False, "other", "full"),
|
||||
],
|
||||
)
|
||||
def test_remote_new_chat_allows_project_selection_only_in_restricted_mode(
|
||||
def test_new_chat_allows_project_selection_in_either_access_mode(
|
||||
tmp_path,
|
||||
monkeypatch,
|
||||
default_restricted: bool,
|
||||
project_name: str,
|
||||
access_mode: str,
|
||||
allowed: bool,
|
||||
) -> None:
|
||||
monkeypatch.setattr("nanobot.webui.workspaces.get_webui_dir", lambda: tmp_path / "webui")
|
||||
default = tmp_path / "default"
|
||||
@@ -347,28 +320,17 @@ def test_remote_new_chat_allows_project_selection_only_in_restricted_mode(
|
||||
)
|
||||
requested_path = tmp_path / project_name
|
||||
|
||||
def resolve():
|
||||
return controller.scope_for_new_chat(
|
||||
{
|
||||
"workspace_scope": {
|
||||
"project_path": str(requested_path),
|
||||
"access_mode": access_mode,
|
||||
}
|
||||
},
|
||||
can_change_project=True,
|
||||
can_use_full_access=False,
|
||||
)
|
||||
|
||||
if allowed:
|
||||
scope = resolve()
|
||||
assert scope.project_path == requested_path.resolve()
|
||||
assert scope.access_mode == access_mode
|
||||
else:
|
||||
with pytest.raises(
|
||||
WorkspaceScopeError,
|
||||
match="full workspace access is unavailable for this connection",
|
||||
):
|
||||
resolve()
|
||||
scope = controller.scope_for_new_chat(
|
||||
{
|
||||
"workspace_scope": {
|
||||
"project_path": str(requested_path),
|
||||
"access_mode": access_mode,
|
||||
}
|
||||
},
|
||||
can_change_project=True,
|
||||
)
|
||||
assert scope.project_path == requested_path.resolve()
|
||||
assert scope.access_mode == access_mode
|
||||
|
||||
|
||||
def test_project_selection_can_remain_disabled_for_untrusted_connections(
|
||||
@@ -398,7 +360,6 @@ def test_project_selection_can_remain_disabled_for_untrusted_connections(
|
||||
}
|
||||
},
|
||||
can_change_project=False,
|
||||
can_use_full_access=False,
|
||||
)
|
||||
|
||||
|
||||
@@ -413,14 +374,14 @@ def test_recent_projects_survive_controller_restart_without_changing_access(tmp_
|
||||
)
|
||||
scope = controller.scope_for_new_chat(
|
||||
{WORKSPACE_SCOPE_METADATA_KEY: {"project_path": str(project), "access_mode": "restricted"}},
|
||||
can_change_project=True, can_use_full_access=False,
|
||||
can_change_project=True,
|
||||
)
|
||||
controller.stage_scope("first", scope)
|
||||
controller.stage_scope("second", scope)
|
||||
restarted = WebUIWorkspaceController(
|
||||
session_manager=None, default_workspace=default, default_restrict_to_workspace=True,
|
||||
)
|
||||
payload = restarted.payload(can_change_project=True, can_use_full_access=False)
|
||||
payload = restarted.payload(can_change_project=True)
|
||||
assert payload["recent_projects"] == [{"name": "project", "path": str(project)}]
|
||||
assert payload["default_scope"]["project_path"] == str(default)
|
||||
assert payload["default_scope"]["access_mode"] == "restricted"
|
||||
@@ -442,7 +403,7 @@ def test_favorites_keep_pin_order_across_restart_and_can_remove_deleted_folder(t
|
||||
restarted = WebUIWorkspaceController(
|
||||
session_manager=None, default_workspace=default, default_restrict_to_workspace=True,
|
||||
)
|
||||
payload = restarted.payload(can_change_project=True, can_use_full_access=False)
|
||||
payload = restarted.payload(can_change_project=True)
|
||||
assert [item["path"] for item in payload["favorite_projects"]] == [str(beta), str(alpha)]
|
||||
assert [item["path"] for item in payload["recent_projects"]] == [str(alpha)]
|
||||
assert payload["default_scope"]["project_path"] == str(default)
|
||||
|
||||
Reference in new issue
Block a user