Example #1
0
def test_get_str():
    """
    Test for Returns a random string of the specified length.
    """
    assert mod_random.get_str(length=1, chars="A") == "A"
    assert len(mod_random.get_str(length=64)) == 64
    ret = mod_random.get_str(
        length=1,
        lowercase=False,
        uppercase=False,
        printable=False,
        whitespace=False,
        punctuation=False,
    )
    assert not re.search(r"^[a-zA-Z]+$", ret), "Found invalid characters"
    assert re.search(r"^[0-9]+$", ret), "Not found required characters"
 def test_get_str(self):
     """
     Test for Returns a random string of the specified length.
     """
     self.assertEqual(mod_random.get_str(length=1, chars="A"), "A")
     self.assertEqual(len(mod_random.get_str(length=64)), 64)
     ret = mod_random.get_str(
         length=1,
         lowercase=False,
         uppercase=False,
         printable=False,
         whitespace=False,
         punctuation=False,
     )
     self.assertNotRegex(ret, r"^[a-zA-Z]+$", "Found invalid characters")
     self.assertRegex(ret, r"^[0-9]+$", "Not found required characters")
Example #3
0
 def test_get_str(self):
     '''
     Test for Returns a random string of the specified length.
     '''
     with patch.object(salt.utils.pycrypto,
                       'secure_password', return_value='A'):
         self.assertEqual(mod_random.get_str(), 'A')
Example #4
0
 def test_get_str(self):
     '''
     Test for Returns a random string of the specified length.
     '''
     with patch.object(salt.utils.pycrypto,
                       'secure_password', return_value='A'):
         self.assertEqual(mod_random.get_str(), 'A')
Example #5
0
 def test_get_str(self):
     """
     Test for Returns a random string of the specified length.
     """
     with patch.object(salt.utils.pycrypto,
                       "secure_password",
                       return_value="A"):
         self.assertEqual(mod_random.get_str(), "A")