Add e-mail authorization to the repository notification flow. Also validates the creation of the other notification methods.
This commit is contained in:
parent
56fec63fcd
commit
34fc279092
15 changed files with 483 additions and 34 deletions
|
@ -20,6 +20,7 @@ from endpoints.api.robot import UserRobotList, OrgRobot, OrgRobotList, UserRobot
|
|||
from endpoints.api.trigger import (BuildTriggerActivate, BuildTriggerSources, BuildTriggerSubdirs,
|
||||
TriggerBuildList, ActivateBuildTrigger, BuildTrigger,
|
||||
BuildTriggerList, BuildTriggerAnalyze)
|
||||
from endpoints.api.repoemail import RepositoryAuthorizedEmail
|
||||
from endpoints.api.repositorynotification import RepositoryNotification, RepositoryNotificationList
|
||||
from endpoints.api.user import (PrivateRepositories, ConvertToOrganization, Signout, Signin, User,
|
||||
UserAuthorizationList, UserAuthorization)
|
||||
|
@ -1082,6 +1083,50 @@ class TestRequestRepoBuild(ApiTestCase):
|
|||
expected_code=403)
|
||||
|
||||
|
||||
class TestRepositoryEmail(ApiTestCase):
|
||||
def test_emailnotauthorized(self):
|
||||
self.login(ADMIN_ACCESS_USER)
|
||||
|
||||
# Verify the e-mail address is not authorized.
|
||||
json = self.getResponse(RepositoryAuthorizedEmail,
|
||||
params=dict(repository=ADMIN_ACCESS_USER + '/simple', email='test@example.com'),
|
||||
expected_code=404)
|
||||
|
||||
def test_emailnotauthorized_butsent(self):
|
||||
self.login(ADMIN_ACCESS_USER)
|
||||
|
||||
# Verify the e-mail address is not authorized.
|
||||
json = self.getJsonResponse(RepositoryAuthorizedEmail,
|
||||
params=dict(repository=ADMIN_ACCESS_USER + '/simple', email='jschorr+other@devtable.com'))
|
||||
|
||||
self.assertEquals(False, json['confirmed'])
|
||||
self.assertEquals(ADMIN_ACCESS_USER, json['namespace'])
|
||||
self.assertEquals('simple', json['repository'])
|
||||
|
||||
|
||||
def test_emailauthorized(self):
|
||||
self.login(ADMIN_ACCESS_USER)
|
||||
|
||||
# Verify the e-mail address is authorized.
|
||||
json = self.getJsonResponse(RepositoryAuthorizedEmail,
|
||||
params=dict(repository=ADMIN_ACCESS_USER + '/simple', email='jschorr@devtable.com'))
|
||||
|
||||
self.assertEquals(True, json['confirmed'])
|
||||
self.assertEquals(ADMIN_ACCESS_USER, json['namespace'])
|
||||
self.assertEquals('simple', json['repository'])
|
||||
|
||||
|
||||
def test_send_email_authorization(self):
|
||||
self.login(ADMIN_ACCESS_USER)
|
||||
|
||||
# Send the email.
|
||||
json = self.postJsonResponse(RepositoryAuthorizedEmail,
|
||||
params=dict(repository=ADMIN_ACCESS_USER + '/simple', email='jschorr+foo@devtable.com'))
|
||||
|
||||
self.assertEquals(False, json['confirmed'])
|
||||
self.assertEquals(ADMIN_ACCESS_USER, json['namespace'])
|
||||
self.assertEquals('simple', json['repository'])
|
||||
|
||||
|
||||
class TestRepositoryNotifications(ApiTestCase):
|
||||
def test_webhooks(self):
|
||||
|
|
Reference in a new issue