2121from ietf .group .factories import GroupFactory , RoleFactory
2222from ietf .ietfauth .htpasswd import update_htpasswd_file
2323from ietf .mailinglists .models import Subscribed
24- from ietf .person .models import Person , Email , PersonalApiKey , PERSON_API_KEY_ENDPOINTS
24+ from ietf .person .models import Person , Email , PersonalApiKey
2525from ietf .person .factories import PersonFactory , EmailFactory
2626from ietf .review .factories import ReviewRequestFactory , ReviewAssignmentFactory
2727from ietf .review .models import ReviewWish , UnavailablePeriod
@@ -531,18 +531,19 @@ def test_apikey_management(self):
531531 self .assertContains (r , 'Endpoint' )
532532
533533 # Add 2 keys
534- for endpoint , display in PERSON_API_KEY_ENDPOINTS :
534+ endpoints = person .available_api_endpoints ()
535+ for endpoint , display in endpoints :
535536 r = self .client .post (url , {'endpoint' : endpoint })
536537 self .assertRedirects (r , urlreverse ('ietf.ietfauth.views.apikey_index' ))
537538
538539 # Check api key list content
539540 url = urlreverse ('ietf.ietfauth.views.apikey_index' )
540541 r = self .client .get (url )
541- for endpoint , display in PERSON_API_KEY_ENDPOINTS :
542+ for endpoint , display in endpoints :
542543 self .assertContains (r , endpoint )
543544 q = PyQuery (r .content )
544- self .assertEqual (len (q ('td code' )), len (PERSON_API_KEY_ENDPOINTS )) # hash
545- self .assertEqual (len (q ('td a:contains("Disable")' )), len (PERSON_API_KEY_ENDPOINTS ))
545+ self .assertEqual (len (q ('td code' )), len (endpoints )) # hash
546+ self .assertEqual (len (q ('td a:contains("Disable")' )), len (endpoints ))
546547
547548 # Get one of the keys
548549 key = person .apikeys .first ()
@@ -562,8 +563,8 @@ def test_apikey_management(self):
562563 url = urlreverse ('ietf.ietfauth.views.apikey_index' )
563564 r = self .client .get (url )
564565 q = PyQuery (r .content )
565- self .assertEqual (len (q ('td code' )), len (PERSON_API_KEY_ENDPOINTS )) # key hash
566- self .assertEqual (len (q ('td a:contains("Disable")' )), len (PERSON_API_KEY_ENDPOINTS )- 1 )
566+ self .assertEqual (len (q ('td code' )), len (endpoints )) # key hash
567+ self .assertEqual (len (q ('td a:contains("Disable")' )), len (endpoints )- 1 )
567568
568569 def test_apikey_errors (self ):
569570 BAD_KEY = "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"
@@ -577,7 +578,7 @@ def test_apikey_errors(self):
577578 login_testing_unauthorized (self , person .user .username , url )
578579
579580 # Add keys
580- for endpoint , display in PERSON_API_KEY_ENDPOINTS :
581+ for endpoint , display in person . available_api_endpoints () :
581582 r = self .client .post (url , {'endpoint' : endpoint })
582583 self .assertRedirects (r , urlreverse ('ietf.ietfauth.views.apikey_index' ))
583584
@@ -620,7 +621,8 @@ def test_send_apikey_report(self):
620621 login_testing_unauthorized (self , person .user .username , url )
621622
622623 # Add keys
623- for endpoint , display in PERSON_API_KEY_ENDPOINTS :
624+ endpoints = person .available_api_endpoints ()
625+ for endpoint , display in endpoints :
624626 r = self .client .post (url , {'endpoint' : endpoint })
625627 self .assertRedirects (r , urlreverse ('ietf.ietfauth.views.apikey_index' ))
626628
@@ -639,7 +641,7 @@ def test_send_apikey_report(self):
639641 cmd = Command ()
640642 cmd .handle (verbosity = 0 , days = 7 )
641643
642- self .assertEqual (len (outbox ), len (PERSON_API_KEY_ENDPOINTS ))
644+ self .assertEqual (len (outbox ), len (endpoints ))
643645 for mail in outbox :
644646 body = mail .get_payload (decode = True ).decode ('utf-8' )
645647 self .assertIn ("API key usage" , mail ['subject' ])
0 commit comments