Skip to content

Commit d1a07a7

Browse files
Release version 1.2.1
1 parent 1d2db7d commit d1a07a7

11 files changed

Lines changed: 406 additions & 211 deletions

File tree

Formula/kst.rb

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -3,22 +3,27 @@ class Kst < Formula
33

44
desc "Local management of Kandji custom resources"
55
homepage "https://github.com/kandji-inc/kst"
6-
url "https://files.pythonhosted.org/packages/40/c6/b1fba7b651b16a923eaacc82194ad63f21ba042b6de97dc4f5684c01c829/kst-1.2.0.tar.gz"
7-
sha256 "581bc4c255d58a933f4e04f1c7efa0debec64db4d1cd0ad7820667dc5a5092df"
6+
url "https://files.pythonhosted.org/packages/3a/56/c4f5328cb1d0d6b5c95a73b6657c3257cf2ca21287fa85b2af7e59175d79/kst-1.2.1.tar.gz"
7+
sha256 "f04c46b1a0bb63ecfa7d486bec6829634efb6d59672d1e6464656720151127b6"
88
license "MIT"
99
head "https://github.com/kandji-inc/kst.git", branch: "main"
1010

1111
depends_on "rust" => :build # for pydantic-core
1212
depends_on "python@3.13"
1313

14+
resource "annotated-doc" do
15+
url "https://files.pythonhosted.org/packages/57/ba/046ceea27344560984e26a590f90bc7f4a75b06701f653222458922b558c/annotated_doc-0.0.4.tar.gz"
16+
sha256 "fbcda96e87e9c92ad167c2e53839e57503ecfda18804ea28102353485033faa4"
17+
end
18+
1419
resource "annotated-types" do
1520
url "https://files.pythonhosted.org/packages/ee/67/531ea369ba64dcff5ec9c3402f9f51bf748cec26dde048a2f973a4eea7f5/annotated_types-0.7.0.tar.gz"
1621
sha256 "aff07c09a53a08bc8cfccb9c85b05f1aa9a2a6f23728d790723543408344ce89"
1722
end
1823

1924
resource "certifi" do
20-
url "https://files.pythonhosted.org/packages/4c/5b/b6ce21586237c77ce67d01dc5507039d444b630dd76611bbca2d8e5dcd91/certifi-2025.10.5.tar.gz"
21-
sha256 "47c09d31ccf2acf0be3f701ea53595ee7e0b8fa08801c6624be771df09ae7b43"
25+
url "https://files.pythonhosted.org/packages/e0/2d/a891ca51311197f6ad14a7ef42e2399f36cf2f9bd44752b3dc4eab60fdc5/certifi-2026.1.4.tar.gz"
26+
sha256 "ac726dd470482006e014ad384921ed6438c457018f4b3d204aea4281258b2120"
2227
end
2328

2429
resource "charset-normalizer" do
@@ -27,8 +32,8 @@ class Kst < Formula
2732
end
2833

2934
resource "click" do
30-
url "https://files.pythonhosted.org/packages/b9/2e/0090cbf739cee7d23781ad4b89a9894a41538e4fcf4c31dcdd705b78eb8b/click-8.1.8.tar.gz"
31-
sha256 "ed53c9d8990d83c2a27deae68e4ee337473f6330c040a31d4225c9574d16096a"
35+
url "https://files.pythonhosted.org/packages/3d/fa/656b739db8587d7b5dfa22e22ed02566950fbfbcdc20311993483657a5c0/click-8.3.1.tar.gz"
36+
sha256 "12ff4785d337a1bb490bb7e9c2b1ee5da3112e94a8622f26a6c77f5d2fc6842a"
3237
end
3338

3439
resource "idna" do
@@ -47,13 +52,13 @@ class Kst < Formula
4752
end
4853

4954
resource "platformdirs" do
50-
url "https://files.pythonhosted.org/packages/61/33/9611380c2bdb1225fdef633e2a9610622310fed35ab11dac9620972ee088/platformdirs-4.5.0.tar.gz"
51-
sha256 "70ddccdd7c99fc5942e9fc25636a8b34d04c24b335100223152c2803e4063312"
55+
url "https://files.pythonhosted.org/packages/1b/04/fea538adf7dbbd6d186f551d595961e564a3b6715bdf276b477460858672/platformdirs-4.9.2.tar.gz"
56+
sha256 "9a33809944b9db043ad67ca0db94b14bf452cc6aeaac46a88ea55b26e2e9d291"
5257
end
5358

5459
resource "pydantic" do
55-
url "https://files.pythonhosted.org/packages/96/ad/a17bc283d7d81837c061c49e3eaa27a45991759a1b7eae1031921c6bd924/pydantic-2.12.4.tar.gz"
56-
sha256 "0f8cb9555000a4b5b617f66bfd2566264c4984b27589d3b845685983e8ea85ac"
60+
url "https://files.pythonhosted.org/packages/69/44/36f1a6e523abc58ae5f928898e4aca2e0ea509b5aa6f6f392a5d882be928/pydantic-2.12.5.tar.gz"
61+
sha256 "4d351024c75c0f085a9febbb665ce8c0c6ec5d30e903bdb6394b7ede26aebb49"
5762
end
5863

5964
resource "pydantic-core" do
@@ -72,18 +77,13 @@ class Kst < Formula
7277
end
7378

7479
resource "rich" do
75-
url "https://files.pythonhosted.org/packages/fb/d2/8920e102050a0de7bfabeb4c4614a49248cf8d5d7a8d01885fbb24dc767a/rich-14.2.0.tar.gz"
76-
sha256 "73ff50c7c0c1c77c8243079283f4edb376f0f6442433aecb8ce7e6d0b92d1fe4"
80+
url "https://files.pythonhosted.org/packages/b3/c6/f3b320c27991c46f43ee9d856302c70dc2d0fb2dba4842ff739d5f46b393/rich-14.3.3.tar.gz"
81+
sha256 "b8daa0b9e4eef54dd8cf7c86c03713f53241884e814f4e2f5fb342fe520f639b"
7782
end
7883

7984
resource "ruamel-yaml" do
80-
url "https://files.pythonhosted.org/packages/9f/c7/ee630b29e04a672ecfc9b63227c87fd7a37eb67c1bf30fe95376437f897c/ruamel.yaml-0.18.16.tar.gz"
81-
sha256 "a6e587512f3c998b2225d68aa1f35111c29fad14aed561a26e73fab729ec5e5a"
82-
end
83-
84-
resource "ruamel-yaml-clib" do
85-
url "https://files.pythonhosted.org/packages/d8/e9/39ec4d4b3f91188fad1842748f67d4e749c77c37e353c4e545052ee8e893/ruamel.yaml.clib-0.2.14.tar.gz"
86-
sha256 "803f5044b13602d58ea378576dd75aa759f52116a0232608e8fdada4da33752e"
85+
url "https://files.pythonhosted.org/packages/c7/3b/ebda527b56beb90cb7652cb1c7e4f91f48649fbcd8d2eb2fb6e77cd3329b/ruamel_yaml-0.19.1.tar.gz"
86+
sha256 "53eb66cd27849eff968ebf8f0bf61f46cdac2da1d1f3576dd4ccee9b25c31993"
8787
end
8888

8989
resource "shellingham" do
@@ -92,8 +92,8 @@ class Kst < Formula
9292
end
9393

9494
resource "typer" do
95-
url "https://files.pythonhosted.org/packages/8f/28/7c85c8032b91dbe79725b6f17d2fffc595dff06a35c7a30a37bef73a1ab4/typer-0.20.0.tar.gz"
96-
sha256 "1aaf6494031793e4876fb0bacfa6a912b551cf43c1e63c800df8b1a866720c37"
95+
url "https://files.pythonhosted.org/packages/f5/24/cb09efec5cc954f7f9b930bf8279447d24618bb6758d4f6adf2574c41780/typer-0.24.1.tar.gz"
96+
sha256 "e39b4732d65fbdcde189ae76cf7cd48aeae72919dea1fdfc16593be016256b45"
9797
end
9898

9999
resource "typing-extensions" do
@@ -107,8 +107,8 @@ class Kst < Formula
107107
end
108108

109109
resource "urllib3" do
110-
url "https://files.pythonhosted.org/packages/15/22/9ee70a2574a4f4599c47dd506532914ce044817c7752a79b6a51286319bc/urllib3-2.5.0.tar.gz"
111-
sha256 "3fc47733c7e419d4bc3f6b3dc2b4f890bb743906a30d56ba4a5bfa4bbff92760"
110+
url "https://files.pythonhosted.org/packages/c7/24/5f1b3bdffd70275f6661c76461e25f024d5a38a46f04aaca912426a2b1d3/urllib3-2.6.3.tar.gz"
111+
sha256 "1b62b6884944a57dbe321509ab94fd4d3b307075e0c2eae991ac71ee15ad38ed"
112112
end
113113

114114
def install

Formula/kst@1.2.0.rb

Lines changed: 129 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,129 @@
1+
class KstAt120 < Formula
2+
include Language::Python::Virtualenv
3+
4+
desc "Local management of Kandji custom resources"
5+
homepage "https://github.com/kandji-inc/kst"
6+
url "https://files.pythonhosted.org/packages/40/c6/b1fba7b651b16a923eaacc82194ad63f21ba042b6de97dc4f5684c01c829/kst-1.2.0.tar.gz"
7+
sha256 "581bc4c255d58a933f4e04f1c7efa0debec64db4d1cd0ad7820667dc5a5092df"
8+
license "MIT"
9+
head "https://github.com/kandji-inc/kst.git", branch: "main"
10+
11+
depends_on "rust" => :build # for pydantic-core
12+
depends_on "python@3.13"
13+
14+
resource "annotated-types" do
15+
url "https://files.pythonhosted.org/packages/ee/67/531ea369ba64dcff5ec9c3402f9f51bf748cec26dde048a2f973a4eea7f5/annotated_types-0.7.0.tar.gz"
16+
sha256 "aff07c09a53a08bc8cfccb9c85b05f1aa9a2a6f23728d790723543408344ce89"
17+
end
18+
19+
resource "certifi" do
20+
url "https://files.pythonhosted.org/packages/4c/5b/b6ce21586237c77ce67d01dc5507039d444b630dd76611bbca2d8e5dcd91/certifi-2025.10.5.tar.gz"
21+
sha256 "47c09d31ccf2acf0be3f701ea53595ee7e0b8fa08801c6624be771df09ae7b43"
22+
end
23+
24+
resource "charset-normalizer" do
25+
url "https://files.pythonhosted.org/packages/13/69/33ddede1939fdd074bce5434295f38fae7136463422fe4fd3e0e89b98062/charset_normalizer-3.4.4.tar.gz"
26+
sha256 "94537985111c35f28720e43603b8e7b43a6ecfb2ce1d3058bbe955b73404e21a"
27+
end
28+
29+
resource "click" do
30+
url "https://files.pythonhosted.org/packages/b9/2e/0090cbf739cee7d23781ad4b89a9894a41538e4fcf4c31dcdd705b78eb8b/click-8.1.8.tar.gz"
31+
sha256 "ed53c9d8990d83c2a27deae68e4ee337473f6330c040a31d4225c9574d16096a"
32+
end
33+
34+
resource "idna" do
35+
url "https://files.pythonhosted.org/packages/6f/6d/0703ccc57f3a7233505399edb88de3cbd678da106337b9fcde432b65ed60/idna-3.11.tar.gz"
36+
sha256 "795dafcc9c04ed0c1fb032c2aa73654d8e8c5023a7df64a53f39190ada629902"
37+
end
38+
39+
resource "markdown-it-py" do
40+
url "https://files.pythonhosted.org/packages/5b/f5/4ec618ed16cc4f8fb3b701563655a69816155e79e24a17b651541804721d/markdown_it_py-4.0.0.tar.gz"
41+
sha256 "cb0a2b4aa34f932c007117b194e945bd74e0ec24133ceb5bac59009cda1cb9f3"
42+
end
43+
44+
resource "mdurl" do
45+
url "https://files.pythonhosted.org/packages/d6/54/cfe61301667036ec958cb99bd3efefba235e65cdeb9c84d24a8293ba1d90/mdurl-0.1.2.tar.gz"
46+
sha256 "bb413d29f5eea38f31dd4754dd7377d4465116fb207585f97bf925588687c1ba"
47+
end
48+
49+
resource "platformdirs" do
50+
url "https://files.pythonhosted.org/packages/61/33/9611380c2bdb1225fdef633e2a9610622310fed35ab11dac9620972ee088/platformdirs-4.5.0.tar.gz"
51+
sha256 "70ddccdd7c99fc5942e9fc25636a8b34d04c24b335100223152c2803e4063312"
52+
end
53+
54+
resource "pydantic" do
55+
url "https://files.pythonhosted.org/packages/96/ad/a17bc283d7d81837c061c49e3eaa27a45991759a1b7eae1031921c6bd924/pydantic-2.12.4.tar.gz"
56+
sha256 "0f8cb9555000a4b5b617f66bfd2566264c4984b27589d3b845685983e8ea85ac"
57+
end
58+
59+
resource "pydantic-core" do
60+
url "https://files.pythonhosted.org/packages/71/70/23b021c950c2addd24ec408e9ab05d59b035b39d97cdc1130e1bce647bb6/pydantic_core-2.41.5.tar.gz"
61+
sha256 "08daa51ea16ad373ffd5e7606252cc32f07bc72b28284b6bc9c6df804816476e"
62+
end
63+
64+
resource "pygments" do
65+
url "https://files.pythonhosted.org/packages/b0/77/a5b8c569bf593b0140bde72ea885a803b82086995367bf2037de0159d924/pygments-2.19.2.tar.gz"
66+
sha256 "636cb2477cec7f8952536970bc533bc43743542f70392ae026374600add5b887"
67+
end
68+
69+
resource "requests" do
70+
url "https://files.pythonhosted.org/packages/c9/74/b3ff8e6c8446842c3f5c837e9c3dfcfe2018ea6ecef224c710c85ef728f4/requests-2.32.5.tar.gz"
71+
sha256 "dbba0bac56e100853db0ea71b82b4dfd5fe2bf6d3754a8893c3af500cec7d7cf"
72+
end
73+
74+
resource "rich" do
75+
url "https://files.pythonhosted.org/packages/fb/d2/8920e102050a0de7bfabeb4c4614a49248cf8d5d7a8d01885fbb24dc767a/rich-14.2.0.tar.gz"
76+
sha256 "73ff50c7c0c1c77c8243079283f4edb376f0f6442433aecb8ce7e6d0b92d1fe4"
77+
end
78+
79+
resource "ruamel-yaml" do
80+
url "https://files.pythonhosted.org/packages/9f/c7/ee630b29e04a672ecfc9b63227c87fd7a37eb67c1bf30fe95376437f897c/ruamel.yaml-0.18.16.tar.gz"
81+
sha256 "a6e587512f3c998b2225d68aa1f35111c29fad14aed561a26e73fab729ec5e5a"
82+
end
83+
84+
resource "ruamel-yaml-clib" do
85+
url "https://files.pythonhosted.org/packages/d8/e9/39ec4d4b3f91188fad1842748f67d4e749c77c37e353c4e545052ee8e893/ruamel.yaml.clib-0.2.14.tar.gz"
86+
sha256 "803f5044b13602d58ea378576dd75aa759f52116a0232608e8fdada4da33752e"
87+
end
88+
89+
resource "shellingham" do
90+
url "https://files.pythonhosted.org/packages/58/15/8b3609fd3830ef7b27b655beb4b4e9c62313a4e8da8c676e142cc210d58e/shellingham-1.5.4.tar.gz"
91+
sha256 "8dbca0739d487e5bd35ab3ca4b36e11c4078f3a234bfce294b0a0291363404de"
92+
end
93+
94+
resource "typer" do
95+
url "https://files.pythonhosted.org/packages/8f/28/7c85c8032b91dbe79725b6f17d2fffc595dff06a35c7a30a37bef73a1ab4/typer-0.20.0.tar.gz"
96+
sha256 "1aaf6494031793e4876fb0bacfa6a912b551cf43c1e63c800df8b1a866720c37"
97+
end
98+
99+
resource "typing-extensions" do
100+
url "https://files.pythonhosted.org/packages/72/94/1a15dd82efb362ac84269196e94cf00f187f7ed21c242792a923cdb1c61f/typing_extensions-4.15.0.tar.gz"
101+
sha256 "0cea48d173cc12fa28ecabc3b837ea3cf6f38c6d1136f85cbaaf598984861466"
102+
end
103+
104+
resource "typing-inspection" do
105+
url "https://files.pythonhosted.org/packages/55/e3/70399cb7dd41c10ac53367ae42139cf4b1ca5f36bb3dc6c9d33acdb43655/typing_inspection-0.4.2.tar.gz"
106+
sha256 "ba561c48a67c5958007083d386c3295464928b01faa735ab8547c5692e87f464"
107+
end
108+
109+
resource "urllib3" do
110+
url "https://files.pythonhosted.org/packages/15/22/9ee70a2574a4f4599c47dd506532914ce044817c7752a79b6a51286319bc/urllib3-2.5.0.tar.gz"
111+
sha256 "3fc47733c7e419d4bc3f6b3dc2b4f890bb743906a30d56ba4a5bfa4bbff92760"
112+
end
113+
114+
def install
115+
virtualenv_install_with_resources
116+
end
117+
118+
test do
119+
assert_match "kst, version #{version}", shell_output("#{bin}/kst --version")
120+
system "git", "config", "--global", "user.name", "Kandji Sync Toolkit"
121+
system "git", "config", "--global", "user.email", "kst@kandji.invalid"
122+
system bin/"kst", "new", testpath/"test-repo"
123+
system "git", "-C", testpath/"test-repo", "rev-parse", "--is-inside-work-tree"
124+
system bin/"kst", "profile", "new", "--output", testpath/"test-repo/profiles", "--name", "test-profile"
125+
system bin/"kst", "profile", "list", "--repo", testpath/"test-repo", "--local"
126+
system bin/"kst", "script", "new", "--output", testpath/"test-repo/scripts", "--name", "test-script"
127+
system bin/"kst", "script", "list", "--repo", testpath/"test-repo", "--local"
128+
end
129+
end

pyproject.toml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,14 @@ python-preference = "only-managed"
6363
[tool.hatch.version]
6464
path = "src/kst/__about__.py"
6565

66+
[tool.hatch.build.targets.sdist]
67+
include = [
68+
"pyproject.toml",
69+
"src/kst",
70+
"LICENSE",
71+
"README.md"
72+
]
73+
6674
[tool.ruff]
6775
lint.select = ["ALL"]
6876
# Rules can be ignored, see: https://beta.ruff.rs/docs/rules/

src/kst/__about__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
APP_NAME = "kst"
2-
__version__ = "1.2.0"
2+
__version__ = "1.2.1"

src/kst/api/scripts.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ def create(
129129
"restart": restart,
130130
"show_in_self_service": show_in_self_service,
131131
}
132-
if remediation_script:
132+
if remediation_script is not None:
133133
payload["remediation_script"] = remediation_script
134134

135135
if execution_frequency is ExecutionFrequency.NO_ENFORCEMENT and not show_in_self_service:

src/kst/repository/custom_script.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -306,7 +306,7 @@ def create_remote(self, config: ApiConfig) -> CustomScriptPayload:
306306
payload = {
307307
"name": self.name,
308308
"script": self.audit.content,
309-
"remediation_script": "" if self.remediation is None else self.remediation.content,
309+
"remediation_script": None if self.remediation is None else self.remediation.content,
310310
"active": self.info.active,
311311
"execution_frequency": self.info.execution_frequency,
312312
"restart": self.info.restart,
@@ -327,7 +327,7 @@ def update_remote(self, config: ApiConfig) -> CustomScriptPayload:
327327
"id": self.id,
328328
"name": self.name,
329329
"script": self.audit.content,
330-
"remediation_script": "" if self.remediation is None else self.remediation.content,
330+
"remediation_script": None if self.remediation is None else self.remediation.content,
331331
"active": self.info.active,
332332
"execution_frequency": self.info.execution_frequency,
333333
"restart": self.info.restart,

tests/conftest.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,16 @@ def prepare_request(self, request):
7171
monkeypatch.setattr("requests.Session", TestSession)
7272

7373

74+
@pytest.fixture(autouse=True, scope="session")
75+
def git_config_isolation():
76+
"""Isolate git operations from user and system config."""
77+
gitconfig = as_file(files("tests.resources") / "gitconfig")
78+
with gitconfig as gitconfig_path, pytest.MonkeyPatch.context() as mp:
79+
mp.setenv("GIT_CONFIG_SYSTEM", os.devnull)
80+
mp.setenv("GIT_CONFIG_GLOBAL", str(gitconfig_path))
81+
yield
82+
83+
7484
@pytest.fixture(autouse=True)
7585
def git_locate_git_cache_clear():
7686
"""Clear the cache before each test."""
@@ -83,6 +93,12 @@ def git_locate_root_cache_clear():
8393
git.locate_root.cache_clear()
8494

8595

96+
@pytest.fixture(autouse=True)
97+
def git_has_user_config_cache_clear():
98+
"""Clear the cache before each test."""
99+
git.has_git_user_config.cache_clear()
100+
101+
86102
@pytest.fixture(autouse=True)
87103
def tmp_path_cd(tmp_path: Path):
88104
"""Change working directory to a temporary directory and return the path."""

tests/resources/gitconfig

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
[init]
2+
defaultBranch = main
3+
[user]
4+
name = Test
5+
email = test@test.invalid

tests/unit/api/profiles/test_list.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -146,10 +146,10 @@ def mock_get_request(self, url):
146146

147147

148148
@pytest.mark.allow_http
149-
def test_successful_list_live(custom_profiles_resource):
149+
def test_successful_list_live(setup_live_profiles_create_and_delete, custom_profiles_resource):
150+
profile_id = setup_live_profiles_create_and_delete
150151
response = custom_profiles_resource.list()
151152
assert isinstance(response, PayloadList)
152-
assert response.next is None
153-
assert response.previous is None
154153
assert response.count > 0
155154
assert len(response.results) == response.count
155+
assert any(profile.id == profile_id for profile in response.results)

tests/unit/repository/scripts/test_custom_script.py

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -258,3 +258,59 @@ def test_diff_hash(self, custom_script_obj):
258258
assert custom_script_obj.diff_hash != original_hash
259259
custom_script_obj.remediation.content = original_content
260260
assert custom_script_obj.diff_hash == original_hash
261+
262+
263+
class TestUpdateRemoteRemediationScript:
264+
"""Verify update_remote sends the correct remediation_script value to the API.
265+
266+
The Kandji API rejects null for remediation_script. When a script has no
267+
remediation, update_remote must send None (filtered to absent by the API
268+
layer) — not "" which would actively clear remote remediation.
269+
"""
270+
271+
def test_without_remediation_does_not_send_empty_string(
272+
self, monkeypatch, config, custom_script_factory, script_info_data_factory
273+
):
274+
"""When remediation is None, update_remote must pass None (not "")."""
275+
script = custom_script_factory(has_remediation=False)
276+
script.info.show_in_self_service = False
277+
278+
captured_kwargs = {}
279+
280+
def fake_update(self, id, **kwargs):
281+
captured_kwargs.update(kwargs)
282+
data = script_info_data_factory(id=id, show_in_self_service=False)
283+
data["script"] = kwargs.get("script", "")
284+
data["remediation_script"] = kwargs.get("remediation_script") or ""
285+
return CustomScriptPayload.model_validate(data)
286+
287+
monkeypatch.setattr("kst.api.scripts.CustomScriptsResource.update", fake_update)
288+
289+
script.update_remote(config)
290+
291+
assert "remediation_script" in captured_kwargs
292+
assert captured_kwargs["remediation_script"] is None
293+
294+
def test_with_remediation_sends_content(
295+
self, monkeypatch, config, custom_script_factory, script_info_data_factory
296+
):
297+
"""When remediation exists, update_remote must pass its content."""
298+
script = custom_script_factory(has_remediation=True)
299+
script.info.show_in_self_service = False
300+
301+
captured_kwargs = {}
302+
303+
def fake_update(self, id, **kwargs):
304+
captured_kwargs.update(kwargs)
305+
data = script_info_data_factory(id=id, show_in_self_service=False)
306+
data["script"] = kwargs.get("script", "")
307+
data["remediation_script"] = kwargs.get("remediation_script") or ""
308+
return CustomScriptPayload.model_validate(data)
309+
310+
monkeypatch.setattr("kst.api.scripts.CustomScriptsResource.update", fake_update)
311+
312+
script.update_remote(config)
313+
314+
assert captured_kwargs["remediation_script"] == script.remediation.content
315+
assert isinstance(captured_kwargs["remediation_script"], str)
316+
assert captured_kwargs["remediation_script"] != ""

0 commit comments

Comments
 (0)