示例#1
0
 def setUp(self):
     self.app = create_app()
     # self.app.app_context().push()
     self.client = self.app.test_client()
     with self.app.app_context():
         db.drop_all()
         db.create_all()
         self.user = User()
         self.user.id = self.user_id
         self.user.email, self.user.name, self.user.secret = \
             '*****@*****.**', self.publisher, 'super_secret'
         publisher = Publisher(name=self.publisher)
         association = PublisherUser(role="OWNER")
         association.publisher = publisher
         self.user.publishers.append(association)
         db.session.add(self.user)
         db.session.commit()
     response = self.client.post(self.jwt_url,
                                 data=json.dumps({
                                     'username': self.publisher,
                                     'secret': 'super_secret'
                                 }),
                                 content_type='application/json')
     data = json.loads(response.data)
     self.jwt = data['token']
示例#2
0
    def setUp(self):
        self.app = create_app()
        self.client = self.app.test_client()
        with self.app.app_context():
            db.drop_all()
            db.create_all()
            self.user = User()
            self.user.id = self.user_id
            self.user.email, self.user.name, self.user.secret = \
                '*****@*****.**', self.publisher_name, 'super_secret'

            self.publisher = Publisher(name=self.publisher_name)

            association = PublisherUser(role=UserRoleEnum.owner)
            association.publisher = self.publisher

            metadata = MetaDataDB(name=self.package)
            self.publisher.packages.append(metadata)
            self.user.publishers.append(association)

            db.session.add(self.user)
            db.session.commit()
        response = self.client.post(self.jwt_url,
                                    data=json.dumps({
                                        'username': self.publisher_name,
                                        'secret': 'super_secret'
                                    }),
                                    content_type='application/json')
        data = json.loads(response.data)
        self.jwt = data['token']
        self.auth = "bearer %s" % self.jwt
示例#3
0
 def test_throw_error_if_role_is_invalid(self):
     with self.app.test_request_context():
         db.drop_all()
         db.create_all()
         publisher = Publisher(name='test_pub_id')
         association = PublisherUser()
         association.publisher = publisher
         self.assertRaises(ValueError, association.role, "NOT_MEMBER")
示例#4
0
    def setUp(self):
        self.app = create_app()
        self.app.app_context().push()
        with self.app.test_request_context():
            db.drop_all()
            db.create_all()

            user = User(id=11,
                        name='test_user_id',
                        secret='supersecret',
                        auth0_id="123|auth0")
            publisher = Publisher(name='test_pub_id')
            association = PublisherUser(role="OWNER")
            association.publisher = publisher
            user.publishers.append(association)

            db.session.add(user)
            db.session.commit()
示例#5
0
    def setUp(self):
        self.app = create_app()
        self.client = self.app.test_client()
        with self.app.app_context():
            db.drop_all()
            db.create_all()
            self.user = User()
            self.user.id = 1
            self.user.email, self.user.name, self.user.secret = \
                '*****@*****.**', self.publisher, 'super_secret'

            self.publisherObj = Publisher(name=self.publisher)

            association = PublisherUser(role=UserRoleEnum.owner)
            association.publisher = self.publisherObj
            self.user.publishers.append(association)

            db.session.add(self.user)
            db.session.commit()
示例#6
0
def populate_db(auth0_id, email, user_name, full_name):
    user = User.query.filter_by(name=user_name).first()

    publisher = Publisher.query.filter_by(name=user_name).first()
    if publisher:
        db.session.delete(publisher)
        db.session.commit()
    if user:
        db.session.delete(user)
        db.session.commit()

    user = User()
    user.auth0_id, user.email, user.name, user.full_name, user.secret \
        = auth0_id, email, user_name, full_name, \
          "c053521f4f3331908d89df39bba922190a69f0ea99f7ca00"

    publisher = Publisher(name=user_name)
    association = PublisherUser(role="OWNER")
    association.publisher = publisher
    user.publishers.append(association)

    db.session.add(user)
    db.session.commit()
示例#7
0
    def setUp(self):
        self.app = create_app()
        self.app.app_context().push()
        with self.app.test_request_context():
            db.drop_all()
            db.create_all()

            self.user = User(id=11,
                             name=self.user_name,
                             secret='supersecret',
                             auth0_id="123|auth0")

            self.publisher = Publisher(name=self.user_name)
            self.publisher.packages.append(MetaDataDB(name='test_package'))

            association = PublisherUser(role=UserRoleEnum.owner)
            association.publisher = self.publisher

            self.user.publishers.append(association)

            self.publisher1 = Publisher(name="test_publisher")
            self.publisher1.packages.append(MetaDataDB(name='test_package'))

            association1 = PublisherUser(role=UserRoleEnum.member)
            association1.publisher = self.publisher1

            self.user.publishers.append(association1)

            db.session.add(self.user)

            self.sysadmin = User(id=12, name='admin', sysadmin=True)
            db.session.add(self.sysadmin)

            self.random_user = User(id=13, name='random')
            db.session.add(self.random_user)

            self.publisher2 = Publisher(name="test_publisher1", private=True)
            self.publisher2.packages.append(
                MetaDataDB(name='test_package', private=True))
            db.session.add(self.publisher2)

            self.publisher3 = Publisher(name="test_publisher2", private=False)
            self.publisher3.packages.append(MetaDataDB(name='test_package'))
            db.session.add(self.publisher3)

            db.session.commit()
示例#8
0
    def setUp(self):
        self.publisher_one = 'test_publisher1'
        self.publisher_two = 'test_publisher2'
        self.package_one = 'test_package1'
        self.package_two = 'test_package2'
        self.app = create_app()
        self.app.app_context().push()

        with self.app.test_request_context():
            db.drop_all()
            db.create_all()

            user1 = User(name=self.publisher_one)
            publisher1 = Publisher(name=self.publisher_one)
            association1 = PublisherUser(role="OWNER")
            association1.publisher = publisher1
            user1.publishers.append(association1)

            user2 = User(name=self.publisher_two)
            publisher2 = Publisher(name=self.publisher_two)
            association2 = PublisherUser(role="OWNER")
            association2.publisher = publisher2
            user2.publishers.append(association2)

            metadata1 = MetaDataDB(name=self.package_one)
            metadata1.descriptor = json.dumps(dict(name='test_one'))
            publisher1.packages.append(metadata1)

            metadata2 = MetaDataDB(name=self.package_two)
            metadata2.descriptor = json.dumps(dict(name='test_two'))
            publisher1.packages.append(metadata2)

            metadata3 = MetaDataDB(name=self.package_one)
            metadata3.descriptor = json.dumps(dict(name='test_three'))
            publisher2.packages.append(metadata3)

            metadata4 = MetaDataDB(name=self.package_two)
            metadata4.descriptor = json.dumps(dict(name='test_four'))
            publisher2.packages.append(metadata4)

            db.session.add(user1)
            db.session.add(user2)

            db.session.commit()