|
15 | 15 | import testcontainers.core.waiting_utils
|
16 | 16 |
|
17 | 17 | from tests.containers import docker_utils
|
| 18 | +from tests.containers import utils |
18 | 19 |
|
19 | 20 | import pytest
|
20 | 21 |
|
@@ -219,6 +220,30 @@ def test_oc_command_runs_fake_fips(self, image: str, subtests: pytest_subtests.S
|
219 | 220 | finally:
|
220 | 221 | docker_utils.NotebookContainer(container).stop(timeout=0)
|
221 | 222 |
|
| 223 | + def test_file_permissions(self, image: str, subtests: pytest_subtests.SubTests): |
| 224 | + """Checks the permissions and ownership for some selected files/directories.""" |
| 225 | + |
| 226 | + app_root_path = "/opt/app-root" |
| 227 | + expected_uid = "1001" # default |
| 228 | + expected_gid = "0" # root |
| 229 | + # Directories to assert permissions and ownerships as we did in ODS-CI |
| 230 | + directories_to_check: list[str] = [ |
| 231 | + [f"{app_root_path}/lib", "775", expected_gid, expected_uid], |
| 232 | + ] |
| 233 | + if not utils.is_rstudio_image(image): |
| 234 | + # RStudio image doesn't have '/opt/app-root/share' directory |
| 235 | + directories_to_check.append([f"{app_root_path}/share", "775", expected_gid, expected_uid]) |
| 236 | + |
| 237 | + def test_fn(container: testcontainers.core.container.DockerContainer): |
| 238 | + for item in directories_to_check: |
| 239 | + with subtests.test(f"Checking permissions of the: {item[0]}"): |
| 240 | + _, output = container.exec(["stat", "--format='%a:%g:%u'", f"{item[0]}"]) |
| 241 | + logging.debug(output.decode()) |
| 242 | + cleaned_output = output.decode().strip().strip("'") |
| 243 | + assert cleaned_output == f"{item[1]}:{item[2]}:{item[3]}" |
| 244 | + |
| 245 | + self._run_test(image=image, test_fn=test_fn) |
| 246 | + |
222 | 247 | def encode_python_function_execution_command_interpreter(python: str, function: Callable[..., Any], *args: list[Any]) -> list[str]:
|
223 | 248 | """Returns a cli command that will run the given Python function encoded inline.
|
224 | 249 | All dependencies (imports, ...) must be part of function body."""
|
|
0 commit comments