Exemplo n.º 1
0
    def test_is_current_user_admin_only_cookie_user(self):
        # Cookie only
        self.oauth_logout()

        dummy_mail = '*****@*****.**'

        # Not an admin
        self.cookie_login(dummy_mail, is_admin=False)
        self.assertFalse(auth_utils.is_current_user_admin())

        # Is an admin
        self.cookie_login(dummy_mail, is_admin=True)
        self.assertTrue(auth_utils.is_current_user_admin())

        self.cookie_logout()
Exemplo n.º 2
0
  def test_is_current_user_admin_only_cookie_user(self):
    # Cookie only
    self.oauth_logout()

    dummy_mail = '*****@*****.**'

    # Not an admin
    self.cookie_login(dummy_mail, is_admin=False)
    self.assertFalse(auth_utils.is_current_user_admin())

    # Is an admin
    self.cookie_login(dummy_mail, is_admin=True)
    self.assertTrue(auth_utils.is_current_user_admin())

    self.cookie_logout()
Exemplo n.º 3
0
    def test_is_current_user_admin_oauth_only_is_admin(self):
        # Can't call is_current_user_admin twice in the same test because the OAuth
        # user gets set once and cached.
        oauth_mail = '*****@*****.**'

        # Is an admin
        self.oauth_login(oauth_mail, is_admin=True)
        self.assertTrue(auth_utils.is_current_user_admin())
Exemplo n.º 4
0
  def test_is_current_user_admin_oauth_only_is_admin(self):
    # Can't call is_current_user_admin twice in the same test because the OAuth
    # user gets set once and cached.
    oauth_mail = '*****@*****.**'

    # Is an admin
    self.oauth_login(oauth_mail, is_admin=True)
    self.assertTrue(auth_utils.is_current_user_admin())
Exemplo n.º 5
0
    def process_request(self, request):
        request.user = auth_utils.get_current_user()
        request.user_is_admin = auth_utils.is_current_user_admin()

        # Update the cached value of the current user's Account
        account = None
        if request.user is not None:
            account = models.Account.get_account_for_user(request.user)
        models.Account.current_user_account = account
Exemplo n.º 6
0
  def process_request(self, request):
    request.user = auth_utils.get_current_user()
    request.user_is_admin = auth_utils.is_current_user_admin()

    # Update the cached value of the current user's Account
    account = None
    if request.user is not None:
      account = models.Account.get_account_for_user(request.user)
    models.Account.current_user_account = account
Exemplo n.º 7
0
    def test_is_current_user_admin_both_cookie_and_oauth_user(self):
        self.cookie_login('*****@*****.**', is_admin=True)
        self.oauth_login('*****@*****.**', is_admin=True)

        self.assertTrue(auth_utils.is_current_user_admin())
Exemplo n.º 8
0
 def test_is_current_user_admin_no_users(self):
     self.cookie_logout()
     self.oauth_logout()
     self.assertFalse(auth_utils.is_current_user_admin())
Exemplo n.º 9
0
  def test_is_current_user_admin_both_cookie_and_oauth_user(self):
    self.cookie_login('*****@*****.**', is_admin=True)
    self.oauth_login('*****@*****.**', is_admin=True)

    self.assertTrue(auth_utils.is_current_user_admin())
Exemplo n.º 10
0
 def test_is_current_user_admin_no_users(self):
   self.cookie_logout()
   self.oauth_logout()
   self.assertFalse(auth_utils.is_current_user_admin())