Skip to content

Commit

Permalink
ci: merge main to release (pull request #7313)
Browse files Browse the repository at this point in the history
ci: merge main to release
  • Loading branch information
rjsparks authored Apr 10, 2024
2 parents c41c0bb + b76fad1 commit b528b3c
Show file tree
Hide file tree
Showing 28 changed files with 272 additions and 133 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ jobs:
path: geckodriver.log

- name: Upload Coverage Results to Codecov
uses: codecov/[email protected].0
uses: codecov/[email protected].1
with:
files: coverage.xml

Expand Down
77 changes: 39 additions & 38 deletions .pnp.cjs

Large diffs are not rendered by default.

Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
28 changes: 21 additions & 7 deletions dev/coverage-action/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dev/coverage-action/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,6 @@
"eslint-plugin-import": "2.29.1",
"eslint-plugin-node": "11.1.0",
"eslint-plugin-promise": "6.1.1",
"npm-check-updates": "16.14.17"
"npm-check-updates": "16.14.18"
}
}
14 changes: 7 additions & 7 deletions dev/deploy-to-container/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dev/deploy-to-container/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"nanoid": "5.0.6",
"nanoid-dictionary": "5.0.0-beta.1",
"slugify": "1.6.6",
"tar": "^6.2.0",
"tar": "^6.2.1",
"yargs": "^17.7.2"
},
"engines": {
Expand Down
14 changes: 7 additions & 7 deletions dev/diff/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dev/diff/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"lodash-es": "^4.17.21",
"luxon": "^3.4.4",
"pretty-bytes": "^6.1.1",
"tar": "^6.2.0",
"tar": "^6.2.1",
"yargs": "^17.7.2"
},
"engines": {
Expand Down
26 changes: 24 additions & 2 deletions ietf/api/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -901,7 +901,7 @@ def test_api_get_session_matherials_no_agenda_meeting_url(self):
r = self.client.get(url)
self.assertEqual(r.status_code, 200)

@override_settings(APP_API_TOKENS={"ietf.api.views.email_aliases": ["valid-token"]})
@override_settings(APP_API_TOKENS={"ietf.api.views.draft_aliases": ["valid-token"]})
@mock.patch("ietf.api.views.DraftAliasGenerator")
def test_draft_aliases(self, mock):
mock.return_value = (("alias1", ("a1", "a2")), ("alias2", ("a3", "a4")))
Expand Down Expand Up @@ -935,7 +935,7 @@ def test_draft_aliases(self, mock):
405,
)

@override_settings(APP_API_TOKENS={"ietf.api.views.email_aliases": ["valid-token"]})
@override_settings(APP_API_TOKENS={"ietf.api.views.group_aliases": ["valid-token"]})
@mock.patch("ietf.api.views.GroupAliasGenerator")
def test_group_aliases(self, mock):
mock.return_value = (("alias1", ("ietf",), ("a1", "a2")), ("alias2", ("ietf", "iab"), ("a3", "a4")))
Expand Down Expand Up @@ -991,6 +991,28 @@ def test_active_email_list(self):
self.assertCountEqual(result.keys(), ["addresses"])
self.assertCountEqual(result["addresses"], Email.objects.filter(active=True).values_list("address", flat=True))

@override_settings(APP_API_TOKENS={"ietf.api.views.role_holder_addresses": ["valid-token"]})
def test_role_holder_addresses(self):
url = urlreverse("ietf.api.views.role_holder_addresses")
r = self.client.get(url, headers={})
self.assertEqual(r.status_code, 403, "No api token, no access")
r = self.client.get(url, headers={"X-Api-Key": "not-valid-token"})
self.assertEqual(r.status_code, 403, "Bad api token, no access")
r = self.client.post(url, headers={"X-Api-Key": "valid-token"})
self.assertEqual(r.status_code, 405, "Bad method, no access")

emails = EmailFactory.create_batch(5)
email_queryset = Email.objects.filter(pk__in=[e.pk for e in emails])
with mock.patch("ietf.api.views.role_holder_emails", return_value=email_queryset):
r = self.client.get(url, headers={"X-Api-Key": "valid-token"})
self.assertEqual(r.status_code, 200, "Good api token and method, access")
content_dict = json.loads(r.content)
self.assertCountEqual(content_dict.keys(), ["addresses"])
self.assertEqual(
content_dict["addresses"],
sorted(e.address for e in emails),
)


class DirectAuthApiTests(TestCase):

Expand Down
2 changes: 2 additions & 0 deletions ietf/api/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@
url(r'^export/personal-information/$', api_views.PersonalInformationExportView.as_view()),
# Email alias information for groups
url(r'^group/group-aliases/$', api_views.group_aliases),
# Email addresses belonging to role holders
url(r'^group/role-holder-addresses/$', api_views.role_holder_addresses),
# Let IESG members set positions programmatically
url(r'^iesg/position', views_ballot.api_set_position),
# Let Meetecho set session video URLs
Expand Down
21 changes: 18 additions & 3 deletions ietf/api/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
from ietf.api.ietf_utils import is_valid_token, requires_api_token
from ietf.api.serializer import JsonExportMixin
from ietf.doc.utils import DraftAliasGenerator, fuzzy_find_documents
from ietf.group.utils import GroupAliasGenerator
from ietf.group.utils import GroupAliasGenerator, role_holder_emails
from ietf.ietfauth.utils import role_required
from ietf.ietfauth.views import send_account_creation_email
from ietf.meeting.models import Meeting
Expand Down Expand Up @@ -452,7 +452,7 @@ def directauth(request):
return HttpResponse(status=405)


@requires_api_token("ietf.api.views.email_aliases")
@requires_api_token
@csrf_exempt
def draft_aliases(request):
if request.method == "GET":
Expand All @@ -471,7 +471,7 @@ def draft_aliases(request):
return HttpResponse(status=405)


@requires_api_token("ietf.api.views.email_aliases")
@requires_api_token
@csrf_exempt
def group_aliases(request):
if request.method == "GET":
Expand Down Expand Up @@ -500,3 +500,18 @@ def active_email_list(request):
}
)
return HttpResponse(status=405)


@requires_api_token
def role_holder_addresses(request):
if request.method == "GET":
return JsonResponse(
{
"addresses": list(
role_holder_emails()
.order_by("address")
.values_list("address", flat=True)
)
}
)
return HttpResponse(status=405)
22 changes: 6 additions & 16 deletions ietf/doc/views_doc.py
Original file line number Diff line number Diff line change
Expand Up @@ -1547,21 +1547,12 @@ def document_ballot_content(request, doc, ballot_id, editable=True):

def document_ballot(request, name, ballot_id=None):
doc = get_object_or_404(Document, name=name)
all_ballots = list(BallotDocEvent.objects.filter(doc=doc, type="created_ballot").order_by("time"))
if not ballot_id:
if all_ballots:
ballot = all_ballots[-1]
else:
raise Http404("Ballot not found for: %s" % name)
ballot_id = ballot.id
ballots = BallotDocEvent.objects.filter(doc=doc, type="created_ballot").order_by("time")
if ballot_id is not None:
ballot = ballots.filter(id=ballot_id).first()
else:
ballot_id = int(ballot_id)
for b in all_ballots:
if b.id == ballot_id:
ballot = b
break

if not ballot_id or not ballot:
ballot = ballots.last()
if not ballot:
raise Http404("Ballot not found for: %s" % name)

if ballot.ballot_type.slug == "irsg-approve":
Expand All @@ -1571,14 +1562,13 @@ def document_ballot(request, name, ballot_id=None):

top = render_document_top(request, doc, ballot_tab, name)

c = document_ballot_content(request, doc, ballot_id, editable=True)
c = document_ballot_content(request, doc, ballot.id, editable=True)
request.session['ballot_edit_return_point'] = request.path_info

return render(request, "doc/document_ballot.html",
dict(doc=doc,
top=top,
ballot_content=c,
# ballot_type_slug=ballot.ballot_type.slug,
))

def document_irsg_ballot(request, name, ballot_id=None):
Expand Down
48 changes: 46 additions & 2 deletions ietf/group/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,16 @@
from ietf.doc.factories import DocumentFactory, WgDraftFactory, EditorialDraftFactory
from ietf.doc.models import DocEvent, RelatedDocument, Document
from ietf.group.models import Role, Group
from ietf.group.utils import get_group_role_emails, get_child_group_role_emails, get_group_ad_emails, GroupAliasGenerator
from ietf.group.utils import (
get_group_role_emails,
get_child_group_role_emails,
get_group_ad_emails,
GroupAliasGenerator,
role_holder_emails,
)
from ietf.group.factories import GroupFactory, RoleFactory
from ietf.person.factories import PersonFactory, EmailFactory
from ietf.person.models import Person
from ietf.person.models import Email, Person
from ietf.utils.test_utils import login_testing_unauthorized, TestCase

class StreamTests(TestCase):
Expand Down Expand Up @@ -240,3 +246,41 @@ def test_group_ad_emails(self):
self.assertGreater(len(emails), 0)
for item in emails:
self.assertIn('@', item)

def test_role_holder_emails(self):
# The test fixtures create a bunch of addresses that pollute this test's results - disable them
Email.objects.update(active=False)

role_holders = [
RoleFactory(name_id="member", group__type_id=gt).person
for gt in [
"ag",
"area",
"dir",
"iab",
"ietf",
"irtf",
"nomcom",
"rg",
"team",
"wg",
"rag",
]
]
# Expect an additional active email to be included
EmailFactory(
person=role_holders[0],
active=True,
)
# Do not expect an inactive email to be included
EmailFactory(
person=role_holders[1],
active=False,
)
# Do not expect address on a role-holder for a different group type
RoleFactory(name_id="member", group__type_id="adhoc") # arbitrary type not in the of-interest list

self.assertCountEqual(
role_holder_emails(),
Email.objects.filter(active=True, person__in=role_holders),
)
Loading

0 comments on commit b528b3c

Please sign in to comment.