- Fix tests to not hit remote Redis endpoint
- Fix convert organization to allow admin email address, in addition to username - Add test for the above
This commit is contained in:
parent
3ebdf2c062
commit
b0c4f5b2f5
4 changed files with 32 additions and 10 deletions
|
@ -296,7 +296,8 @@ class ConvertToOrganization(ApiResource):
|
||||||
|
|
||||||
# Ensure that the sign in credentials work.
|
# Ensure that the sign in credentials work.
|
||||||
admin_password = convert_data['adminPassword']
|
admin_password = convert_data['adminPassword']
|
||||||
if not authentication.verify_user(admin_username, admin_password):
|
admin_user = authentication.verify_user(admin_username, admin_password)
|
||||||
|
if not admin_user:
|
||||||
raise request_error(reason='invaliduser',
|
raise request_error(reason='invaliduser',
|
||||||
message='The admin user credentials are not valid')
|
message='The admin user credentials are not valid')
|
||||||
|
|
||||||
|
@ -306,7 +307,7 @@ class ConvertToOrganization(ApiResource):
|
||||||
subscribe(user, plan, None, True) # Require business plans
|
subscribe(user, plan, None, True) # Require business plans
|
||||||
|
|
||||||
# Convert the user to an organization.
|
# Convert the user to an organization.
|
||||||
model.convert_user_to_organization(user, model.get_user(admin_username))
|
model.convert_user_to_organization(user, admin_user)
|
||||||
log_action('account_convert', user.username)
|
log_action('account_convert', user.username)
|
||||||
|
|
||||||
# And finally login with the admin credentials.
|
# And finally login with the admin credentials.
|
||||||
|
|
|
@ -53,6 +53,8 @@ READ_ACCESS_USER = 'reader'
|
||||||
ADMIN_ACCESS_USER = 'devtable'
|
ADMIN_ACCESS_USER = 'devtable'
|
||||||
PUBLIC_USER = 'public'
|
PUBLIC_USER = 'public'
|
||||||
|
|
||||||
|
ADMIN_ACCESS_EMAIL = 'jschorr@devtable.com'
|
||||||
|
|
||||||
ORG_REPO = 'orgrepo'
|
ORG_REPO = 'orgrepo'
|
||||||
|
|
||||||
ORGANIZATION = 'buynlarge'
|
ORGANIZATION = 'buynlarge'
|
||||||
|
@ -274,6 +276,28 @@ class TestConvertToOrganization(ApiTestCase):
|
||||||
self.assertEquals(True, json['is_admin'])
|
self.assertEquals(True, json['is_admin'])
|
||||||
|
|
||||||
|
|
||||||
|
def test_convert_via_email(self):
|
||||||
|
self.login(READ_ACCESS_USER)
|
||||||
|
json = self.postJsonResponse(ConvertToOrganization,
|
||||||
|
data={'adminUser': ADMIN_ACCESS_EMAIL,
|
||||||
|
'adminPassword': 'password',
|
||||||
|
'plan': 'free'})
|
||||||
|
|
||||||
|
self.assertEqual(True, json['success'])
|
||||||
|
|
||||||
|
# Verify the organization exists.
|
||||||
|
organization = model.get_organization(READ_ACCESS_USER)
|
||||||
|
assert organization is not None
|
||||||
|
|
||||||
|
# Verify the admin user is the org's admin.
|
||||||
|
self.login(ADMIN_ACCESS_USER)
|
||||||
|
json = self.getJsonResponse(Organization,
|
||||||
|
params=dict(orgname=READ_ACCESS_USER))
|
||||||
|
|
||||||
|
self.assertEquals(READ_ACCESS_USER, json['name'])
|
||||||
|
self.assertEquals(True, json['is_admin'])
|
||||||
|
|
||||||
|
|
||||||
class TestChangeUserDetails(ApiTestCase):
|
class TestChangeUserDetails(ApiTestCase):
|
||||||
def test_changepassword(self):
|
def test_changepassword(self):
|
||||||
self.login(READ_ACCESS_USER)
|
self.login(READ_ACCESS_USER)
|
||||||
|
@ -982,12 +1006,6 @@ class TestRepoBuilds(ApiTestCase):
|
||||||
|
|
||||||
self.assertEquals(status_json, build)
|
self.assertEquals(status_json, build)
|
||||||
|
|
||||||
# Check the logs.
|
|
||||||
logs_json = self.getJsonResponse(RepositoryBuildLogs,
|
|
||||||
params=dict(repository=ADMIN_ACCESS_USER + '/building', build_uuid=build['id']))
|
|
||||||
|
|
||||||
assert 'logs' in logs_json
|
|
||||||
|
|
||||||
class TestRequestRepoBuild(ApiTestCase):
|
class TestRequestRepoBuild(ApiTestCase):
|
||||||
def test_requestrepobuild(self):
|
def test_requestrepobuild(self):
|
||||||
self.login(ADMIN_ACCESS_USER)
|
self.login(ADMIN_ACCESS_USER)
|
||||||
|
|
|
@ -28,7 +28,7 @@ class TestConfig(DefaultConfig):
|
||||||
DISTRIBUTED_STORAGE_PREFERENCE = ['local_us']
|
DISTRIBUTED_STORAGE_PREFERENCE = ['local_us']
|
||||||
|
|
||||||
BUILDLOGS_MODULE_AND_CLASS = ('test.testlogs', 'testlogs.TestBuildLogs')
|
BUILDLOGS_MODULE_AND_CLASS = ('test.testlogs', 'testlogs.TestBuildLogs')
|
||||||
BUILDLOGS_OPTIONS = ['devtable', 'building', 'deadbeef-dead-beef-dead-beefdeadbeef']
|
BUILDLOGS_OPTIONS = ['devtable', 'building', 'deadbeef-dead-beef-dead-beefdeadbeef', False]
|
||||||
|
|
||||||
USERFILES_TYPE = 'FakeUserfiles'
|
USERFILES_TYPE = 'FakeUserfiles'
|
||||||
|
|
||||||
|
|
|
@ -42,11 +42,12 @@ class TestBuildLogs(RedisBuildLogs):
|
||||||
'pull_completion': 0.0,
|
'pull_completion': 0.0,
|
||||||
}
|
}
|
||||||
|
|
||||||
def __init__(self, redis_host, namespace, repository, test_build_id):
|
def __init__(self, redis_host, namespace, repository, test_build_id, allow_delegate=True):
|
||||||
super(TestBuildLogs, self).__init__(redis_host)
|
super(TestBuildLogs, self).__init__(redis_host)
|
||||||
self.namespace = namespace
|
self.namespace = namespace
|
||||||
self.repository = repository
|
self.repository = repository
|
||||||
self.test_build_id = test_build_id
|
self.test_build_id = test_build_id
|
||||||
|
self.allow_delegate = allow_delegate
|
||||||
self.remaining_script = self._generate_script()
|
self.remaining_script = self._generate_script()
|
||||||
logger.debug('Total script size: %s', len(self.remaining_script))
|
logger.debug('Total script size: %s', len(self.remaining_script))
|
||||||
self._logs = []
|
self._logs = []
|
||||||
|
@ -188,5 +189,7 @@ class TestBuildLogs(RedisBuildLogs):
|
||||||
returnable_status = self._last_status
|
returnable_status = self._last_status
|
||||||
self._last_status = self._status
|
self._last_status = self._status
|
||||||
return returnable_status
|
return returnable_status
|
||||||
|
elif not self.allow_delegate:
|
||||||
|
return None
|
||||||
else:
|
else:
|
||||||
return super(TestBuildLogs, self).get_status(build_id)
|
return super(TestBuildLogs, self).get_status(build_id)
|
||||||
|
|
Reference in a new issue