示例#1
0
    def test_manage_user(self):
        """Test GOOGLE manage_user works."""
        # First with a new user
        user_data = dict(id='1', name='google',
                         email='*****@*****.**')
        token = 't'
        user = manage_user(token, user_data, None)
        assert user.email_addr == user_data['email'], user
        assert user.name == user_data['name'], user
        assert user.fullname == user_data['name'], user
        assert user.google_user_id == user_data['id'], user

        # Second with the same user
        user = manage_user(token, user_data, None)
        assert user.email_addr == user_data['email'], user
        assert user.name == user_data['name'], user
        assert user.fullname == user_data['name'], user
        assert user.google_user_id == user_data['id'], user

        # Finally with a user that already is in the system
        user_data = dict(id='10', name=self.name,
                         email=self.email_addr)
        token = 'tA'
        user = manage_user(token, user_data, None)
        err_msg = "User should be the same"
        print user.google_user_id
        assert user.google_user_id == '10', err_msg
示例#2
0
    def test_manage_user(self):
        """Test GOOGLE manage_user works."""
        with self.app.test_request_context('/'):
            # First with a new user
            user_data = dict(id='1', name='google', email='*****@*****.**')
            token = 't'
            user = google.manage_user(token, user_data, None)
            assert user.email_addr == user_data['email'], user
            assert user.name == user_data['name'], user
            assert user.fullname == user_data['name'], user
            assert user.google_user_id == user_data['id'], user

            # Second with the same user
            user = google.manage_user(token, user_data, None)
            assert user.email_addr == user_data['email'], user
            assert user.name == user_data['name'], user
            assert user.fullname == user_data['name'], user
            assert user.google_user_id == user_data['id'], user

            # Finally with a user that already is in the system
            user_data = dict(id='10',
                             name=Fixtures.name,
                             email=Fixtures.email_addr)
            token = 'tA'
            user = google.manage_user(token, user_data, None)
            assert user is None
示例#3
0
    def test_manage_user(self):
        """Test GOOGLE manage_user works."""
        with self.app.test_request_context('/'):
            # First with a new user
            user_data = dict(id='1', name='google',
                             email='*****@*****.**')
            token = 't'
            user = google.manage_user(token, user_data, None)
            assert user.email_addr == user_data['email'], user
            assert user.name == user_data['name'], user
            assert user.fullname == user_data['name'], user
            assert user.google_user_id == user_data['id'], user

            # Second with the same user
            user = google.manage_user(token, user_data, None)
            assert user.email_addr == user_data['email'], user
            assert user.name == user_data['name'], user
            assert user.fullname == user_data['name'], user
            assert user.google_user_id == user_data['id'], user

            # Finally with a user that already is in the system
            user_data = dict(id='10', name=Fixtures.name,
                             email=Fixtures.email_addr)
            token = 'tA'
            user = google.manage_user(token, user_data, None)
            assert user is None
示例#4
0
    def test_manage_user(self):
        """Test GOOGLE manage_user works."""
        # First with a new user
        user_data = dict(id='1', name='google', email='*****@*****.**')
        token = 't'
        user = manage_user(token, user_data, None)
        assert user.email_addr == user_data['email'], user
        assert user.name == user_data['name'], user
        assert user.fullname == user_data['name'], user
        assert user.google_user_id == user_data['id'], user

        # Second with the same user
        user = manage_user(token, user_data, None)
        assert user.email_addr == user_data['email'], user
        assert user.name == user_data['name'], user
        assert user.fullname == user_data['name'], user
        assert user.google_user_id == user_data['id'], user

        # Finally with a user that already is in the system
        user_data = dict(id='10', name=self.name, email=self.email_addr)
        token = 'tA'
        user = manage_user(token, user_data, None)
        err_msg = "User should be the same"
        print user.google_user_id
        assert user.google_user_id == '10', err_msg
示例#5
0
 def test_manage_user_twitter_registered_user(self):
     """Test GOOGLE manage_user with an existing user registered with Google"""
     user_data = dict(id="1", name="google", email="*****@*****.**")
     token = "t"
     manage_user(token, user_data)
     new_token = "new_t"
     user = manage_user(new_token, user_data)
     assert user.email_addr == user_data["email"], user
     assert user.name == user_data["name"], user
     assert user.fullname == user_data["name"], user
     assert user.google_user_id == user_data["id"], user
     assert user.info["google_token"] == dict(oauth_token=new_token), user
示例#6
0
 def test_manage_user_twitter_registered_user(self):
     """Test GOOGLE manage_user with an existing user registered with Google"""
     user_data = dict(id='1', name='google', email='*****@*****.**')
     token = 't'
     manage_user(token, user_data)
     new_token = "new_t"
     user = manage_user(new_token, user_data)
     assert user.email_addr == user_data['email'], user
     assert user.name == user_data['name'], user
     assert user.fullname == user_data['name'], user
     assert user.google_user_id == user_data['id'], user
     assert user.info['google_token'] == dict(oauth_token=new_token), user
示例#7
0
 def test_manage_user_twitter_registered_user(self):
     """Test GOOGLE manage_user with an existing user registered with Google"""
     user_data = dict(id='1', name='google', email='*****@*****.**')
     token = 't'
     manage_user(token, user_data)
     new_token = "new_t"
     user = manage_user(new_token, user_data)
     assert user.email_addr == user_data['email'], user
     assert user.name == user_data['name'], user
     assert user.fullname == user_data['name'], user
     assert user.google_user_id == user_data['id'], user
     assert user.info['google_token'] == dict(oauth_token=new_token), user
示例#8
0
    def test_40_google_oauth_creation(self):
        """Test WEB Google OAuth detects same user name/email works"""
        fake_response = {
            u'access_token': u'access_token',
            u'token_type': u'Bearer',
            u'expires_in': 3600,
            u'id_token': u'token'
        }

        fake_user = {
            u'family_name': u'Doe',
            u'name': u'John Doe',
            u'picture': u'https://goo.gl/img.jpg',
            u'locale': u'en',
            u'gender': u'male',
            u'email': u'*****@*****.**',
            u'birthday': u'0000-01-15',
            u'link': u'https://plus.google.com/id',
            u'given_name': u'John',
            u'id': u'111111111111111111111',
            u'verified_email': True
        }

        self.register()
        self.signout()

        from pybossa.view import google
        response_user = google.manage_user(fake_response['access_token'],
                                           fake_user, None)

        assert response_user is None, response_user
示例#9
0
    def test_40_google_oauth_creation(self):
        """Test WEB Google OAuth detects same user name/email works"""
        fake_response = {
                u'access_token': u'access_token',
                u'token_type': u'Bearer',
                u'expires_in': 3600,
                u'id_token': u'token'}

        fake_user = {
        u'family_name': u'Doe', u'name': u'John Doe',
        u'picture': u'https://goo.gl/img.jpg',
        u'locale': u'en',
        u'gender': u'male',
        u'email': u'*****@*****.**',
        u'birthday': u'0000-01-15',
        u'link': u'https://plus.google.com/id',
        u'given_name': u'John',
        u'id': u'111111111111111111111',
        u'verified_email': True}

        self.register()
        self.signout()

        from pybossa.view import google
        response_user = google.manage_user(fake_response['access_token'],
                fake_user, None)

        assert response_user is None, response_user
示例#10
0
    def test_39_google_oauth_creation(self):
        """Test WEB Google OAuth creation of user works"""
        fake_response = {
                u'access_token': u'access_token',
                u'token_type': u'Bearer',
                u'expires_in': 3600,
                u'id_token': u'token'}

        fake_user = {
        u'family_name': u'Doe', u'name': u'John Doe',
        u'picture': u'https://goo.gl/img.jpg',
        u'locale': u'en',
        u'gender': u'male',
        u'email': u'*****@*****.**',
        u'birthday': u'0000-01-15',
        u'link': u'https://plus.google.com/id',
        u'given_name': u'John',
        u'id': u'111111111111111111111',
        u'verified_email': True}

        from pybossa.view import google
        response_user = google.manage_user(fake_response['access_token'],
                fake_user, None)

        user = db.session.query(model.User)\
                .get(1)

        assert user.email_addr == response_user.email_addr, response_user
示例#11
0
    def test_39_google_oauth_creation(self):
        """Test WEB Google OAuth creation of user works"""
        fake_response = {
            u"access_token": u"access_token",
            u"token_type": u"Bearer",
            u"expires_in": 3600,
            u"id_token": u"token",
        }

        fake_user = {
            u"family_name": u"Doe",
            u"name": u"John Doe",
            u"picture": u"https://goo.gl/img.jpg",
            u"locale": u"en",
            u"gender": u"male",
            u"email": u"*****@*****.**",
            u"birthday": u"0000-01-15",
            u"link": u"https://plus.google.com/id",
            u"given_name": u"John",
            u"id": u"111111111111111111111",
            u"verified_email": True,
        }

        from pybossa.view import google

        response_user = google.manage_user(fake_response["access_token"], fake_user, None)

        user = db.session.query(model.User).get(1)

        assert user.email_addr == response_user.email_addr, response_user
示例#12
0
    def test_39_google_oauth_creation(self):
        """Test WEB Google OAuth creation of user works"""
        fake_response = {
            u'access_token': u'access_token',
            u'token_type': u'Bearer',
            u'expires_in': 3600,
            u'id_token': u'token'
        }

        fake_user = {
            u'family_name': u'Doe',
            u'name': u'John Doe',
            u'picture': u'https://goo.gl/img.jpg',
            u'locale': u'en',
            u'gender': u'male',
            u'email': u'*****@*****.**',
            u'birthday': u'0000-01-15',
            u'link': u'https://plus.google.com/id',
            u'given_name': u'John',
            u'id': u'111111111111111111111',
            u'verified_email': True
        }

        from pybossa.view import google
        response_user = google.manage_user(fake_response['access_token'],
                                           fake_user, None)

        user = db.session.query(model.User)\
                .get(1)

        assert user.email_addr == response_user.email_addr, response_user
示例#13
0
    def test_40_google_oauth_creation(self):
        """Test WEB Google OAuth detects same user name/email works"""
        fake_response = {
            u"access_token": u"access_token",
            u"token_type": u"Bearer",
            u"expires_in": 3600,
            u"id_token": u"token",
        }

        fake_user = {
            u"family_name": u"Doe",
            u"name": u"John Doe",
            u"picture": u"https://goo.gl/img.jpg",
            u"locale": u"en",
            u"gender": u"male",
            u"email": u"*****@*****.**",
            u"birthday": u"0000-01-15",
            u"link": u"https://plus.google.com/id",
            u"given_name": u"John",
            u"id": u"111111111111111111111",
            u"verified_email": True,
        }

        self.register()
        self.signout()

        from pybossa.view import google

        response_user = google.manage_user(fake_response["access_token"], fake_user, None)

        assert response_user is None, response_user
示例#14
0
 def test_manage_user_with_existing_non_twitter_account_user(self):
     """Test GOOGLE manage_user user with a username that already exists
     and registered without Google"""
     user_data = dict(id='10', name=self.name, email=self.email_addr)
     token = 'tA'
     user = manage_user(token, user_data)
     err_msg = "User should be the same"
     assert user.google_user_id == '10', err_msg
     assert user.info['google_token'] == dict(oauth_token=token), user
示例#15
0
 def test_manage_user_with_existing_non_twitter_account_user(self):
     """Test GOOGLE manage_user user with a username that already exists
     and registered without Google"""
     user_data = dict(id="10", name=self.name, email=self.email_addr)
     token = "tA"
     user = manage_user(token, user_data)
     err_msg = "User should be the same"
     assert user.google_user_id == "10", err_msg
     assert user.info["google_token"] == dict(oauth_token=token), user
示例#16
0
 def test_manage_user_new_user(self):
     """Test GOOGLE manage_user with a new user"""
     user_data = dict(id="1", name="google", email="*****@*****.**")
     token = "t"
     user = manage_user(token, user_data)
     assert user.email_addr == user_data["email"], user
     assert user.name == user_data["name"], user
     assert user.fullname == user_data["name"], user
     assert user.google_user_id == user_data["id"], user
     assert user.info["google_token"] == dict(oauth_token=token), user
示例#17
0
 def test_manage_user_new_user(self):
     """Test GOOGLE manage_user with a new user"""
     user_data = dict(id='1', name='google', email='*****@*****.**')
     token = 't'
     user = manage_user(token, user_data)
     assert user.email_addr == user_data['email'], user
     assert user.name == user_data['name'], user
     assert user.fullname == user_data['name'], user
     assert user.google_user_id == user_data['id'], user
     assert user.info['google_token'] == dict(oauth_token=token), user
示例#18
0
 def test_manage_user_new_user(self):
     """Test GOOGLE manage_user with a new user"""
     user_data = dict(id='1', name='google', email='*****@*****.**')
     token = 't'
     user = manage_user(token, user_data)
     assert user.email_addr == user_data['email'], user
     assert user.name == user_data['name'], user
     assert user.fullname == user_data['name'], user
     assert user.google_user_id == user_data['id'], user
     assert user.info['google_token'] == dict(oauth_token=token), user
示例#19
0
 def test_manage_user_with_newsletter(self, newsletter):
     """Test GOOGLE manage_user with newsletter works."""
     # First with a new user
     newsletter.app = True
     user_data = dict(id="1", name="google", email="*****@*****.**")
     token = "t"
     user = manage_user(token, user_data)
     assert user.email_addr == user_data["email"], user
     assert user.name == user_data["name"], user
     assert user.fullname == user_data["name"], user
     assert user.google_user_id == user_data["id"], user
     newsletter.subscribe_user.assert_called_once_with(user)
示例#20
0
 def test_manage_user_with_newsletter_only_once(self, newsletter):
     """Test GOOGLE manage_user with newsletter only once works."""
     # Second with the same user
     token = "t"
     user = UserFactory.create(fullname="john", name="john", google_user_id="1")
     user_data = dict(id=str(user.id), name=user.name, email=user.email_addr)
     r_user = manage_user(token, user_data)
     assert r_user.email_addr == user_data["email"], user
     assert r_user.name == user_data["name"], user
     assert r_user.fullname == user_data["name"], user
     assert r_user.google_user_id == user_data["id"], user
     assert newsletter.subscribe_user.called is False, newsletter.subscribe_user.called
示例#21
0
 def test_manage_user_with_newsletter(self, newsletter):
     """Test GOOGLE manage_user with newsletter works."""
     # First with a new user
     newsletter.app = True
     user_data = dict(id='1', name='google', email='*****@*****.**')
     token = 't'
     user = manage_user(token, user_data, None)
     assert user.email_addr == user_data['email'], user
     assert user.name == user_data['name'], user
     assert user.fullname == user_data['name'], user
     assert user.google_user_id == user_data['id'], user
     newsletter.subscribe_user.assert_called_once_with(user)
示例#22
0
 def test_manage_user_with_newsletter(self, newsletter):
     """Test GOOGLE manage_user with newsletter works."""
     # First with a new user
     newsletter.app = True
     user_data = dict(id='1', name='google',
                      email='*****@*****.**')
     token = 't'
     user = manage_user(token, user_data)
     assert user.email_addr == user_data['email'], user
     assert user.name == user_data['name'], user
     assert user.fullname == user_data['name'], user
     assert user.google_user_id == user_data['id'], user
     newsletter.subscribe_user.assert_called_once_with(user)
示例#23
0
 def test_manage_user_with_newsletter_only_once(self, newsletter):
     """Test GOOGLE manage_user with newsletter only once works."""
     # Second with the same user
     token = 't'
     user = UserFactory.create(fullname='john', name='john',
                               google_user_id='1')
     user_data = dict(id=str(user.id), name=user.name, email=user.email_addr)
     r_user = manage_user(token, user_data)
     assert r_user.email_addr == user_data['email'], user
     assert r_user.name == user_data['name'], user
     assert r_user.fullname == user_data['name'], user
     assert r_user.google_user_id == user_data['id'], user
     assert newsletter.subscribe_user.called is False, newsletter.subscribe_user.called
示例#24
0
 def test_manage_user_with_newsletter_only_once(self, newsletter):
     """Test GOOGLE manage_user with newsletter only once works."""
     # Second with the same user
     token = 't'
     user = UserFactory.create(fullname='john', name='john',
                               google_user_id='1')
     user_data = dict(id=str(user.id), name=user.name, email=user.email_addr)
     r_user = manage_user(token, user_data)
     assert r_user.email_addr == user_data['email'], user
     assert r_user.name == user_data['name'], user
     assert r_user.fullname == user_data['name'], user
     assert r_user.google_user_id == user_data['id'], user
     assert newsletter.subscribe_user.called is False, newsletter.subscribe_user.called