Skip to content

Commit c1b7e3b

Browse files
authored
Merge pull request #1334 from lsst-sqre/tickets/DM-52140
DM-52140: Fix group name validation regression
2 parents c146ae4 + 1794ff7 commit c1b7e3b

File tree

4 files changed

+34
-3
lines changed

4 files changed

+34
-3
lines changed

.github/workflows/ci.yaml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ jobs:
171171
run: uv run --only-group=tox tox run -e docs
172172

173173
# Upload docs:
174-
# - on pushes to main, merge queues, and workflow dispatches
174+
# - on pushes to main and workflow dispatches
175175
# - on pushes to tickets/ branches if docs/ directory content changed
176176
- uses: lsst-sqre/ltd-upload@v1
177177
with:
@@ -181,7 +181,6 @@ jobs:
181181
password: ${{ secrets.LTD_PASSWORD }}
182182
if: >
183183
(github.event_name == 'push' && github.ref_name == 'main')
184-
|| (github.event_name == 'merge_group')
185184
|| (github.event_name == 'workflow_dispatch')
186185
|| (github.event_name == 'pull_request'
187186
&& startsWith(github.head_ref, 'tickets/')
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
### Bug fixes
2+
3+
- Allow group names where the only alphabetic character is the first character. This fixes a regression introduced in Gafaelfawr 13.0.1.

src/gafaelfawr/constants.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,9 @@
199199
CURSOR_REGEX = "^p?[0-9]+_[0-9]+$"
200200
"""Regex matching a valid cursor."""
201201

202-
GROUPNAME_REGEX = "^[a-zA-Z0-9][a-zA-Z0-9._-]*[a-zA-Z][a-zA-Z0-9._-]*$"
202+
GROUPNAME_REGEX = (
203+
"^([a-zA-Z]|[a-zA-Z0-9][a-zA-Z0-9._-]*[a-zA-Z])[a-zA-Z0-9._-]*$"
204+
)
203205
"""Regex matching all valid group names."""
204206

205207
SCOPE_REGEX = "^[a-zA-Z0-9:._-]+$"

tests/models/userinfo_test.py

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
"""Tests for user information models."""
2+
3+
from __future__ import annotations
4+
5+
import pytest
6+
from pydantic import ValidationError
7+
8+
from gafaelfawr.models.userinfo import Group
9+
10+
11+
def test_group_names() -> None:
12+
for valid in (
13+
"g_special_users",
14+
"rra",
15+
"19numbers",
16+
"G-12345",
17+
"group.name",
18+
"group1234",
19+
"19numbers19",
20+
"1-g",
21+
"12341-g-",
22+
):
23+
Group(name=valid, id=1234)
24+
25+
for invalid in ("12345", "rra#foo", "", "-rra", "_rra", "1-"):
26+
with pytest.raises(ValidationError):
27+
Group(name=invalid, id=1234)

0 commit comments

Comments
 (0)