Example #1
0
    def test_03_remove_authorized_keys(self):
        # 0 keys left in a empty authorized_keys
        self.assertEquals(0, git.remove_authorized_keys([]))        

        # adding one key
        self.assertEquals(1, git.add_authorized_keys([ "ssh-rsa test ema@mars" ]))

        # we should now have exactly 1 authorized key
        self.assertEquals(1, len(git.get_authorized_keys()))

        # adding another key
        self.assertEquals(1, git.add_authorized_keys([ "ssh-rsa test2 ema@mars" ]))

        # we should now have exactly 2 authorized keys
        self.assertEquals(2, len(git.get_authorized_keys()))

        # adding another key
        self.assertEquals(1, git.add_authorized_keys([ "ssh-rsa test3 ema@mars" ]))

        # we should now have exactly 3 authorized keys
        self.assertEquals(3, len(git.get_authorized_keys()))

        # removing a single key should leave us with 2 keys
        self.assertEquals(2, git.remove_authorized_keys([ "ssh-rsa test2 ema@mars" ]))

        # we should now have exactly 2 authorized keys
        self.assertEquals(2, len(git.get_authorized_keys()))

        # removing the two remaining keys
        self.assertEquals(0, git.remove_authorized_keys(
                [ "ssh-rsa test ema@mars", "ssh-rsa test3 ema@mars" ]
        ))

        # we should now have no authorized_key left
        self.assertEquals(0, len(git.get_authorized_keys()))
Example #2
0
    def list_authorized_keys(self, kwargs):
        if len(kwargs) != 0:
            ex = ManagerException(ManagerException.E_ARGS_UNEXPECTED,
                                  kwargs.keys())
            return HttpErrorResponse(ex.message)

        return HttpJsonResponse({'authorizedKeys' : git.get_authorized_keys()})
Example #3
0
    def list_authorized_keys(self, kwargs):
        if len(kwargs) != 0:
            return HttpErrorResponse(
                ManagerException(ManagerException.E_ARGS_UNEXPECTED,
                                 kwargs.keys()).message)

        return HttpJsonResponse({'authorizedKeys': git.get_authorized_keys()})
Example #4
0
    def test_02_add_authorized_keys(self):
        new_keys = [ "ssh-rsa test123 ema@uranus" ]

        # add_authorized_keys should return 1 on successful insertion
        self.assertEquals(1, git.add_authorized_keys(new_keys))

        # add_authorized_keys should return 0 if the key is already present
        self.assertEquals(0, git.add_authorized_keys(new_keys))

        # we should now have exactly 1 authorized key
        self.assertEquals(1, len(git.get_authorized_keys()))

        # adding a new one
        self.assertEquals(1, git.add_authorized_keys([ "ssh-rsa test ema@mars" ]))

        # we should now have exactly 2 authorized keys
        self.assertEquals(2, len(git.get_authorized_keys()))
Example #5
0
    def list_authorized_keys(self, kwargs):
        try:
            exp_params = []
            check_arguments(exp_params, kwargs)
        except Exception as ex:
            return HttpErrorResponse("%s" % ex)

        return HttpJsonResponse({'authorizedKeys' : git.get_authorized_keys()})
Example #6
0
 def test_01_empty_authorized_keys(self):
     # get_authorized_keys should return 0 with an empty file
     self.assertEquals(0, len(git.get_authorized_keys()))
Example #7
0
 def test_01_empty_authorized_keys(self):
     # get_authorized_keys should return 0 with an empty file
     self.assertEquals(0, len(git.get_authorized_keys()))