Esempio n. 1
0
  def testIsAdminUserFalse(self):
    """Test IsAdminUser() with a passed email address that is not an admin."""
    self.mox.StubOutWithMock(auth, '_GetGroupMembers')

    admin_email = '*****@*****.**'
    auth._GetGroupMembers('admins').AndReturn(['*****@*****.**'])

    self.mox.ReplayAll()
    self.assertFalse(auth.IsAdminUser(admin_email))
    self.mox.VerifyAll()
Esempio n. 2
0
  def testIsAdminUserFalse(self):
    """Test IsAdminUser() with a passed email address that is not an admin."""
    self.mox.StubOutWithMock(auth, '_GetGroupMembers')

    admin_email = '*****@*****.**'
    auth._GetGroupMembers('admins').AndReturn(['*****@*****.**'])

    self.mox.ReplayAll()
    self.assertFalse(auth.IsAdminUser(admin_email))
    self.mox.VerifyAll()
Esempio n. 3
0
  def testIsAdminUserBootstrapFalse(self):
    """Test IsAdminUser() where no admins are defined, but user not admin."""
    self.mox.StubOutWithMock(auth.users, 'is_current_user_admin')
    self.mox.StubOutWithMock(auth, '_GetGroupMembers')

    admin_email = '*****@*****.**'
    auth._GetGroupMembers('admins').AndReturn([])

    self.mox.StubOutWithMock(auth, 'users')
    auth.users.is_current_user_admin().AndReturn(False)

    self.mox.ReplayAll()
    self.assertFalse(auth.IsAdminUser(admin_email))
    self.mox.VerifyAll()
Esempio n. 4
0
  def testIsAdminUserBootstrapFalse(self):
    """Test IsAdminUser() where no admins are defined, but user not admin."""
    self.mox.StubOutWithMock(auth.users, 'is_current_user_admin')
    self.mox.StubOutWithMock(auth, '_GetGroupMembers')

    admin_email = '*****@*****.**'
    auth._GetGroupMembers('admins').AndReturn([])

    self.mox.StubOutWithMock(auth, 'users')
    auth.users.is_current_user_admin().AndReturn(False)

    self.mox.ReplayAll()
    self.assertFalse(auth.IsAdminUser(admin_email))
    self.mox.VerifyAll()
Esempio n. 5
0
  def testIsAdminUserWithNoPassedEmail(self):
    """Test IsAdminUser() with no passed email address."""
    self.mox.StubOutWithMock(auth.users, 'get_current_user')
    self.mox.StubOutWithMock(auth, '_GetGroupMembers')

    admin_email = '*****@*****.**'

    mock_user = self.mox.CreateMockAnything()
    auth.users.get_current_user().AndReturn(mock_user)
    mock_user.email().AndReturn(admin_email)
    auth._GetGroupMembers('admins').AndReturn(['*****@*****.**'])

    self.mox.ReplayAll()
    self.assertFalse(auth.IsAdminUser())
    self.mox.VerifyAll()
Esempio n. 6
0
  def testIsAdminUserWithNoPassedEmail(self):
    """Test IsAdminUser() with no passed email address."""
    self.mox.StubOutWithMock(auth.users, 'get_current_user')
    self.mox.StubOutWithMock(auth, '_GetGroupMembers')

    admin_email = '*****@*****.**'

    mock_user = self.mox.CreateMockAnything()
    auth.users.get_current_user().AndReturn(mock_user)
    mock_user.email().AndReturn(admin_email)
    auth._GetGroupMembers('admins').AndReturn(['*****@*****.**'])

    self.mox.ReplayAll()
    self.assertFalse(auth.IsAdminUser())
    self.mox.VerifyAll()