summary refs log tree commit diff stats
path: root/testing/test_data.py
blob: 47f4e66cef640d56a467498da891aab1640f7de7 (plain) (blame)
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
from ganarchy.data import DataProperty, ObjectDataSource, PCTP

def test_basic_project():
    ods = ObjectDataSource({
        'projects': {
            '0123456789012345678901234567890123456789': {
                'https://example/': {
                    None: {'active': True}
                }
            }
         }
    })
    values = list(ods.get_property_values(DataProperty.VCS_REPOS))
    assert len(values) == 1
    assert isinstance(values[0], PCTP)
    assert values[0].project_commit == '0123456789'*4
    assert values[0].uri == 'https://example/'
    assert values[0].branch == None
    assert values[0].active
    assert values[0].federate # defaults to True
    assert not values[0].pinned # defaults to False

def test_nul_in_project_uri():
    # tests what happens if repo uri is malicious/bogus
    # should just ignore bad uri
    ods = ObjectDataSource({
        'projects': {
            '0123456789012345678901234567890123456789': {
                'https://example/\0': {
                    None: {'active': True}
                }
            }
         }
    })
    values = list(ods.get_property_values(DataProperty.VCS_REPOS))
    assert not len(values)

def test_bad_branch():
    # tests what happens if repo branch is malicious/bogus
    # should just ignore bad branch
    ods = ObjectDataSource({
        'projects': {
            '0123456789012345678901234567890123456789': {
                'https://example/': {
                    '\0': {'active': True}
                }
            }
         }
    })
    values = list(ods.get_property_values(DataProperty.VCS_REPOS))
    assert not len(values)