예제 #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()
예제 #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()
예제 #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())
예제 #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())
예제 #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
예제 #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
예제 #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())
예제 #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())
예제 #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())
예제 #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())