Merge branch 'main' into RCCE-255-unit-tests-fix

This commit is contained in:
Andrii V 2025-07-03 15:49:31 +02:00
commit 7c551fd05f
7 changed files with 83 additions and 11 deletions

View file

@ -0,0 +1,37 @@
|RCE| 5.6.1 |RNS|
-----------------
Release Date
^^^^^^^^^^^^
- 2025-07-01
New Features
^^^^^^^^^^^^
General
^^^^^^^
Security
^^^^^^^^
Performance
^^^^^^^^^^^
Fixes
^^^^^
- ui: Fixed issue with number of users warning not disappearing properly when you dismiss it.
- api: Added repo field to indicate if repo is archived, updated appi docs.
Upgrade notes
^^^^^^^^^^^^^
- RhodeCode 5.6.1 is an unscheduled bugfix release.

View file

@ -9,6 +9,7 @@ Release Notes
.. toctree::
:maxdepth: 1
release-notes-5.6.1.rst
release-notes-5.6.0.rst
release-notes-5.5.3.rst
release-notes-5.5.2.rst

View file

@ -15,11 +15,14 @@
# This program is dual-licensed. If you wish to learn more about the
# RhodeCode Enterprise Edition, including its added features, Support services,
# and proprietary license terms, please see https://rhodecode.com/licenses/
import json
import pytest
from rhodecode.api.utils import Optional, OAttr
from rhodecode.api.tests.utils import build_data, api_call, assert_error, assert_ok
from rhodecode.model.db import Repository
from rhodecode.model.meta import Session
@pytest.mark.usefixtures("testuser_api", "app")
@ -133,3 +136,30 @@ class TestApi(object):
response = api_call(self.app, params)
assert response.status == "200 OK"
assert_ok(id_, expected, response.body)
@pytest.mark.parametrize(
"is_archived",
[
True,
False,
],
)
def test_api_repo_is_archived(self, backend, is_archived):
repo_name = self._create_repo(backend, is_archived)
id_, params = build_data(apikey=self.apikey, method="get_repo", repoid=repo_name)
response = api_call(self.app, params)
assert response.status == "200 OK"
json_body = json.loads(response.body)
assert json_body["result"]["archived"] == is_archived
def _create_repo(self, backend, is_archived):
repo = backend.create_repo()
repo_name = repo.repo_name
repo = Repository.get_by_repo_name(repo_name)
repo.archived = is_archived
Session().commit()
return repo_name

View file

@ -413,7 +413,7 @@ class BranchPermOriginDict(dict):
else:
(pattern_perm, origin) = pattern_perm_origin
# we're passing in the dict, so we save the the stack
# we're passing in the dict, so we save the stack
for pattern, perm in list(pattern_perm.items()):
self.perm_origin_stack.setdefault(key, {}).setdefault(pattern, []).append((perm, origin))
@ -849,7 +849,9 @@ class PermissionCalculator(object):
multiple_counter[r_k] += 1
if multiple_counter[r_k] > 1:
cur_perm = self.permissions_repository_branches[r_k][pattern]
# Get the previous permission for this pattern, with fallback, from perm_origin_stack that keeps history
pattern_perms = self.permissions_repository_branches.perm_origin_stack.get(r_k, {}).get(pattern, [])
cur_perm = pattern_perms[0][0] if pattern_perms else "branch.none"
p = self._choose_permission(p, cur_perm)
self.permissions_repository_branches[r_k] = {pattern: p}, o

View file

@ -364,7 +364,7 @@ class BaseModel(object):
return cls.query().all()
@classmethod
def delete(cls, id_):
def delete(cls, id_): # noqa: F811
obj = cls.query().get(id_)
Session().delete(obj)
@ -418,7 +418,7 @@ class RhodeCodeSetting(Base, BaseModel):
@validates("_app_settings_value")
def validate_settings_value(self, key, val):
assert type(val) == str
assert type(val) is str
return val
@hybrid_property
@ -535,7 +535,7 @@ class RepoRhodeCodeSetting(Base, BaseModel):
@validates("_app_settings_value")
def validate_settings_value(self, key, val):
assert type(val) == str
assert type(val) is str
return val
@hybrid_property
@ -2398,6 +2398,7 @@ class Repository(Base, BaseModel):
"locked_by": User.get(_user_id).get_api_data(include_secrets=include_secrets) if _user_id else None,
"locked_date": time_to_datetime(_time) if _time else None,
"lock_reason": _reason if _reason else None,
"archived": repo.archived or False,
}
# TODO: mikhail: should be per-repo settings here

View file

@ -705,6 +705,9 @@ var storeUserSessionAttr = function (key, val) {
return false;
};
let setCookie = function (name, value, path = '/') {
document.cookie = `${name}=${encodeURIComponent(value)}; path=${path}`;
};
var getUserSessionAttr = function(key) {
var storeKey = templateContext.session_attrs;

View file

@ -125,15 +125,13 @@ c.template_context['attachment_store'] = {
ajaxPOST(url, postData, success, failure);
}
var hideLicenseWarning = function () {
var fingerprint = templateContext.session_attrs.license_fingerprint;
storeUserSessionAttr('rc_user_session_attr.hide_license_warning', fingerprint);
let hideLicenseWarning = function () {
setCookie('hide_license_warning', 'true');
$('#notifications').hide();
}
var hideLicenseError = function () {
var fingerprint = templateContext.session_attrs.license_fingerprint;
storeUserSessionAttr('rc_user_session_attr.hide_license_error', fingerprint);
let hideLicenseError = function () {
setCookie('hide_license_error', 'true');
$('#notifications').hide();
}