Skip to content

Commit

Permalink
schema,tests: add support for new system usernames
Browse files Browse the repository at this point in the history
Signed-off-by: Alex Lewontin <alex.lewontin@canonical.com>
  • Loading branch information
alexclewontin committed Oct 27, 2022
1 parent 433a092 commit 1f626e7
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 3 deletions.
2 changes: 1 addition & 1 deletion schema/snapcraft.json
Original file line number Diff line number Diff line change
Expand Up @@ -523,7 +523,7 @@
"additionalProperties": false,
"validation-failure": "{!r} is not a valid system-username.",
"patternProperties": {
"^snap_(daemon|microk8s)$": {
"^snap_(daemon|microk8s|aziotedge|aziotdu)$": {
"oneOf": [
{
"$ref": "#/definitions/system-username-scope"
Expand Down
20 changes: 18 additions & 2 deletions tests/legacy/unit/project/test_schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -1225,13 +1225,29 @@ def test_invalid_command_chain(data, command_chain):
assert expected_message in str(error.value)


@pytest.mark.parametrize("username", ["snap_daemon", "snap_microk8s"])
@pytest.mark.parametrize(
"username",
[
"snap_daemon",
"snap_microk8s",
"snap_aziotedge",
"snap_aziotdu",
],
)
def test_yaml_valid_system_usernames_long(data, username):
data["system-usernames"] = {username: {"scope": "shared"}}
Validator(data).validate()


@pytest.mark.parametrize("username", ["snap_daemon", "snap_microk8s"])
@pytest.mark.parametrize(
"username",
[
"snap_daemon",
"snap_microk8s",
"snap_aziotedge",
"snap_aziotdu",
],
)
def test_yaml_valid_system_usernames_short(data, username):
data["system-usernames"] = {username: "shared"}
Validator(data).validate()
Expand Down
3 changes: 3 additions & 0 deletions tests/unit/meta/test_snap_yaml.py
Original file line number Diff line number Diff line change
Expand Up @@ -330,6 +330,9 @@ def test_complex_snap_yaml(complex_project, new_dir):
snap_daemon:
scope: shared
snap_microk8s: shared
snap_aziotedge: shared
snap_aziotdu:
scope: shared
"""
)

Expand Down
4 changes: 4 additions & 0 deletions tests/unit/test_projects.py
Original file line number Diff line number Diff line change
Expand Up @@ -1153,8 +1153,12 @@ def test_grammar_syntax_error(self, project_yaml_data):
[
{"snap_daemon": {"scope": "shared"}},
{"snap_microk8s": {"scope": "shared"}},
{"snap_aziotedge": {"scope": "shared"}},
{"snap_aziotdu": {"scope": "shared"}},
{"snap_daemon": "shared"},
{"snap_microk8s": "shared"},
{"snap_aziotedge": "shared"},
{"snap_aziotdu": "shared"},
],
)
def test_project_system_usernames_valid(self, system_username, project_yaml_data):
Expand Down

0 comments on commit 1f626e7

Please sign in to comment.