Ejemplo n.º 1
0
def test_preseed_simple():
    app = web.app_factory(global_config={})
    app = webtest.TestApp(app)
    res = app.get(
        '/preseed/ubuntu-10.10',
        )
    eq(res.headers['Content-Type'], 'text/plain')
    eq(res.body[:4], 'd-i ')
Ejemplo n.º 2
0
def test_preseed_notfound():
    app = web.app_factory(global_config={})
    app = webtest.TestApp(app)
    res = app.get(
        '/preseed/does-not-exist',
        status=404,
        )
    eq(res.headers['Content-Type'], 'text/plain')
    eq(res.body, '404 Not Found')
Ejemplo n.º 3
0
def test_preseed_notfound():
    app = web.app_factory(global_config={})
    app = webtest.TestApp(app)
    res = app.get(
        '/preseed/does-not-exist',
        status=404,
    )
    eq(res.headers['Content-Type'], 'text/plain')
    eq(res.body, '404 Not Found')
Ejemplo n.º 4
0
def test_userdata_simple():
    app = web.app_factory(global_config={})
    app = webtest.TestApp(app)
    res = app.get(
        '/latest/user-data',
        extra_environ={
            'cheesy2.userdata': lambda request: 'xyzzy',
            },
        )
    eq(res.headers['Content-Type'], 'text/plain')
    eq(res.body, 'xyzzy')
Ejemplo n.º 5
0
def test_userdata_simple():
    app = web.app_factory(global_config={})
    app = webtest.TestApp(app)
    res = app.get(
        '/latest/user-data',
        extra_environ={
            'cheesy2.userdata': lambda request: 'xyzzy',
        },
    )
    eq(res.headers['Content-Type'], 'text/plain')
    eq(res.body, 'xyzzy')
Ejemplo n.º 6
0
def test_userdata_notfound():
    app = web.app_factory(global_config={})
    app = webtest.TestApp(app)
    res = app.get(
        '/latest/user-data',
        extra_environ={
            'cheesy2.userdata': lambda request: None,
            },
        status=404,
        )
    eq(res.headers['Content-Type'], 'text/plain')
    eq(res.body, '404 Not Found')
Ejemplo n.º 7
0
def test_userdata_notfound():
    app = web.app_factory(global_config={})
    app = webtest.TestApp(app)
    res = app.get(
        '/latest/user-data',
        extra_environ={
            'cheesy2.userdata': lambda request: None,
        },
        status=404,
    )
    eq(res.headers['Content-Type'], 'text/plain')
    eq(res.body, '404 Not Found')
Ejemplo n.º 8
0
def test_metadata_specific():
    app = web.app_factory(global_config={})
    app = webtest.TestApp(app)
    res = app.get(
        '/latest/meta-data/hostname',
        extra_environ={
            'cheesy2.metadata': lambda request: {
                'hostname': 'slartibartfast.example.com',
                },
            },
        )
    eq(res.headers['Content-Type'], 'text/plain')
    eq(res.body, 'slartibartfast.example.com')
Ejemplo n.º 9
0
def test_metadata_specific():
    app = web.app_factory(global_config={})
    app = webtest.TestApp(app)
    res = app.get(
        '/latest/meta-data/hostname',
        extra_environ={
            'cheesy2.metadata': lambda request: {
                'hostname': 'slartibartfast.example.com',
            },
        },
    )
    eq(res.headers['Content-Type'], 'text/plain')
    eq(res.body, 'slartibartfast.example.com')
Ejemplo n.º 10
0
def test_metadata_index():
    app = web.app_factory(global_config={})
    app = webtest.TestApp(app)
    res = app.get(
        '/latest/meta-data/',
        extra_environ={
            'cheesy2.metadata': lambda request: {
                'foo': 'bar',
                'baz': 'quux',
                },
            },
        )
    eq(res.headers['Content-Type'], 'text/plain')
    eq(res.body, 'baz\nfoo\n')
Ejemplo n.º 11
0
def test_metadata_index():
    app = web.app_factory(global_config={})
    app = webtest.TestApp(app)
    res = app.get(
        '/latest/meta-data/',
        extra_environ={
            'cheesy2.metadata': lambda request: {
                'foo': 'bar',
                'baz': 'quux',
            },
        },
    )
    eq(res.headers['Content-Type'], 'text/plain')
    eq(res.body, 'baz\nfoo\n')
Ejemplo n.º 12
0
def test_metadata_list():
    app = web.app_factory(global_config={})
    app = webtest.TestApp(app)
    meta = {
        'cheesy2.metadata': lambda request: {
            'foo':
            'bar',
            'public-keys': [
                web.Named(name='my-public-key',
                          value=
                          {'openssh-key': 'ssh-rsa AAAAfoo my-public-key'}),
            ],
        },
    }

    res = app.get(
        '/latest/meta-data/',
        extra_environ=meta,
    )
    eq(res.headers['Content-Type'], 'text/plain')
    eq(res.body, 'foo\npublic-keys/\n')

    res = app.get(
        '/latest/meta-data/public-keys/',
        extra_environ=meta,
    )
    eq(res.headers['Content-Type'], 'text/plain')
    eq(res.body, '0=my-public-key\n')

    res = app.get(
        '/latest/meta-data/public-keys/0/',
        extra_environ=meta,
    )
    eq(res.headers['Content-Type'], 'text/plain')
    eq(res.body, 'openssh-key\n')

    res = app.get(
        '/latest/meta-data/public-keys/0/openssh-key',
        extra_environ=meta,
    )
    eq(res.headers['Content-Type'], 'text/plain')
    eq(res.body, 'ssh-rsa AAAAfoo my-public-key')
Ejemplo n.º 13
0
def test_metadata_list():
    app = web.app_factory(global_config={})
    app = webtest.TestApp(app)
    meta = {
        'cheesy2.metadata': lambda request: {
            'foo': 'bar',
            'public-keys': [
                web.Named(name='my-public-key', value={'openssh-key': 'ssh-rsa AAAAfoo my-public-key'}),
                ],
            },
        }

    res = app.get(
        '/latest/meta-data/',
        extra_environ=meta,
        )
    eq(res.headers['Content-Type'], 'text/plain')
    eq(res.body, 'foo\npublic-keys/\n')

    res = app.get(
        '/latest/meta-data/public-keys/',
        extra_environ=meta,
        )
    eq(res.headers['Content-Type'], 'text/plain')
    eq(res.body, '0=my-public-key\n')

    res = app.get(
        '/latest/meta-data/public-keys/0/',
        extra_environ=meta,
        )
    eq(res.headers['Content-Type'], 'text/plain')
    eq(res.body, 'openssh-key\n')

    res = app.get(
        '/latest/meta-data/public-keys/0/openssh-key',
        extra_environ=meta,
        )
    eq(res.headers['Content-Type'], 'text/plain')
    eq(res.body, 'ssh-rsa AAAAfoo my-public-key')
Ejemplo n.º 14
0
def test_preseed_simple():
    app = web.app_factory(global_config={})
    app = webtest.TestApp(app)
    res = app.get('/preseed/ubuntu-10.10', )
    eq(res.headers['Content-Type'], 'text/plain')
    eq(res.body[:4], 'd-i ')