Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion sonar/platform.py
Original file line number Diff line number Diff line change
Expand Up @@ -788,7 +788,7 @@ def __lta_and_latest() -> tuple[tuple[int, int, int], tuple[int, int, int]]:
_, tmpfile = tempfile.mkstemp(prefix="sonar-tools", suffix=".txt", text=True)
try:
with open(tmpfile, "w", encoding="utf-8") as fp:
print(requests.get(_UPDATE_CENTER, headers=_SONAR_TOOLS_AGENT, timeout=10).text, file=fp)
print(requests.get(_UPDATE_CENTER, headers={"user-agent": _SONAR_TOOLS_AGENT}, timeout=10).text, file=fp)
with open(tmpfile, "r", encoding="utf-8") as fp:
upd_center_props = jprops.load_properties(fp)
v = upd_center_props.get("ltsVersion", "9.9.0").split(".")
Expand Down
5 changes: 2 additions & 3 deletions sonar/users.py
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ def update(self, **kwargs) -> User:
params[p] = kwargs[p]
if len(params) > 1:
self.post(UPDATE_API, params=params)
self.set_scm_accounts(kwargs.get("scmAccounts", ""))
self.set_scm_accounts(kwargs.get("scmAccounts", None))
if "login" in kwargs:
new_login = kwargs["login"]
if new_login not in _OBJECTS:
Expand Down Expand Up @@ -380,8 +380,7 @@ def to_json(self, export_settings: types.ConfigSettings) -> types.ObjectJsonRepr
:rtype: dict
"""
json_data = self._json.copy()
scm = self.scm_accounts
json_data["scmAccounts"] = util.list_to_csv(scm) if scm else None
json_data["scmAccounts"] = self.scm_accounts
json_data["groups"] = self.groups().copy()
if export_settings.get("MODE", "") == "MIGRATION":
return json_data
Expand Down
14 changes: 9 additions & 5 deletions test/test_migration.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,11 +68,14 @@ def test_migration() -> None:
assert json_config["users"]["olivier"]["externalProvider"] == "sonarqube"

u = json_config["users"]["olivier-korach65532"]
assert u["externalProvider"] == "github"
assert u["name"] == "Olivier Korach"
assert not u["local"]
assert u["externalLogin"] == "okorach"
assert u["email"] == "[email protected]"
if util.SQ.version() >= (10, 0, 0):
assert u["externalProvider"] == "github"
assert u["externalLogin"] == "okorach"
assert u["email"] == "[email protected]"
else:
assert u["externalProvider"] == "sonarqube"

p = json_config["projects"]["okorach_sonar-tools"]
assert "lastTaskScannerContext" in p["backgroundTasks"]
Expand All @@ -96,7 +99,8 @@ def test_migration() -> None:
p = json_config["projects"]["checkstyle-issues"]
assert len(p["branches"]["main"]["issues"]["thirdParty"]) > 0

assert json_config["projects"]["demo:gitlab-ci-maven"]["detectedCi"] == "GitLab CI"
assert json_config["projects"]["demo:gitlab-actions-cli"]["detectedCi"] == "Github Actions"
if util.SQ.version() >= (10, 0, 0):
assert json_config["projects"]["demo:gitlab-ci-maven"]["detectedCi"] == "Gitlab CI"
assert json_config["projects"]["demo:github-actions-cli"]["detectedCi"] == "Github Actions"

util.clean(util.JSON_FILE)