Skip to content

Commit

Permalink
remove merge conflict rockstor#688
Browse files Browse the repository at this point in the history
  • Loading branch information
Mchakravartula committed Jun 24, 2015
1 parent d7c17f7 commit 10e2f09
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 6 deletions.
3 changes: 2 additions & 1 deletion buildout.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -158,4 +158,5 @@ update-command = ${docker:command}
recipe = plone.recipe.command
command = export DJANGO_SETTINGS_MODULE=settings &&
${buildout:directory}/bin/django dumpdata --exclude contenttypes --exclude auth.Permission --natural --indent 4 > ${buildout:directory}/src/rockstor/storageadmin/fixtures/newfixture.json
update-command = ${db-migrate:command}
update-command = ${db-migrate:command}

32 changes: 27 additions & 5 deletions src/rockstor/storageadmin/tests/test_user.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,10 @@ def test_get(self):
# get base URL
self.get_base(self.BASE_URL)

# get user with username admin2
response = self.client.get('%s/admin2' % self.BASE_URL)
self.assertEqual(response.status_code, status.HTTP_200_OK, msg=response)

def test_post_requests(self):
data = {'username': 'user1','password': 'pwuser1',}
invalid_user_names = ('User $', '-user', '.user', '', ' ',)
Expand All @@ -87,7 +91,11 @@ def test_post_requests(self):
status.HTTP_500_INTERNAL_SERVER_ERROR, msg=response.data)
e_msg = ("Username is invalid. It must confirm to the regex: [A-Za-z][-a-zA-Z0-9_]*$")
self.assertEqual(response.data['detail'], e_msg)





# username with more than 30 characters
invalid_user_name = 'user'*11
data = {'username': invalid_user_name,'password': 'pwadmin',}
response = self.client.post(self.BASE_URL, data=data)
Expand Down Expand Up @@ -125,7 +133,17 @@ def test_post_requests(self):
data = {'username': 'user1','password': 'pwuser1','email':'...'}
#response = self.client.post(self.BASE_URL, data=data)
#self.assertEqual(response.status_code,
# status.HTTP_500_INTERNAL_SERVER_ERROR, msg=response.data)
# status.HTTP_500_INTERNAL_SERVER_ERROR, msg=response.data)

# public_key
data = {'username': 'newUser','password': 'pwuser2','pubic_key':'xxx'}
self.mock_is_pub_key.side_effect = False
response = self.client.post(self.BASE_URL, data=data)
self.assertEqual(response.status_code,
status.HTTP_500_INTERNAL_SERVER_ERROR, msg=response.data)
e_msg = ("Public key is invalid")
self.assertEqual(response.data['detail'], e_msg)
self.mock_is_pub_key.side_effect = True

# create user with existing username
data = {'username': 'admin','password': 'pwadmin',}
Expand Down Expand Up @@ -192,7 +210,7 @@ def test_put_requests(self):
self.assertEqual(response.status_code,
status.HTTP_200_OK, msg=response.data)

data = {'password': 'admin2','group':'admin', 'user':'uadmin2', 'email':'admin2@xyz.com'}
data = {'password': 'admin2','group':'admin', 'user':'uadmin2','shell':'/bin/xyz', 'email':'admin2@xyz.com'}
response = self.client.put('%s/admin2' % self.BASE_URL, data=data)
self.assertEqual(response.status_code,
status.HTTP_200_OK, msg=response.data)
Expand Down Expand Up @@ -232,13 +250,17 @@ def test_delete_requests(self):
status.HTTP_500_INTERNAL_SERVER_ERROR, msg=response.data)
e_msg = ("Cannot delete the currently logged in user")
self.assertEqual(response.data['detail'], e_msg)



# happy path
# delete user
username = 'admin2'
response = self.client.delete('%s/%s' % (self.BASE_URL,username))
self.assertEqual(response.status_code,
status.HTTP_200_OK, msg=response.data)

username = 'admin3'
response = self.client.delete('%s/%s' % (self.BASE_URL,username))
self.assertEqual(response.status_code,
status.HTTP_200_OK, msg=response.data)


1 change: 1 addition & 0 deletions src/rockstor/storageadmin/views/user.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ def get_queryset(self, *args, **kwargs):
@transaction.atomic
def post(self, request):
with self._handle_exception(request):

invar = self._validate_input(request)
# Check that a django user with the same name does not exist
e_msg = ('user: %s already exists. Please choose a different'
Expand Down

0 comments on commit 10e2f09

Please sign in to comment.