summaryrefslogtreecommitdiffstats
path: root/tests/functional/authentication/test_authentication_allow_blank.py
blob: dab0baab3b30de07d12ddf10b1ae32635acddaf8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
#  Copyright (C) 2017-2018  Red Hat, Inc. <http://www.redhat.com>
#
#  This program is free software; you can redistribute it and/or modify
#  it under the terms of the GNU General Public License as published by
#  the Free Software Foundation; either version 2 of the License, or
#  any later version.
#
#  This program is distributed in the hope that it will be useful,
#  but WITHOUT ANY WARRANTY; without even the implied warranty of
#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#  GNU General Public License for more details.
#
#  You should have received a copy of the GNU General Public License along
#  with this program; if not, write to the Free Software Foundation, Inc.,
#  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.

""" Description
Test Case in this module is to set value of auth.allow to empty string
and check if it throws an error
"""
from glusto.core import Glusto as g
from glustolibs.gluster.gluster_base_class import (GlusterBaseClass,
                                                   runs_on)
from glustolibs.gluster.exceptions import ExecutionError
from glustolibs.gluster.gluster_init import is_glusterd_running
from glustolibs.gluster.volume_ops import set_volume_options
from glustolibs.gluster.volume_libs import cleanup_volume


@runs_on([['replicated', 'distributed-replicated', 'dispersed',
           'distributed-dispersed'],
          ['glusterfs']])
class AuthAllowEmptyString(GlusterBaseClass):
    """
    Tests to verify auth.allow functionality on Volume and Fuse subdir
    """
    def setUp(self):
        """
        Setup Volume
        """
        ret = self.setup_volume()
        if not ret:
            raise ExecutionError("Failed to setup volume")
        g.log.info("Volume %s has been setup successfully", self.volname)

        # Calling GlusterBaseClass Setup
        self.get_super_method(self, 'setUp')()

    def test_validate_authallow(self):
        """
        -Set Authentication allow as empty string for volume
        -Check if glusterd is running
        """
        # pylint: disable=too-many-statements

        # Set Authentication to blank string for volume
        option = {"auth.allow": " "}
        ret = set_volume_options(self.mnode, self.volname,
                                 option)
        self.assertFalse(ret, ("Unexpected: Authentication set successfully "
                               "for Volume with option: %s" % option))
        g.log.info("Expected: Failed to set authentication for Volume with "
                   "option: %s", option)

        # Check if glusterd is running
        ret = is_glusterd_running(self.servers)
        self.assertEqual(ret, 0, "Glusterd service not running")
        g.log.info("Expected : Glusterd service running")

    def tearDown(self):
        """
        TearDown for Volume
        Volume Cleanup
        """
        ret = cleanup_volume(self.mnode, self.volname)
        if not ret:
            raise ExecutionError("Failed to Cleanup the "
                                 "Volume %s" % self.volname)
        g.log.info("Volume deleted successfully "
                   ": %s", self.volname)