Skip to content

Commit

Permalink
[antlir] Convert tests to use uidmaps
Browse files Browse the repository at this point in the history
Summary: Tests for parent diff.

Test Plan: Signals.

Reviewed By: tfg13

Differential Revision: D66301412

fbshipit-source-id: 4e78b42e6a38ebacee1ce57e9db7114c8757d63e
  • Loading branch information
pzmarzly authored and facebook-github-bot committed Nov 22, 2024
1 parent 8b4356d commit b31d199
Show file tree
Hide file tree
Showing 10 changed files with 32 additions and 36 deletions.
16 changes: 8 additions & 8 deletions antlir/antlir2/antlir2_depgraph/tests/BUCK
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ bad_depgraph(
home_dir = "/",
primary_group = "root",
shell = "/fakeshell",
uid = 1000,
uidmap = "antlir",
username = "antlir",
),
# install /etc/passwd to be owned by 'antlir' which creates the circular
Expand Down Expand Up @@ -193,7 +193,7 @@ bad_depgraph(
primary_group = "root",
# this will cause a validation error because /fakeshell is not executable
shell = "/fakeshell",
uid = 1000,
uidmap = "antlir",
username = "antlir",
),
],
Expand Down Expand Up @@ -243,12 +243,12 @@ good_depgraph(
home_dir = "/",
primary_group = "antlir",
shell = "/fakeshell",
uid = 1000,
uidmap = "antlir",
username = "antlir",
),
feature.group_add(
gid = 1000,
groupname = "antlir",
uidmap = "antlir",
),
feature.install(
src = "//antlir:empty",
Expand Down Expand Up @@ -397,7 +397,7 @@ good_depgraph(
primary_group = "root",
# /bin/bash is behind a symlink
shell = "/bin/bash",
uid = 1000,
uidmap = "antlir",
username = "antlir",
),
feature.ensure_dirs_exist(dirs = "/etc"),
Expand Down Expand Up @@ -432,7 +432,7 @@ good_depgraph(
primary_group = "root",
# /bin/bash is behind a relative symlink
shell = "/bin/bash",
uid = 1000,
uidmap = "antlir",
username = "antlir",
),
feature.ensure_dirs_exist(dirs = "/etc"),
Expand Down Expand Up @@ -480,12 +480,12 @@ good_depgraph(
home_dir = "/home/antlir",
primary_group = "antlir",
shell = "/usr/sbin/nologin",
uid = 1000,
uidmap = "antlir",
username = "antlir",
),
feature.group_add(
gid = 1000,
groupname = "antlir",
uidmap = "antlir",
),
],
)
Expand Down
2 changes: 1 addition & 1 deletion antlir/antlir2/antlir2_facts/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ Take this `feature.user_add` as an example

```
feature.user_add(
uid = 1001,
uidmap = "antlir",
username = "foouser",
primary_group = "foogroup",
shell = "/bin/bash",
Expand Down
4 changes: 2 additions & 2 deletions antlir/antlir2/antlir2_facts/tests/BUCK
Original file line number Diff line number Diff line change
Expand Up @@ -79,12 +79,12 @@ feature.new(
home_dir = "/",
primary_group = "antlir",
shell = "/fakeshell",
uid = 42,
uidmap = "antlir",
username = "antlir",
),
feature.group_add(
gid = 43,
groupname = "antlir",
uidmap = "antlir",
),
],
)
Expand Down
22 changes: 11 additions & 11 deletions antlir/antlir2/features/clone/tests/BUCK
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,12 @@ image.layer(
home_dir = "/",
primary_group = "antlir",
shell = "/fakeshell",
uid = 1000,
uidmap = "antlir",
username = "antlir",
),
feature.group_add(
gid = 1000,
groupname = "antlir",
uidmap = "antlir",
),
],
)
Expand Down Expand Up @@ -217,23 +217,23 @@ image.layer(
home_dir = "/",
primary_group = "antlir",
shell = "/fakeshell",
uid = 10,
uidmap = "antlir",
username = "antlir",
),
feature.group_add(
gid = 10,
groupname = "antlir",
uidmap = "antlir",
),
feature.user_add(
home_dir = "/",
primary_group = "bar",
primary_group = "foogroup",
shell = "/fakeshell",
uid = 11,
username = "foo",
uidmap = "antlir",
username = "foouser",
),
feature.group_add(
gid = 12,
groupname = "bar",
groupname = "foogroup",
uidmap = "antlir",
),
],
)
Expand Down Expand Up @@ -263,10 +263,10 @@ image.layer(
features = [
feature.clone(
dst_path = "/cloned-file",
group = "bar",
group = "foogroup",
src_layer = ":clone-src",
src_path = "/f",
user = "foo",
user = "foouser",
),
],
parent_layer = ":base-ids-remap",
Expand Down
4 changes: 2 additions & 2 deletions antlir/antlir2/features/clone/tests/clone-file-user.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ op = 'added'
[file.cloned-file.diff]
mode = 'u+r,g+r,o+r'
file-type = 'regular-file'
user = "foo"
group = "bar"
user = "foouser"
group = "foogroup"
text = '''
This file will be cloned!
'''
2 changes: 1 addition & 1 deletion antlir/antlir2/features/group/tests/BUCK
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ image.layer(
name = "add-group",
features = [
feature.group_add(
gid = 1000,
groupname = "antlir",
uidmap = "antlir",
),
],
parent_layer = ":base",
Expand Down
4 changes: 2 additions & 2 deletions antlir/antlir2/features/tarball/tests/BUCK
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@ image.layer(
home_dir = "/",
primary_group = "antlir",
shell = "/bin/bash",
uid = 1042,
uidmap = "antlir",
username = "antlir",
),
feature.group_add(
gid = 1043,
groupname = "antlir",
uidmap = "antlir",
),
feature.ensure_dirs_exist(
dirs = "/dir",
Expand Down
4 changes: 2 additions & 2 deletions antlir/antlir2/features/user/tests/BUCK
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ image.layer(
home_dir = "/",
primary_group = "antlir",
shell = "/fakeshell",
uid = 1000,
uidmap = "antlir",
username = "antlir",
),
],
Expand Down Expand Up @@ -68,7 +68,7 @@ image.layer(
home_dir = "/",
primary_group = "antlir",
shell = "/fakeshell",
uid = 1000,
uidmap = "antlir",
username = "antlir",
),
],
Expand Down
6 changes: 1 addition & 5 deletions antlir/antlir2/features/user/user.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,8 @@ def user_add(
Example usage:
```
feature.group_add(
gid = 1000,
groupname = "myuser",
)
feature.group_add(groupname = "myuser")
feature.user_add(
uid = 1000,
username = "myuser",
primary_group = "myuser",
home_dir = "/home/myuser",
Expand Down
4 changes: 2 additions & 2 deletions antlir/antlir2/test_images/package/btrfs/BUCK
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,12 @@ image.layer(
home_dir = "/",
primary_group = "antlir",
shell = "/fakeshell",
uid = 42,
uidmap = "antlir",
username = "antlir",
),
feature.group_add(
gid = 43,
groupname = "antlir",
uidmap = "antlir",
),
feature.install_text(
dst = "/foo",
Expand Down

0 comments on commit b31d199

Please sign in to comment.