Skip to content

Commit ae84388

Browse files
tests: add tests for permissions config
Signed-off-by: John Mulligan <[email protected]>
1 parent ba14c45 commit ae84388

File tree

1 file changed

+47
-1
lines changed

1 file changed

+47
-1
lines changed

tests/test_config.py

Lines changed: 47 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,10 @@
6363
"share"
6464
],
6565
"globals": ["global0"],
66-
"instance_name": "GANDOLPH"
66+
"instance_name": "GANDOLPH",
67+
"permissions": {
68+
"method": "none"
69+
}
6770
}
6871
},
6972
"shares": {
@@ -122,6 +125,9 @@
122125
"valid users": "sambauser",
123126
"guest ok": "no",
124127
"force user": "root"
128+
},
129+
"permissions": {
130+
"method": "none"
125131
}
126132
}
127133
},
@@ -714,3 +720,43 @@ def test_instance_config_equality(json_a, json_b, iname, expect_equal):
714720
assert instance_a == instance_b
715721
else:
716722
assert instance_a != instance_b
723+
724+
725+
def test_permissions_config_default():
726+
c1 = sambacc.config.GlobalConfig(io.StringIO(config1))
727+
ic = c1.get("foobar")
728+
for share in ic.shares():
729+
assert share.permissions_config().method == "none"
730+
731+
732+
def test_permissions_config_instance():
733+
c2 = sambacc.config.GlobalConfig(io.StringIO(config2))
734+
ic = c2.get("foobar")
735+
# TODO: improve test to ensure this isn't getting the default. it does
736+
# work as designed based on coverage, but we shouldn't rely on that
737+
for share in ic.shares():
738+
assert share.permissions_config().method == "none"
739+
740+
741+
def test_permissions_config_share():
742+
c3 = sambacc.config.GlobalConfig(io.StringIO(config3))
743+
ic = c3.get("foobar")
744+
# TODO: improve test to ensure this isn't getting the default. it does
745+
# work as designed based on coverage, but we shouldn't rely on that
746+
for share in ic.shares():
747+
assert share.permissions_config().method == "none"
748+
749+
750+
def test_permissions_config_options():
751+
pc = sambacc.config.PermissionsConfig(
752+
{
753+
"method": "initialize-share-perms",
754+
"status_xattr": "user.fake-stuff",
755+
"mode": "0777",
756+
"friendship": "always",
757+
}
758+
)
759+
opts = pc.options
760+
assert len(opts) == 2
761+
assert "mode" in opts
762+
assert "friendship" in opts

0 commit comments

Comments
 (0)