Skip to content

Commit

Permalink
api: allow empty filesystem string
Browse files Browse the repository at this point in the history
Clients may send an empty filesystem string, don't ignore their requests but
handle them as if no filesystem was set.

Signed-off-by: Paul Spooren <[email protected]>
  • Loading branch information
aparcar committed Jul 30, 2022
1 parent 0ca7466 commit 2287136
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 1 deletion.
3 changes: 2 additions & 1 deletion asu/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ def download_file(filename: str, dest: str = None):

log.debug("Created store path: %s", req["store_path"] / bin_dir)

if "filesystem" in req:
if req.get("filesystem"):
config_path = cache_workdir / ".config"
config = config_path.read_text()

Expand All @@ -293,6 +293,7 @@ def download_file(filename: str, dest: str = None):

config_path.write_text(config)
else:
log.debug("Enable default filesystems")
copyfile(
cache_workdir / ".config.orig",
cache_workdir / ".config",
Expand Down
1 change: 1 addition & 0 deletions asu/openapi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,7 @@ components:
- ext4
- ubifs
- jffs2
- ""
description: |
Ability to specify filesystem running on device. Attaching this
optional parameter will limit the ImageBuilder to only build
Expand Down
20 changes: 20 additions & 0 deletions tests/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,26 @@ def test_api_build_filesystem_squashfs(app, upstream):
assert "# CONFIG_TARGET_ROOTFS_EXT4FS is not set" in config
assert "CONFIG_TARGET_ROOTFS_SQUASHFS=y" in config

def test_api_build_filesystem_empty(app, upstream):
client = app.test_client()
response = client.post(
"/api/v1/build",
json=dict(
version="TESTVERSION",
target="testtarget/testsubtarget",
profile="testprofile",
packages=["test1", "test2"],
filesystem="",
),
)
assert response.status == "200 OK"
assert response.json.get("request_hash") == "33377fbd91c50c4236343f1dfd67f9ae"
config = (
app.config["CACHE_PATH"] / "cache/TESTVERSION/testtarget/testsubtarget/.config"
).read_text()
assert "CONFIG_TARGET_ROOTFS_EXT4FS=y" in config
assert "CONFIG_TARGET_ROOTFS_SQUASHFS=y" in config


def test_api_build_filesystem_reset(app, upstream):
client = app.test_client()
Expand Down

0 comments on commit 2287136

Please sign in to comment.