Esempio n. 1
0
    def test_root_is_not_enabled(self):
        mock_conn = mock_admin_sql_connection()

        mock_rs = mock()
        mock_rs.rowcount = 0
        when(mock_conn).execute(TextClauseMatcher("User = '******' AND Host != 'localhost'")).thenReturn(mock_rs)

        self.assertThat(MySqlRootAccess.is_root_enabled(), Equals(False))
Esempio n. 2
0
 def test_enable_root(self):
     mock_conn = mock_admin_sql_connection()
     when(mock_conn).execute(any()).thenReturn(None)
     # invocation
     user_ser = MySqlRootAccess.enable_root()
     # verification
     self.assertThat(user_ser, Not(Is(None)))
     verify(mock_conn).execute(TextClauseMatcher("CREATE USER"), user="******", host="%")
     verify(mock_conn).execute(TextClauseMatcher("GRANT ALL PRIVILEGES ON *.*"))
     verify(mock_conn).execute(TextClauseMatcher("UPDATE mysql.user"))
Esempio n. 3
0
    def test_root_is_not_enabled(self):
        mock_conn = mock_admin_sql_connection()

        mock_rs = mock()
        mock_rs.rowcount = 0
        when(mock_conn).execute(
            TextClauseMatcher(
                "User = '******' AND Host != 'localhost'")).thenReturn(mock_rs)

        self.assertThat(MySqlRootAccess.is_root_enabled(), Equals(False))
Esempio n. 4
0
 def test_report_root_enabled(self):
     mock_db_api = mock()
     when(trove.extensions.mysql.models).get_db_api().thenReturn(mock_db_api)
     when(mock_db_api).find_by(any(), id=None).thenReturn(None)
     root_history = RootHistory("x", "root")
     when(mock_db_api).save(any(RootHistory)).thenReturn(root_history)
     # invocation
     history = MySqlRootAccess.report_root_enabled(TroveContext())
     # verification
     self.assertThat(history, Is(root_history))
     verify(mock_db_api).save(any(RootHistory))
Esempio n. 5
0
 def test_report_root_enabled(self):
     mock_db_api = mock()
     when(
         trove.extensions.mysql.models).get_db_api().thenReturn(mock_db_api)
     when(mock_db_api).find_by(any(), id=None).thenReturn(None)
     root_history = RootHistory('x', 'root')
     when(mock_db_api).save(any(RootHistory)).thenReturn(root_history)
     # invocation
     history = MySqlRootAccess.report_root_enabled(TroveContext())
     # verification
     self.assertThat(history, Is(root_history))
     verify(mock_db_api).save(any(RootHistory))
Esempio n. 6
0
 def test_enable_root(self):
     mock_conn = mock_admin_sql_connection()
     when(mock_conn).execute(any()).thenReturn(None)
     # invocation
     user_ser = MySqlRootAccess.enable_root()
     # verification
     self.assertThat(user_ser, Not(Is(None)))
     verify(mock_conn).execute(TextClauseMatcher('CREATE USER'),
                               user='******',
                               host='%')
     verify(mock_conn).execute(
         TextClauseMatcher('GRANT ALL PRIVILEGES ON *.*'))
     verify(mock_conn).execute(TextClauseMatcher('UPDATE mysql.user'))