summaryrefslogtreecommitdiffstats
path: root/rp_meyzieu/mappers/linuxfr_example.py
blob: 2773707344b34c56a4f986468eb3bf946cceca9b (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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88

"""
You need to defined 3 variables :

* form_values (defined the login form values):
form_values = {
    'login_url': '/login',
    'post_url': '/login',
    'form_attrs': { 'name': 'form40', },
    'username_field': 'user',
    'password_field': 'pass',
    'post_fields': ['birthdate', 'card_number']
}
login_url, form_attrs, post_fields and username_field are obligatory
* urls (a dictionnary with urls) :
 urls = {
       'associate_url': '/mandaye/associate',
       'connection_url': '/mandaye/sso',
       'login_url': '/mandaye/login'
       }
* mapping
"""

from rp_meyzieu.filters.example import ReplayFilter

form_values = {
        'login_url': '/compte/connexion',
        'form_attrs': { 'id': 'new_account' },
        'post_fields': ['account[login]', 'account[password]'],
        'username_field': 'account[login]',
        'password_field': 'account[password]',
}

urls = {
    'associate_url': '/mandaye/associate',
    'connection_url': '/mandaye/sso',
    'login_url': '/mandaye/login'
}

mapping = [
        {
            'path': r'/mandaye/login$',
            'method': 'GET',
            'response': [{
                'auth': 'login',
                'condition': 'response.code==302',
                },]
            },  
        {   
            'path': r'/mandaye/sso$',
            'method': 'GET',
            'response': [{
                'auth': 'sso',
                }]
            },  
        {   
            'path': r'/mandaye/slo$',
            'method': 'GET',
            'response': [{
                'auth': 'slo',
                }]
            }, 
        {
            'path': r'/mandaye/associate$',
            'method': 'GET',
            'on_response': [{
                'filter': ReplayFilter.associate,
                'values': {
                    'action': urls['associate_url'],
                    'template': 'associate.html',
                    'sp_name': 'Linux FR',
                    'login_name': form_values['username_field'],
                    'password_name': form_values['password_field'],
                    },
                },]
            },
        {
            'path':  r'/mandaye/associate$',
            'method': 'POST',
            'response': [
                {
                    'auth': 'associate_submit',
                    'condition': "response.code==302"
                    },
                ]
            },
        ]