예제 #1
0
    def test_create_user(self):
        """
        Tests to create user accounts
        """
        self.assertFalse(
            drac.create_user("username", "password", "permissions",
                             {"username": None}))

        mock = MagicMock(return_value=False)
        with patch.object(drac, "__execute_cmd", mock):
            mock = MagicMock(return_value=None)
            with patch.object(drac, "delete_user", mock):
                self.assertFalse(
                    drac.create_user(
                        "username",
                        "password",
                        "permissions",
                        {"username1": {
                            "index": 1
                        }},
                    ))

        mock = MagicMock(return_value=True)
        with patch.object(drac, "__execute_cmd", mock):
            mock = MagicMock(return_value=False)
            with patch.object(drac, "set_permissions", mock):
                mock = MagicMock(return_value=None)
                with patch.object(drac, "delete_user", mock):
                    self.assertFalse(
                        drac.create_user(
                            "username",
                            "password",
                            "permissions",
                            {"username1": {
                                "index": 1
                            }},
                        ))

            mock = MagicMock(return_value=True)
            with patch.object(drac, "set_permissions", mock):
                mock = MagicMock(return_value=False)
                with patch.object(drac, "change_password", mock):
                    mock = MagicMock(return_value=None)
                    with patch.object(drac, "delete_user", mock):
                        self.assertFalse(
                            drac.create_user(
                                "username",
                                "password",
                                "permissions",
                                {"username1": {
                                    "index": 1
                                }},
                            ))

        mock = MagicMock(side_effect=[True, False])
        with patch.object(drac, "__execute_cmd", mock):
            mock = MagicMock(return_value=True)
            with patch.object(drac, "set_permissions", mock):
                mock = MagicMock(return_value=True)
                with patch.object(drac, "change_password", mock):
                    mock = MagicMock(return_value=None)
                    with patch.object(drac, "delete_user", mock):
                        self.assertFalse(
                            drac.create_user(
                                "username",
                                "password",
                                "permissions",
                                {"username1": {
                                    "index": 1
                                }},
                            ))

        mock = MagicMock(side_effect=[True, True])
        with patch.object(drac, "__execute_cmd", mock):
            mock = MagicMock(return_value=True)
            with patch.object(drac, "set_permissions", mock):
                mock = MagicMock(return_value=True)
                with patch.object(drac, "change_password", mock):
                    mock = MagicMock(return_value=None)
                    with patch.object(drac, "delete_user", mock):
                        self.assertTrue(
                            drac.create_user(
                                "username",
                                "password",
                                "permissions",
                                {"username1": {
                                    "index": 1
                                }},
                            ))
예제 #2
0
    def test_create_user(self):
        '''
        Tests to create user accounts
        '''
        self.assertFalse(
            drac.create_user('username', 'password', 'permissions',
                             {'username': None}))

        mock = MagicMock(return_value=False)
        with patch.object(drac, '__execute_cmd', mock):
            mock = MagicMock(return_value=None)
            with patch.object(drac, 'delete_user', mock):
                self.assertFalse(
                    drac.create_user('username', 'password', 'permissions',
                                     {'username1': {
                                         'index': 1
                                     }}))

        mock = MagicMock(return_value=True)
        with patch.object(drac, '__execute_cmd', mock):
            mock = MagicMock(return_value=False)
            with patch.object(drac, 'set_permissions', mock):
                mock = MagicMock(return_value=None)
                with patch.object(drac, 'delete_user', mock):
                    self.assertFalse(
                        drac.create_user('username', 'password', 'permissions',
                                         {'username1': {
                                             'index': 1
                                         }}))

            mock = MagicMock(return_value=True)
            with patch.object(drac, 'set_permissions', mock):
                mock = MagicMock(return_value=False)
                with patch.object(drac, 'change_password', mock):
                    mock = MagicMock(return_value=None)
                    with patch.object(drac, 'delete_user', mock):
                        self.assertFalse(
                            drac.create_user('username', 'password',
                                             'permissions',
                                             {'username1': {
                                                 'index': 1
                                             }}))

        mock = MagicMock(side_effect=[True, False])
        with patch.object(drac, '__execute_cmd', mock):
            mock = MagicMock(return_value=True)
            with patch.object(drac, 'set_permissions', mock):
                mock = MagicMock(return_value=True)
                with patch.object(drac, 'change_password', mock):
                    mock = MagicMock(return_value=None)
                    with patch.object(drac, 'delete_user', mock):
                        self.assertFalse(
                            drac.create_user('username', 'password',
                                             'permissions',
                                             {'username1': {
                                                 'index': 1
                                             }}))

        mock = MagicMock(side_effect=[True, True])
        with patch.object(drac, '__execute_cmd', mock):
            mock = MagicMock(return_value=True)
            with patch.object(drac, 'set_permissions', mock):
                mock = MagicMock(return_value=True)
                with patch.object(drac, 'change_password', mock):
                    mock = MagicMock(return_value=None)
                    with patch.object(drac, 'delete_user', mock):
                        self.assertTrue(
                            drac.create_user('username', 'password',
                                             'permissions',
                                             {'username1': {
                                                 'index': 1
                                             }}))
예제 #3
0
파일: drac_test.py 프로젝트: DaveQB/salt
    def test_create_user(self):
        '''
        Tests to create user accounts
        '''
        self.assertFalse(drac.create_user('username', 'password',
                                          'permissions', {'username': None}))

        mock = MagicMock(return_value=False)
        with patch.object(drac, '__execute_cmd', mock):
            mock = MagicMock(return_value=None)
            with patch.object(drac, 'delete_user', mock):
                self.assertFalse(drac.create_user('username', 'password',
                                                  'permissions',
                                                  {'username1': {'index': 1}}))

        mock = MagicMock(return_value=True)
        with patch.object(drac, '__execute_cmd', mock):
            mock = MagicMock(return_value=False)
            with patch.object(drac, 'set_permissions', mock):
                mock = MagicMock(return_value=None)
                with patch.object(drac, 'delete_user', mock):
                    self.assertFalse(drac.create_user('username', 'password',
                                                      'permissions',
                                                      {'username1':
                                                       {'index': 1}}))

            mock = MagicMock(return_value=True)
            with patch.object(drac, 'set_permissions', mock):
                mock = MagicMock(return_value=False)
                with patch.object(drac, 'change_password', mock):
                    mock = MagicMock(return_value=None)
                    with patch.object(drac, 'delete_user', mock):
                        self.assertFalse(drac.create_user('username',
                                                          'password',
                                                          'permissions',
                                                          {'username1':
                                                           {'index': 1}}))

        mock = MagicMock(side_effect=[True, False])
        with patch.object(drac, '__execute_cmd', mock):
            mock = MagicMock(return_value=True)
            with patch.object(drac, 'set_permissions', mock):
                mock = MagicMock(return_value=True)
                with patch.object(drac, 'change_password', mock):
                    mock = MagicMock(return_value=None)
                    with patch.object(drac, 'delete_user', mock):
                        self.assertFalse(drac.create_user('username',
                                                          'password',
                                                          'permissions',
                                                          {'username1':
                                                           {'index': 1}}))

        mock = MagicMock(side_effect=[True, True])
        with patch.object(drac, '__execute_cmd', mock):
            mock = MagicMock(return_value=True)
            with patch.object(drac, 'set_permissions', mock):
                mock = MagicMock(return_value=True)
                with patch.object(drac, 'change_password', mock):
                    mock = MagicMock(return_value=None)
                    with patch.object(drac, 'delete_user', mock):
                        self.assertTrue(drac.create_user('username',
                                                         'password',
                                                         'permissions',
                                                         {'username1':
                                                          {'index': 1}}))