Skip to content

Commit

Permalink
Merge 16209d1 into d0c163b
Browse files Browse the repository at this point in the history
  • Loading branch information
hluk committed Nov 20, 2023
2 parents d0c163b + 16209d1 commit 53c15f0
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 17 deletions.
13 changes: 12 additions & 1 deletion tests/test_api_v10.py
Original file line number Diff line number Diff line change
Expand Up @@ -886,7 +886,10 @@ def test_permissions_endpoint(client):
"maintainers": ["alice@example.com"],
"_testcase_regex_pattern": "^kernel-qe",
"groups": ["devel", "qa"],
"users": ["alice@example.com"],
"users": [
"alice@example.com",
"bob@example.com",
],
},
{
"name": "Greenwave Tests",
Expand Down Expand Up @@ -924,9 +927,17 @@ def test_permissions_endpoint(client):
r = client.get('/api/v1.0/permissions?testcase=greenwave-tests.test1&html=1')
assert r.status_code == 200
assert r.content_type.startswith('text/html')
with open('permissions2.html', 'w') as f: f.write(r.text)
assert f"<td>{config['PERMISSIONS'][0]['name']}</td>" not in r.text
assert f"<td>{config['PERMISSIONS'][1]['name']}</td>" in r.text

r = client.get('/api/v1.0/permissions?testcase=kernel-qe.test1&html=1')
assert r.status_code == 200
assert r.content_type.startswith('text/html')
with open('permissions.html', 'w') as f: f.write(r.text)
assert "<td><div>alice@example.com</div><div>bob@example.com</div></td>" in r.text
assert "<td><div>devel</div><div>qa</div></td>" in r.text


def test_config_endpoint_superusers(client):
config = {
Expand Down
3 changes: 1 addition & 2 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
[tox]
envlist = bandit,lint,py311,docs
envlist = bandit,lint,py3,docs
isolated_build = True

[testenv]
basepython = python3.11
extras =
test
commands =
Expand Down
25 changes: 11 additions & 14 deletions waiverdb/templates/permissions.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,28 +14,25 @@
<th>Name</th>
<th>Maintainers</th>
<th>Testcases</th>
<th>Users/Groups</th>
<th>Groups</th>
<th>Users</th>
<th>Description</th>
</tr>
</thead>
<tbody>
{% for p in permissions -%}
<tr>
<td>{{ p["name"] }}</td>
<td>{{ p["maintainers"] | map("urlize") | join(" ") | safe }}</td>
<td>{{ p["testcases"] | join("<br />") | replace('-', '&#8209;') | safe }}</td>
<td>
{% if p["groups"] | length > 0 -%}
<span class="font-weight-bold">Groups:</span><br />
{{ p["groups"] | join("<br />") | replace('-', '&#8209;') | safe }}
{% if p["users"] | length > 0 -%}
<br />
{%- endif %}
{%- endif %}
{% if p["users"] | length > 0 -%}
<span class="font-weight-bold">Users:</span><br />
{{ p["users"] | join("<br />") | replace('-', '&#8209;') | safe }}
{%- endif %}
{% for maintainer in p["maintainers"] %}<div>{{ maintainer | urlize }}</div>{% endfor %}
</td>
<td>
<div>{{ p["_testcase_regex_pattern"] }}</div>
{% for testcase in p["testcases"] %}<div>{{ testcase }}</div>{% endfor %}
</td>
<td>{% for group in p["groups"] %}<div>{{ group }}</div>{% endfor %}</td>
<td>{% for user in p["users"] %}<div>{{ user }}</div>{% endfor %}</td>
<td>{{ p["description"] }}</td>
</tr>
{%- endfor %}
</tbody>
Expand Down

0 comments on commit 53c15f0

Please sign in to comment.