Esempio n. 1
0
def main():
    args = parser.parse_args()
    app = create_app()
    with app.app_context():
        # Organization and user
        try:
            organization = Organization(
                id=organization_id,
                name=args.organization,
                namespace=args.namespace,
                created_at=datetime.utcnow()
            )
            organization.save()
            print('Organization {} successfully created!'.format(organization.name))
        except Exception:
            raise Exception('Adding {} organization failed'.format(args.organization))
        try:
            user = User.create(
                None,
                id=user_id,
                username=args.username,
                password=args.password,
                email='*****@*****.**',
                organization=organization,
                created_at=datetime.utcnow(),
                role='superadmin',
                active=True
            )
            user.save()
            print('User {} successfully created!'.format(user.username))
        except Exception:
            raise Exception('Adding {} user failed'.format(args.username))
Esempio n. 2
0
 def __init__(self, namespace=None):
     profile = fake.simple_profile()
     self.test_org = OrganizationFixture(namespace)
     user = User.create(None,
                        username=profile['username'],
                        password=profile['username'] + 'password',
                        organization=self.test_org.obj,
                        role='superadmin',
                        active=True)
     user.save(validate=False)
     self.obj = user
Esempio n. 3
0
def user():
    """Prepare user object."""
    profile = fake.simple_profile()
    user = User.create(None,
                       username=profile['username'],
                       password=profile['username'] + 'password',
                       organization=organization(),
                       role='superadmin',
                       active=True)
    user.save()

    return user
Esempio n. 4
0
def user():
    """Prepare user object."""
    with current_app.app_context():
        test_org = OrganizationFixture()
        profile = fake.simple_profile()
        user = User.create(None,
                           username=profile['username'],
                           password=profile['username'] + 'password',
                           organization=test_org.obj,
                           role='superadmin',
                           active=True)

        user.save()
        yield user
        try:
            user.delete()
            test_org.destroy()
        except Exception:
            # objects may be already deleted
            pass
Esempio n. 5
0
with app.app_context():
    # Organization and user
    try:
        organization = Organization(id=uuid_organization,
                                    name='DemoOrg',
                                    namespace='demoorg',
                                    created_at=datetime.utcnow())
        organization.save()
    except:
        raise Exception('Adding DemoOrg organization failed')

    try:
        user = User.create(None,
                           username='******',
                           password='******',
                           organization=organization,
                           created_at=datetime.utcnow(),
                           role='superadmin',
                           active=True)
        user.save()
    except:
        raise Exception('Adding admin user failed')

    # AWS + Jenkins
    try:
        provisioner = Provisioner(user.namespace,
                                  id=uuid_provisioner_jenkins,
                                  name='Jenkins provisioner to AWS',
                                  state='OK',
                                  engine='kqueen.engines.JenkinsEngine',
                                  parameters={