-
Notifications
You must be signed in to change notification settings - Fork 252
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[features test cmd] Write tests with a non-root
remoteUser
(#286)
* [features test cmd] Play nice with setting 'remoteUser' in a test Previously, if you set 'remoteUser' in a test, the accompanying test scripts placed into the shared 'workspaceFolder' would not have the appropriate permission bits set to be executed by the exec user. This patch ensure that all files in the workspaceFolder can be read/written/executed by the exec user. A test is added to validate creating a user and setting 'remoteUser' in a scenario, and then running a test within that context to validate. * add new test project * let -> const
- Loading branch information
1 parent
eb8752e
commit 37ee770
Showing
6 changed files
with
77 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
9 changes: 9 additions & 0 deletions
9
...ample-v2-features-sets/not-root-remote-user/src/whoisremoteuser/devcontainer-feature.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
{ | ||
"id": "whoisremoteuser", | ||
"version": "0.0.0", | ||
"name": "Stores and echoes original value of _REMOTE_USER", | ||
"options": {}, | ||
"installsAfter": [ | ||
"ghcr.io/devcontainers/features/common-utils" | ||
] | ||
} |
12 changes: 12 additions & 0 deletions
12
...ner-features/example-v2-features-sets/not-root-remote-user/src/whoisremoteuser/install.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
#!/bin/sh | ||
set -e | ||
|
||
echo "Activating feature 'whoisremoteuser'" | ||
|
||
cat > /usr/local/bin/whoisremoteuser \ | ||
<< EOF | ||
#!/bin/sh | ||
echo -n "$_REMOTE_USER" | ||
EOF | ||
|
||
chmod +x /usr/local/bin/whoisremoteuser |
15 changes: 15 additions & 0 deletions
15
...ample-v2-features-sets/not-root-remote-user/test/whoisremoteuser/different_remote_user.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
#!/bin/bash | ||
|
||
set -e | ||
|
||
# Optional: Import test library | ||
source dev-container-features-test-lib | ||
|
||
# Definition specific tests | ||
check "ensure i am user codespace" bash -c "whoami | grep 'codespace'" | ||
|
||
check "_REMOTE_USER was equal to codespace" bash -c "whoisremoteuser | grep 'codespace'" | ||
|
||
|
||
# Report result | ||
reportResults |
15 changes: 15 additions & 0 deletions
15
...eatures/example-v2-features-sets/not-root-remote-user/test/whoisremoteuser/scenarios.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
{ | ||
"different_remote_user": { | ||
"image": "mcr.microsoft.com/devcontainers/base:ubuntu", | ||
"remoteUser": "codespace", | ||
"features": { | ||
"ghcr.io/devcontainers/features/common-utils:1": { | ||
"installZsh": false, | ||
"installOhMyZsh": false, | ||
"upgradePackages": false, | ||
"username": "codespace" | ||
}, | ||
"whoisremoteuser": {} | ||
} | ||
} | ||
} |
14 changes: 14 additions & 0 deletions
14
...ainer-features/example-v2-features-sets/not-root-remote-user/test/whoisremoteuser/test.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
#!/bin/bash | ||
|
||
set -e | ||
|
||
# Optional: Import test library | ||
source dev-container-features-test-lib | ||
|
||
# Definition specific tests | ||
check "ensure i am root" bash -c "whoami | grep 'root'" | ||
|
||
check "_REMOTE_USER was equal to root" bash -c "whoisremoteuser | grep 'root'" | ||
|
||
# Report result | ||
reportResults |