Пример #1
0
 def test_container_request_auth(self):
     users.create('*****@*****.**', {'openid': 'oid', 'approved': True,
                              'nickname': 'nn', 'api_key': 'blahBlah'})
     u = users.get('*****@*****.**')
     auth_headers = [('Authorization', 'Token %s:%s' % (u.name, 'bl'))]
     self.post_json('/api/v1/container_request/', {}, 401)
     self.post_json('/api/v1/container_request/', {}, 401, auth_headers)
Пример #2
0
    def test_container_request(self):
        data = {
            'name': 'container_foo',
            'template': 'ubuntu',
            'release': 'xenial',
        }
        users.create('*****@*****.**', {'openid': 'oid', 'approved': True,
                                 'nickname': 'nn', 'api_key': 'blahBlah'})
        u = users.get('*****@*****.**')
        auth_headers = [('Authorization', 'Token %s:%s' % (u.name, u.api_key))]
        self.post_json('/api/v1/container_request/', data, 202, auth_headers)

        queue = list(container_requests.list())
        self.assertEqual(['container_foo'], queue)
        c = container_requests.get('container_foo')
        self.assertEqual('nn', c.requested_by)
Пример #3
0
Файл: ui.py Проект: doanac/cya
def create_user():
    if g.user is not None or 'openid' not in session:
        return redirect(url_for('index'))
    approved = settings.AUTO_APPROVE_USER
    admin = False
    if users.count() == 0:
        approved = True
        admin = True
    users.create(request.values['email'], {
        'nickname': request.values['name'],
        'openid': session['openid'],
        'approved': approved,
        'admin': admin,
        'api_key': users.generate_api_key(),
    })
    flash('Profile successfully created')
    return redirect(oid.get_next_url())
Пример #4
0
def create_user():
    if g.user is not None or 'openid' not in session:
        return redirect(url_for('index'))
    approved = settings.AUTO_APPROVE_USER
    admin = False
    if users.count() == 0:
        approved = True
        admin = True
    users.create(
        request.values['email'], {
            'nickname': request.values['name'],
            'openid': session['openid'],
            'approved': approved,
            'admin': admin,
            'api_key': users.generate_api_key(),
        })
    flash('Profile successfully created')
    return redirect(oid.get_next_url())