コード例 #1
0
    def test_check_args_mendatory(self):
        """Test check_args_mendatory :
           -<empty>
        """
        sys.argv = [sys.argv[0]]

        try:
            out = StringIO()
            sys.stdout = out
            check_samba.main()
        except SystemExit, e:
            self.assertEquals(type(e), type(SystemExit()))
            self.assertEquals(e.code, 3)
            output = out.getvalue().strip()
            assert output.startswith("""UNKNOWN - Argument '""")
コード例 #2
0
 def test_help(self):
     """Test help output :
        -h
     """
     sys.argv = [sys.argv[0]]
     sys.argv.append('-h')
     try:
         out = StringIO()
         sys.stdout = out
         check_samba.main()
     except SystemExit, e:
         self.assertEquals(type(e), type(SystemExit()))
         self.assertEquals(e.code, 3)
         output = out.getvalue().strip()
         assert output.startswith("""check_samba""")
コード例 #3
0
 def test_help(self):
     """Test help output :
        -h
     """
     sys.argv = [sys.argv[0]]
     sys.argv.append('-h')
     try:
         out = StringIO()
         sys.stdout = out
         check_samba.main()
     except SystemExit, e:
         self.assertEquals(type(e), type(SystemExit()))
         self.assertEquals(e.code, 3)
         output = out.getvalue().strip()
         assert output.startswith("""check_samba""")
コード例 #4
0
    def test_check_args_mendatory(self):
        """Test check_args_mendatory :
           -<empty>
        """
        sys.argv = [sys.argv[0]]

        try:
            out = StringIO()
            sys.stdout = out
            check_samba.main()
        except SystemExit, e:
            self.assertEquals(type(e), type(SystemExit()))
            self.assertEquals(e.code, 3)
            output = out.getvalue().strip()
            assert output.startswith("""UNKNOWN - Argument '""")
コード例 #5
0
    def test_bad_options(self):
        """Test check_args :
           -X
        """
        sys.argv = [sys.argv[0]]
        sys.argv.append('-X')

        try:
            out = StringIO()
            sys.stdout = out
            check_samba.main()
        except SystemExit, e:
            self.assertEquals(type(e), type(SystemExit()))
            self.assertEquals(e.code, 3)
            output = out.getvalue().strip()
            assert output.startswith("""option """)
コード例 #6
0
 def test_version(self):
     """Test version output :
        -V
     """
     sys.argv = [sys.argv[0]]
     sys.argv.append('-V')
     try:
         out = StringIO()
         sys.stdout = out
         check_samba.main()
     except SystemExit, e:
         self.assertEquals(type(e), type(SystemExit()))
         self.assertEquals(e.code, 3)
         output = out.getvalue().strip()
         assert output.startswith("check_samba.py v%s" %
                                  check_samba.PLUGIN_VERSION)
コード例 #7
0
 def test_bad_options(self):
     """Test check_args :
        -X
     """
     sys.argv = [sys.argv[0]]
     sys.argv.append('-X')
     
     try:
         out = StringIO()
         sys.stdout = out
         check_samba.main()
     except SystemExit, e:
         self.assertEquals(type(e), type(SystemExit()))
         self.assertEquals(e.code, 3)
         output = out.getvalue().strip()
         assert output.startswith("""option """)
コード例 #8
0
 def test_version(self):
     """Test version output :
        -V
     """
     sys.argv = [sys.argv[0]]
     sys.argv.append('-V')
     try:
         out = StringIO()
         sys.stdout = out
         check_samba.main()
     except SystemExit, e:
         self.assertEquals(type(e), type(SystemExit()))
         self.assertEquals(e.code, 3)
         output = out.getvalue().strip()
         assert output.startswith("check_samba.py v%s"
                                  % check_samba.PLUGIN_VERSION)
コード例 #9
0
    def test_bad_hostname(self):
        """Test bad_hostname :
           -H foo-bar -s test_shinken
        """
        sys.argv = [sys.argv[0]]
        sys.argv.append('-H')
        sys.argv.append('foo-bar')
        sys.argv.append('-s')
        sys.argv.append('test_shinken')

        try:
            out = StringIO()
            sys.stdout = out
            check_samba.main()
        except SystemExit, e:
            self.assertEquals(type(e), type(SystemExit()))
            self.assertEquals(e.code, 2)
            output = out.getvalue().strip()
            assert output.startswith("""CRITICAL - Can't connect to """)
コード例 #10
0
    def test_bad_ip(self):
        """Test bad_ip :
           -H 992.168.50.254 -s test_shinken
        """
        sys.argv = [sys.argv[0]]
        sys.argv.append('-H')
        sys.argv.append('192.168.50.254')
        sys.argv.append('-s')
        sys.argv.append('test_shinken')

        try:
            out = StringIO()
            sys.stdout = out
            check_samba.main()
        except SystemExit, e:
            self.assertEquals(type(e), type(SystemExit()))
            self.assertEquals(e.code, 2)
            output = out.getvalue().strip()
            assert output.startswith("""CRITICAL - UNKNOWN Ip address :""")
コード例 #11
0
 def test_bad_hostname(self):
     """Test bad_hostname :
        -H foo-bar -s test_shinken
     """
     sys.argv = [sys.argv[0]]
     sys.argv.append('-H')
     sys.argv.append('foo-bar')
     sys.argv.append('-s')
     sys.argv.append('test_shinken')
     
     try:
         out = StringIO()
         sys.stdout = out
         check_samba.main()
     except SystemExit, e:
         self.assertEquals(type(e), type(SystemExit()))
         self.assertEquals(e.code, 2)
         output = out.getvalue().strip()
         assert output.startswith("""CRITICAL - Can't connect to """)
コード例 #12
0
 def test_bad_ip(self):
     """Test bad_ip :
        -H 992.168.50.254 -s test_shinken
     """
     sys.argv = [sys.argv[0]]
     sys.argv.append('-H')
     sys.argv.append('192.168.50.254')
     sys.argv.append('-s')
     sys.argv.append('test_shinken')
     
     try:
         out = StringIO()
         sys.stdout = out
         check_samba.main()
     except SystemExit, e:
         self.assertEquals(type(e), type(SystemExit()))
         self.assertEquals(e.code, 2)
         output = out.getvalue().strip()
         assert output.startswith("""CRITICAL - UNKNOWN Ip address :""")
コード例 #13
0
    def test_check_args_couple(self):
        """Test check_args_couple :
           -H 
        """
        sys.argv = [sys.argv[0]]
        sys.argv.append('-H')
        sys.argv.append('192.168.50.23')
        sys.argv.append('-s')
        sys.argv.append('test_shinken')
        sys.argv.append('-w')
        sys.argv.append('10')

        try:
            out = StringIO()
            sys.stdout = out
            check_samba.main()
        except SystemExit, e:
            self.assertEquals(type(e), type(SystemExit()))
            self.assertEquals(e.code, 3)
            output = out.getvalue().strip()
            assert output.startswith("""UNKNOWN - You can't specify only warning or critical.""")
コード例 #14
0
    def test_check_args_couple(self):
        """Test check_args_couple :
           -H 
        """
        sys.argv = [sys.argv[0]]
        sys.argv.append('-H')
        sys.argv.append('192.168.50.23')
        sys.argv.append('-s')
        sys.argv.append('test_shinken')
        sys.argv.append('-w')
        sys.argv.append('10')

        try:
            out = StringIO()
            sys.stdout = out
            check_samba.main()
        except SystemExit, e:
            self.assertEquals(type(e), type(SystemExit()))
            self.assertEquals(e.code, 3)
            output = out.getvalue().strip()
            assert output.startswith(
                """UNKNOWN - You can't specify only warning or critical.""")
コード例 #15
0
    def test_bad_values(self):
        """Test bad_values :
           -H 192.168.50.23 -s test_shinken
        """
        sys.argv = [sys.argv[0]]
        sys.argv.append('-H')
        sys.argv.append('192.168.50.23')
        sys.argv.append('-s')
        sys.argv.append('test_shinken')
        sys.argv.append('-w')
        sys.argv.append('10')
        sys.argv.append('-c')
        sys.argv.append('9')

        try:
            out = StringIO()
            sys.stdout = out
            check_samba.main()
        except SystemExit, e:
            self.assertEquals(type(e), type(SystemExit()))
            self.assertEquals(e.code, 3)
            output = out.getvalue().strip()
            assert output.startswith("""UNKNOWN - Wrong warning, critical or timeout values""")
コード例 #16
0
    def test_bad_values(self):
        """Test bad_values :
           -H 192.168.50.23 -s test_shinken
        """
        sys.argv = [sys.argv[0]]
        sys.argv.append('-H')
        sys.argv.append('192.168.50.23')
        sys.argv.append('-s')
        sys.argv.append('test_shinken')
        sys.argv.append('-w')
        sys.argv.append('10')
        sys.argv.append('-c')
        sys.argv.append('9')

        try:
            out = StringIO()
            sys.stdout = out
            check_samba.main()
        except SystemExit, e:
            self.assertEquals(type(e), type(SystemExit()))
            self.assertEquals(e.code, 3)
            output = out.getvalue().strip()
            assert output.startswith(
                """UNKNOWN - Wrong warning, critical or timeout values""")