blob: 28cbe19ff056061b723361575c073ab5202e8392 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
|
"""Integration test for the apt module's ``sources_list`` functionality.
This test specifies a ``sources_list`` and then checks that (a) the expected
number of sources.list entries is present, and (b) that each expected line
appears in the file.
(This is ported from
``tests/cloud_tests/testcases/modules/apt_configure_sources_list.yaml``.)"""
import re
import pytest
USER_DATA = """\
#cloud-config
apt:
primary:
- arches: [default]
uri: http://archive.ubuntu.com/ubuntu
security:
- arches: [default]
uri: http://security.ubuntu.com/ubuntu
sources_list: |
deb $MIRROR $RELEASE main restricted
deb-src $MIRROR $RELEASE main restricted
deb $PRIMARY $RELEASE universe restricted
deb-src $PRIMARY $RELEASE universe restricted
deb $SECURITY $RELEASE-security multiverse
deb-src $SECURITY $RELEASE-security multiverse
"""
EXPECTED_REGEXES = [
r"deb http://archive.ubuntu.com/ubuntu [a-z].* main restricted",
r"deb-src http://archive.ubuntu.com/ubuntu [a-z].* main restricted",
r"deb http://archive.ubuntu.com/ubuntu [a-z].* universe restricted",
r"deb-src http://archive.ubuntu.com/ubuntu [a-z].* universe restricted",
r"deb http://security.ubuntu.com/ubuntu [a-z].*security multiverse",
r"deb-src http://security.ubuntu.com/ubuntu [a-z].*security multiverse",
]
@pytest.mark.ci
@pytest.mark.ubuntu
class TestAptConfigureSourcesList:
@pytest.mark.user_data(USER_DATA)
def test_sources_list(self, client):
sources_list = client.read_from_file("/etc/apt/sources.list")
assert 6 == len(sources_list.rstrip().split('\n'))
for expected_re in EXPECTED_REGEXES:
assert re.search(expected_re, sources_list) is not None
|