Projet

Général

Profil

0001-astregs-add-initial-connector-33424.patch

Serghei Mihai, 26 juin 2019 11:45

Télécharger (70,6 ko)

Voir les différences:

Subject: [PATCH] astregs: add initial connector (#33424)

 passerelle/apps/astregs/__init__.py           |   0
 .../apps/astregs/migrations/0001_initial.py   |  51 +++
 .../apps/astregs/migrations/__init__.py       |   0
 passerelle/apps/astregs/models.py             | 216 +++++++++++++
 passerelle/settings.py                        |   1 +
 tests/data/astregs/Contact.wsdl               | 267 ++++++++++++++++
 tests/data/astregs/Contact.xml                |   1 +
 tests/data/astregs/RechercheTiers.wsdl        | 135 ++++++++
 tests/data/astregs/RechercheTiers.xml         |   1 +
 tests/data/astregs/RechercheTiersDetails.wsdl | 156 +++++++++
 tests/data/astregs/RechercheTiersDetails.xml  |   1 +
 tests/data/astregs/RechercheTiersNoResult.xml |   1 +
 tests/data/astregs/Tiers.wsdl                 | 300 ++++++++++++++++++
 tests/data/astregs/Tiers.xml                  |   1 +
 tests/test_astregs.py                         | 120 +++++++
 15 files changed, 1251 insertions(+)
 create mode 100644 passerelle/apps/astregs/__init__.py
 create mode 100644 passerelle/apps/astregs/migrations/0001_initial.py
 create mode 100644 passerelle/apps/astregs/migrations/__init__.py
 create mode 100644 passerelle/apps/astregs/models.py
 create mode 100644 tests/data/astregs/Contact.wsdl
 create mode 100644 tests/data/astregs/Contact.xml
 create mode 100644 tests/data/astregs/RechercheTiers.wsdl
 create mode 100644 tests/data/astregs/RechercheTiers.xml
 create mode 100644 tests/data/astregs/RechercheTiersDetails.wsdl
 create mode 100644 tests/data/astregs/RechercheTiersDetails.xml
 create mode 100644 tests/data/astregs/RechercheTiersNoResult.xml
 create mode 100644 tests/data/astregs/Tiers.wsdl
 create mode 100644 tests/data/astregs/Tiers.xml
 create mode 100644 tests/test_astregs.py
passerelle/apps/astregs/migrations/0001_initial.py
1
# -*- coding: utf-8 -*-
2
# Generated by Django 1.11.20 on 2019-06-19 10:24
3
from __future__ import unicode_literals
4

  
5
from django.db import migrations, models
6
import django.db.models.deletion
7

  
8

  
9
class Migration(migrations.Migration):
10

  
11
    initial = True
12

  
13
    dependencies = [
14
        ('base', '0012_job'),
15
    ]
16

  
17
    operations = [
18
        migrations.CreateModel(
19
            name='AstreGS',
20
            fields=[
21
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
22
                ('title', models.CharField(max_length=50, verbose_name='Title')),
23
                ('description', models.TextField(verbose_name='Description')),
24
                ('slug', models.SlugField(unique=True, verbose_name='Identifier')),
25
                ('wsdl_base_url', models.URLField(verbose_name='Webservices base URL')),
26
                ('username', models.CharField(max_length=32, verbose_name='Username')),
27
                ('password', models.CharField(max_length=32, verbose_name='Password')),
28
                ('organism', models.CharField(max_length=32, verbose_name='Organism')),
29
                ('budget', models.CharField(max_length=32, verbose_name='Budget')),
30
                ('exercice', models.CharField(max_length=32, verbose_name='Exercice')),
31
                ('users', models.ManyToManyField(blank=True, related_name='_astregs_users_+', related_query_name='+', to='base.ApiUser')),
32
            ],
33
            options={
34
                'verbose_name': 'AstresGS',
35
            },
36
        ),
37
        migrations.CreateModel(
38
            name='Link',
39
            fields=[
40
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
41
                ('name_id', models.CharField(max_length=32)),
42
                ('association_id', models.CharField(max_length=32)),
43
                ('created', models.DateTimeField(auto_now_add=True)),
44
                ('resource', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='astregs.AstreGS')),
45
            ],
46
        ),
47
        migrations.AlterUniqueTogether(
48
            name='link',
49
            unique_together=set([('resource', 'name_id', 'association_id')]),
50
        ),
51
    ]
passerelle/apps/astregs/models.py
1
# -*- coding: utf-8 -*-
2
# Copyright (C) 2019  Entr'ouvert
3
#
4
# This program is free software: you can redistribute it and/or modify it
5
# under the terms of the GNU Affero General Public License as published
6
# by the Free Software Foundation, either version 3 of the License, or
7
# (at your option) any later version.
8
#
9
# This program is distributed in the hope that it will be useful,
10
# but WITHOUT ANY WARRANTY; without even the implied warranty of
11
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12
# GNU Affero General Public License for more details.
13
#
14
# You should have received a copy of the GNU Affero General Public License
15
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
16

  
17
from zeep.helpers import serialize_object
18

  
19
from django.db import models
20
from django.utils.translation import ugettext_lazy as _
21
from django.utils.six.moves.urllib import parse as urlparse
22
from django.http import Http404
23

  
24
from passerelle.base.models import BaseResource
25
from passerelle.utils.api import endpoint
26

  
27
LINK_CREATION_SCHEMA = {
28
    '$schema': 'http://json-schema.org/draft-03/schema#',
29
    'title': 'AstreGS Link',
30
    'description': '',
31
    'type': 'object',
32
    'properties': {
33
        'NameID': {
34
            'description': 'user name_id',
35
            'type': 'string',
36
            'required': True
37
        },
38
        'association_id': {
39
            'description': 'association id',
40
            'type': 'string',
41
            'required': True
42
        }
43
    }
44
}
45

  
46

  
47
class AstreGS(BaseResource):
48
    wsdl_base_url = models.URLField(_('Webservices base URL'))
49
    username = models.CharField(_('Username'), max_length=32)
50
    password = models.CharField(_('Password'), max_length=32)
51
    organism = models.CharField('Organisme', max_length=32)
52
    budget = models.CharField('Budget', max_length=32)
53
    exercice = models.CharField('Exercice', max_length=32)
54

  
55
    category = _('Business Process Connectors')
56

  
57
    class Meta:
58
        verbose_name = u'AstresGS'
59

  
60
    def check_status(self):
61
        response = self.requests.get(self.wsdl_base_url)
62
        response.raise_for_status()
63

  
64
    @property
65
    def authentication(self):
66
        return {'USERNOM': self.username, 'USERPWD': self.password}
67

  
68
    @property
69
    def context(self):
70
        return {'Organisme': self.organism,
71
                'Budget': self.budget,
72
                'Exercice': self.exercice}
73

  
74
    def get_client(self, wsdl_name):
75
        url = urlparse.urljoin(self.wsdl_base_url, '%s?wsdl' % wsdl_name)
76
        client = self.soap_client(wsdl_url=url)
77
        parsed_wsdl_address = urlparse.urlparse(client.service._binding_options['address'])
78
        parsed_real_address = urlparse.urlparse(self.wsdl_base_url)
79
        client.service._binding_options['address'] = urlparse.urlunparse(
80
            parsed_real_address[:2] + parsed_wsdl_address[2:])
81
        return client
82

  
83

  
84
    @endpoint(description=_('Find associations by SIREN number'),
85
              perm='can_access',
86
              parameters={
87
                  'siren': {'description': _('SIREN Number'),
88
                            'example_value': '77567227216096'}
89
                  }
90
              )
91
    def associations(self, request, siren):
92
        client = self.get_client('RechercheTiersDetails')
93
        r = client.service.liste(Authentification=self.authentication,
94
                                 Contexte=self.context,
95
                                 Criteres={'siren': '%s*' % siren})
96
        data = []
97
        if r.liste:
98
            for item in r.liste.EnregRechercheTiersDetailsReturn:
99
                association_data = serialize_object(item)
100
                association_data['id'] = association_data['Numero_SIRET']
101
                association_data['text'] = '%(Numero_SIRET)s - %(Nom_enregistrement)s' % association_data
102
                association_data['code'] = association_data['Code_tiers']
103
                association_data['name'] = association_data['Nom_enregistrement']
104
                data.append(association_data)
105
        return {'data': data}
106

  
107
    @endpoint(description=_('Check if association exists by its SIRET number'),
108
              name='check-association-by-siret',
109
              perm='can_access',
110
              parameters={
111
                  'siret': {'description': _('SIRET Number'),
112
                            'example_value': '7756722721609600014'}
113
                  }
114
              )
115
    def check_association_by_siret(self, request, siret):
116
        client = self.get_client('RechercheTiers')
117
        r = client.service.liste(Authentification=self.authentication,
118
                                 Contexte=self.context,
119
                                 Criteres={'siren': siret})
120
        if r.liste:
121
            return {'exists': True}
122
        return {'exists': False}
123

  
124
    @endpoint(name='get-association-link-means',
125
              description=_('Get association linking means'),
126
              perm='can_access',
127
              parameters={
128
                  'association_id': {'description': _('Association ID'),
129
                                     'example_value': '42435'}
130
                  }
131
    )
132
    def get_association_link_means(self, request, association_id):
133
        client = self.get_client('Tiers')
134
        r = client.service.Chargement({'Authentification': self.authentication,
135
                                       'Contexte': self.context,
136
                                       'TiersCle': {'CodeTiers': association_id}})
137
        data = []
138
        # assocation contact is defined in EncodeKeyContact attribute
139
        if not r.EncodeKeyContact:
140
            return {'data': data}
141

  
142
        client = self.get_client('Contact')
143
        r = client.service.Chargement({'Authentification': self.authentication,
144
                                       'Contexte': self.context,
145
                                       'ContactCle': {'idContact': r.EncodeKeyContact}})
146
        if r.AdresseMail:
147
            data.append({'id': 'email',
148
                         'text': 'par courriel vers %s***@***%s' % (r.AdresseMail[:2], r.AdresseMail[-3:]),
149
                         'value': r.AdresseMail,
150
                         'type': 'email'})
151
        if r.TelephoneMobile:
152
            data.append({'id': 'mobile',
153
                         'text': 'par SMS vers %s****%s' % (r.TelephoneMobile[:2], r.TelephoneMobile[-3:]),
154
                         'value': r.TelephoneMobile,
155
                         'type': 'mobile'})
156
        if r.RueVoie:
157
            full_address = r.RueVoie
158
            full_address += ', '
159
            if r.CodePostal:
160
                full_address += '%s ' % r.CodePostal
161
            if r.Ville:
162
                full_address += r.Ville
163
            data.append({'id': 'address',
164
                         'text': 'par courrier vers %s ***** %s' % (full_address[:10], full_address[-10:]),
165
                         'address': r.RueVoie,
166
                         'zicode': r.CodePostal,
167
                         'city': r.Ville,
168
                         'value': full_address,
169
                         'type': 'mail'})
170
        return {'data': data}
171

  
172
    @endpoint(name='link', perm='can_access',
173
              post={
174
                  'description': _('Create link with an association'),
175
                  'request_body': {
176
                      'schema': {
177
                          'application/json': LINK_CREATION_SCHEMA
178
                      }
179
                  }
180
              }
181
    )
182
    def link(self, request, post_data):
183
        link, created = Link.objects.get_or_create(resource=self, name_id=post_data['NameID'],
184
                                                   association_id=post_data['association_id'])
185
        return {'link': link.id, 'created': created, 'association_id': link.association_id}
186

  
187

  
188
    @endpoint(description=_('Remove link to an association'),
189
              perm='can_access',
190
              parameters={
191
                  'NameID':{
192
                      'description': _('Publik NameID'),
193
                      'example_value': 'xyz24d934',
194
                  },
195
                  'association_id':{
196
                      'description': _('Association ID'),
197
                      'example_value': '12345',
198
                  }
199
              })
200
    def unlink(self, request, NameID, association_id):
201
        try:
202
            link = Link.objects.get(resource=self, name_id=NameID, association_id=association_id)
203
            link.delete()
204
            return {'deleted': True}
205
        except Link.DoesNotExist:
206
            raise Http404('link not found')
207

  
208

  
209
class Link(models.Model):
210
    resource = models.ForeignKey(AstreGS)
211
    name_id = models.CharField(max_length=32)
212
    association_id = models.CharField(max_length=32)
213
    created = models.DateTimeField(auto_now_add=True)
214

  
215
    class Meta:
216
        unique_together = ('resource', 'name_id', 'association_id')
passerelle/settings.py
122 122
    'passerelle.apps.api_particulier',
123 123
    'passerelle.apps.arcgis',
124 124
    'passerelle.apps.arpege_ecp',
125
    'passerelle.apps.astregs',
125 126
    'passerelle.apps.atal',
126 127
    'passerelle.apps.atos_genesys',
127 128
    'passerelle.apps.base_adresse',
tests/data/astregs/Contact.wsdl
1
<?xml version="1.0" encoding="UTF-8"?>
2
<wsdl:definitions name="Contact" targetNamespace="http://gfi.astre.webservices/rf/gf/contact" xmlns:impl="http://gfi.astre.webservices/rf/gf/contact" xmlns:apachesoap="http://xml.apache.org/xml-soap" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:wsdlsoap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:intf="http://gfi.astre.webservices/rf/gf/contact">
3
  <wsdl:types>
4
    <schema elementFormDefault="qualified" targetNamespace="http://gfi.astre.webservices/rf/gf/contact" xmlns="http://www.w3.org/2001/XMLSchema">
5
				<!--  request et response -->	
6
			
7
	<complexType name="Authentification">
8
		<sequence>
9
			<element name="USERNOM" type="string"/>
10
			<element name="USERPWD" type="string"/>
11
		</sequence>
12
	</complexType>
13
	
14
	<complexType name="Contexte">
15
		<sequence>
16
			<element name="Organisme" type="string"/>
17
			<element name="Budget" type="string"/>
18
			<element name="Exercice" type="string"/>
19
		</sequence>
20
	</complexType>
21
	
22
	<complexType name="ContactRequest">
23
				<sequence>
24
			<element name="Authentification" type="impl:Authentification"/>
25
			<element name="Contexte" type="impl:Contexte"/>
26
		<element name="Contact" type="impl:Contact"/>
27
				</sequence>
28
			</complexType>
29
		<complexType name="ContactResponse">
30
			<sequence>		
31
				<element name="ContactReturn" type="impl:Contact"/>
32
			</sequence>
33
		</complexType>
34
		
35
		<complexType name="Contact">
36
		    <sequence>
37
         <element name="idContact" nillable="true" type="xsd:string"/>
38
         <element name="CodeContact" nillable="true" type="xsd:string"/>
39
         <element name="CodeTitreCivilite" nillable="true" type="xsd:string"/>
40
         <element name="Nom" nillable="true" type="xsd:string"/>
41
         <element name="Prenom" nillable="true" type="xsd:string"/>
42
         <element name="NomDeJeuneFille" nillable="true" type="xsd:string"/>
43
         <element name="DateDeNaissance" nillable="true" type="xsd:string"/>
44
         <element name="FormuleCivilite" nillable="true" type="xsd:string"/>
45
         <element name="IntituleTitre2" nillable="true" type="xsd:string"/>
46
         <element name="IntituleTitre3" nillable="true" type="xsd:string"/>
47
         <element name="IntituleTitre4" nillable="true" type="xsd:string"/>
48
         <element name="SituationDeFamille" nillable="true" type="xsd:string"/>
49
         <element name="CodeFonction" nillable="true" type="xsd:string"/>
50
         <element name="LibelleFonction" nillable="true" type="xsd:string"/>
51
         <element name="TelephoneBureau" nillable="true" type="xsd:string"/>
52
         <element name="TelephoneMobile" nillable="true" type="xsd:string"/>
53
         <element name="NumeroDeFax" nillable="true" type="xsd:string"/>
54
         <element name="AdresseMail" nillable="true" type="xsd:string"/>
55
         <element name="PageWeb" nillable="true" type="xsd:string"/>
56
         <element name="AdresseDestinataire" nillable="true" type="xsd:string"/>
57
         <element name="AdresseComplementaire" nillable="true" type="xsd:string"/>
58
         <element name="ComplementGeographique" nillable="true" type="xsd:string"/>
59
         <element name="RueVoie" nillable="true" type="xsd:string"/>
60
         <element name="ComplementVoie" nillable="true" type="xsd:string"/>
61
         <element name="CodePostal" nillable="true" type="xsd:string"/>
62
         <element name="Ville" nillable="true" type="xsd:string"/>
63
         <element name="CodePays" nillable="true" type="xsd:string"/>
64
         <element name="LibellePays" nillable="true" type="xsd:string"/>
65
         <element name="LibelleAdresse" nillable="true" type="xsd:string"/>
66
         <element name="Commentaire" nillable="true" type="xsd:string"/>
67
</sequence>
68
	</complexType>
69
	
70
	<complexType name="Contact_Cle">
71
		<sequence>
72
			<element name="idContact" nillable="true" type="xsd:string"/>
73
		</sequence>
74
	</complexType>
75
	
76
	<complexType name="ContactRequest_Cles">
77
	   	<sequence>
78
			<element name="Authentification" type="impl:Authentification"/>
79
			<element name="Contexte" type="impl:Contexte"/>
80
		<element name="ContactCle" type="impl:Contact_Cle"/>
81
		
82
				</sequence>
83
			</complexType>
84
			
85
		<element name="creation">
86
			<complexType>
87
				<sequence>
88
					<element name="request" type="impl:ContactRequest"/>
89
				</sequence>
90
			</complexType>
91
		</element>
92
		
93
		<element name="creationResponse">
94
			<complexType>
95
				<sequence>
96
					<element name="response" type="impl:ContactResponse"/>
97
				</sequence>
98
			</complexType>
99
		</element>
100
		
101
		<element name="modification">
102
			<complexType>
103
				<sequence>
104
					<element name="request" type="impl:ContactRequest"/>
105
				</sequence>
106
			</complexType>
107
		</element>
108
		
109
		<element name="modificationResponse">
110
			<complexType>
111
				<sequence>
112
					<element name="response" type="impl:ContactResponse"/>
113
				</sequence>
114
			</complexType>
115
		</element>
116
		
117
		<element name="suppression">
118
			<complexType>
119
				<sequence>
120
					<element name="request" type="impl:ContactRequest_Cles"/>
121
				</sequence>
122
			</complexType>
123
		</element>
124
		
125
		<element name="suppressionResponse">
126
			<complexType>
127
				<sequence>
128
					<element name="response" type="impl:ContactResponse"/>
129
				</sequence>
130
			</complexType>
131
		</element>
132
		
133
		<element name="chargement">
134
			<complexType>
135
				<sequence>
136
					<element name="request" type="impl:ContactRequest_Cles"/>
137
				</sequence>
138
			</complexType>
139
		</element>
140
		
141
		<element name="chargementResponse">
142
			<complexType>
143
				<sequence>
144
					<element name="response" type="impl:ContactResponse"/>
145
				</sequence>
146
			</complexType>
147
		</element>
148
		
149
		
150
		</schema>
151
  </wsdl:types>
152
  <wsdl:message name="chargementRequest">
153
    <wsdl:part name="request" element="impl:chargement">
154
    </wsdl:part>
155
  </wsdl:message>
156
  <wsdl:message name="suppressionRequest">
157
    <wsdl:part name="request" element="impl:suppression">
158
    </wsdl:part>
159
  </wsdl:message>
160
  <wsdl:message name="modificationResponse">
161
    <wsdl:part name="response" element="impl:modificationResponse">
162
    </wsdl:part>
163
  </wsdl:message>
164
  <wsdl:message name="creationResponse">
165
    <wsdl:part name="response" element="impl:creationResponse">
166
    </wsdl:part>
167
  </wsdl:message>
168
  <wsdl:message name="chargementResponse">
169
    <wsdl:part name="response" element="impl:chargementResponse">
170
    </wsdl:part>
171
  </wsdl:message>
172
  <wsdl:message name="modificationRequest">
173
    <wsdl:part name="request" element="impl:modification">
174
    </wsdl:part>
175
  </wsdl:message>
176
  <wsdl:message name="suppressionResponse">
177
    <wsdl:part name="response" element="impl:suppressionResponse">
178
    </wsdl:part>
179
  </wsdl:message>
180
  <wsdl:message name="creationRequest">
181
    <wsdl:part name="request" element="impl:creation">
182
    </wsdl:part>
183
  </wsdl:message>
184
  <wsdl:portType name="Contact">
185
<wsdl:documentation>Web service des Contact Astre </wsdl:documentation>
186
    <wsdl:operation name="Modification">
187
<wsdl:documentation>
188
				le champ encodeKey est obligatoire ainsi que le champ à modifier
189
			</wsdl:documentation>
190
      <wsdl:input name="modificationRequest" message="impl:modificationRequest">
191
    </wsdl:input>
192
      <wsdl:output name="modificationResponse" message="impl:modificationResponse">
193
    </wsdl:output>
194
    </wsdl:operation>
195
    <wsdl:operation name="Chargement">
196
<wsdl:documentation>
197
				le champ encodeKey est obligatoire
198
			</wsdl:documentation>
199
      <wsdl:input name="chargementRequest" message="impl:chargementRequest">
200
    </wsdl:input>
201
      <wsdl:output name="chargementResponse" message="impl:chargementResponse">
202
    </wsdl:output>
203
    </wsdl:operation>
204
    <wsdl:operation name="Creation">
205
<wsdl:documentation>
206
				tous les champs sont obligatoires
207
			</wsdl:documentation>
208
      <wsdl:input name="creationRequest" message="impl:creationRequest">
209
    </wsdl:input>
210
      <wsdl:output name="creationResponse" message="impl:creationResponse">
211
    </wsdl:output>
212
    </wsdl:operation>
213
    <wsdl:operation name="Suppression">
214
<wsdl:documentation>
215
				tous les champs sont obligatoires
216
			</wsdl:documentation>
217
      <wsdl:input name="suppressionRequest" message="impl:suppressionRequest">
218
    </wsdl:input>
219
      <wsdl:output name="suppressionResponse" message="impl:suppressionResponse">
220
    </wsdl:output>
221
    </wsdl:operation>
222
  </wsdl:portType>
223
  <wsdl:binding name="ContactSoapBinding" type="impl:Contact">
224
    <wsdlsoap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
225
    <wsdl:operation name="Modification">
226
      <wsdlsoap:operation soapAction=""/>
227
      <wsdl:input name="modificationRequest">
228
        <wsdlsoap:body use="literal"/>
229
      </wsdl:input>
230
      <wsdl:output name="modificationResponse">
231
        <wsdlsoap:body use="literal"/>
232
      </wsdl:output>
233
    </wsdl:operation>
234
    <wsdl:operation name="Suppression">
235
      <wsdlsoap:operation soapAction=""/>
236
      <wsdl:input name="suppressionRequest">
237
        <wsdlsoap:body use="literal"/>
238
      </wsdl:input>
239
      <wsdl:output name="suppressionResponse">
240
        <wsdlsoap:body use="literal"/>
241
      </wsdl:output>
242
    </wsdl:operation>
243
    <wsdl:operation name="Creation">
244
      <wsdlsoap:operation soapAction=""/>
245
      <wsdl:input name="creationRequest">
246
        <wsdlsoap:body use="literal"/>
247
      </wsdl:input>
248
      <wsdl:output name="creationResponse">
249
        <wsdlsoap:body use="literal"/>
250
      </wsdl:output>
251
    </wsdl:operation>
252
    <wsdl:operation name="Chargement">
253
      <wsdlsoap:operation soapAction=""/>
254
      <wsdl:input name="chargementRequest">
255
        <wsdlsoap:body use="literal"/>
256
      </wsdl:input>
257
      <wsdl:output name="chargementResponse">
258
        <wsdlsoap:body use="literal"/>
259
      </wsdl:output>
260
    </wsdl:operation>
261
  </wsdl:binding>
262
  <wsdl:service name="Contact">
263
    <wsdl:port name="Contact" binding="impl:ContactSoapBinding">
264
      <wsdlsoap:address location="http://10.1.20.153:28001/axis2/services/Contact/"/>
265
    </wsdl:port>
266
  </wsdl:service>
267
</wsdl:definitions>
tests/data/astregs/Contact.xml
1
<?xml version='1.0' encoding='utf-8'?><soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"><soapenv:Body><ns1:chargementResponse xmlns:ns1="http://gfi.astre.webservices/rf/gf/contact"><ns1:response><ns1:ContactReturn><ns1:idContact>13012</ns1:idContact><ns1:CodeContact>AS173957</ns1:CodeContact><ns1:CodeTitreCivilite>035</ns1:CodeTitreCivilite><ns1:Nom>MARTIN</ns1:Nom><ns1:Prenom>Jean-Marc</ns1:Prenom><ns1:NomDeJeuneFille></ns1:NomDeJeuneFille><ns1:DateDeNaissance></ns1:DateDeNaissance><ns1:FormuleCivilite></ns1:FormuleCivilite><ns1:IntituleTitre2></ns1:IntituleTitre2><ns1:IntituleTitre3></ns1:IntituleTitre3><ns1:IntituleTitre4>Président de l&amp;#39;</ns1:IntituleTitre4><ns1:SituationDeFamille></ns1:SituationDeFamille><ns1:CodeFonction></ns1:CodeFonction><ns1:LibelleFonction></ns1:LibelleFonction><ns1:TelephoneBureau></ns1:TelephoneBureau><ns1:TelephoneMobile>0660909980</ns1:TelephoneMobile><ns1:NumeroDeFax></ns1:NumeroDeFax><ns1:AdresseMail>jeanmarcallan@neuf.fr</ns1:AdresseMail><ns1:PageWeb></ns1:PageWeb><ns1:AdresseDestinataire>Jean-Marc MARTIN</ns1:AdresseDestinataire><ns1:AdresseComplementaire></ns1:AdresseComplementaire><ns1:ComplementGeographique></ns1:ComplementGeographique><ns1:RueVoie>271 chemin de Curnier</ns1:RueVoie><ns1:ComplementVoie></ns1:ComplementVoie><ns1:CodePostal>06750</ns1:CodePostal><ns1:Ville>SERANON</ns1:Ville><ns1:CodePays>FR</ns1:CodePays><ns1:LibellePays>France</ns1:LibellePays><ns1:LibelleAdresse>SIEGE SOCIAL</ns1:LibelleAdresse><ns1:Commentaire></ns1:Commentaire></ns1:ContactReturn></ns1:response></ns1:chargementResponse></soapenv:Body></soapenv:Envelope>
tests/data/astregs/RechercheTiers.wsdl
1
<?xml version="1.0" encoding="UTF-8"?>
2
<wsdl:definitions name="RechercheTiers" targetNamespace="http://gfi.astre.webservices/gf/recherchetiers" xmlns:impl="http://gfi.astre.webservices/gf/recherchetiers" xmlns:apachesoap="http://xml.apache.org/xml-soap" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:wsdlsoap="http://schemas.xmlsoap.org/wsdl/soap/">
3
  <wsdl:types>
4
    <schema elementFormDefault="qualified" targetNamespace="http://gfi.astre.webservices/gf/recherchetiers" xmlns="http://www.w3.org/2001/XMLSchema">
5
	  
6
	
7
	<complexType name="Authentification">
8
		<sequence>
9
			<element name="USERNOM" type="string"/>
10
			<element name="USERPWD" type="string"/>
11
		</sequence>
12
	</complexType>
13
	
14
	<complexType name="Contexte">
15
		<sequence>
16
			<element name="Organisme" type="string"/>
17
			<element name="Budget" type="string"/>
18
			<element name="Exercice" type="string"/>
19
		</sequence>
20
	</complexType>
21
	
22
	<complexType name="CriteresRequest">
23
		<sequence>
24
			<element name="Authentification" type="impl:Authentification"/>
25
			<element name="Contexte" type="impl:Contexte"/>
26
			<element name="Criteres" type="impl:RechercheTiers"/>
27
		</sequence>
28
	</complexType>
29
	
30
	<complexType name="ListeRechercheTiers">
31
			<sequence>
32
				<element maxOccurs="unbounded" minOccurs="0" name="EnregRechercheTiersReturn" type="impl:EnregRechercheTiers"/>
33
		</sequence>
34
	</complexType>
35
	
36
	 
37
	<complexType name="RechercheResponse">
38
		<sequence>
39
			<element name="criteres" type="impl:RechercheTiers"/>
40
			<element name="liste" type="impl:ListeRechercheTiers"/>
41
		</sequence>
42
	</complexType>			
43

  
44
	<complexType name="RechercheTiers">
45
		<sequence>
46
	
47
			<element name="NbEnreg" nillable="true" type="xsd:string"/>
48
			<element name="ListeResultat" nillable="true" type="xsd:string"/>
49
			<element name="casseCodeTiers" nillable="true" type="xsd:string"/>
50
			<element name="NbEnregPage" nillable="true" type="xsd:string"/>
51
			<element name="isFinancier" nillable="true" type="xsd:string"/>
52
			<element name="numeroTiers" nillable="true" type="xsd:string"/>
53
			<element name="nom" nillable="true" type="xsd:string"/>
54
			<element name="nomSigleRaison" nillable="true" type="xsd:string"/>
55
			<element name="nomContact" nillable="true" type="xsd:string"/>
56
			<element name="indicateurAssociation" nillable="true" type="xsd:string"/>
57
			<element name="codeFamille" nillable="true" type="xsd:string"/>
58
			<element name="libelleFamille" nillable="true" type="xsd:string"/>
59
			<element name="siren" nillable="true" type="xsd:string"/>
60
			<element name="agence" nillable="true" type="xsd:string"/>
61
			<element name="codeApe" nillable="true" type="xsd:string"/>
62
			<element name="libelleCodeApe" nillable="true" type="xsd:string"/>
63
			<element name="banque" nillable="true" type="xsd:string"/>
64
			<element name="guichet" nillable="true" type="xsd:string"/>
65
			<element name="numeroCompte" nillable="true" type="xsd:string"/>
66
			<element name="cleRIB" nillable="true" type="xsd:string"/>
67
			<element name="AdrEmail" nillable="true" type="xsd:string"/>
68
			<element name="codePostal" nillable="true" type="xsd:string"/>
69
			<element name="ville" nillable="true" type="xsd:string"/>
70
			<element name="encodeKeyStatut" nillable="true" type="xsd:string"/>
71
			<element name="typeTiers" nillable="true" type="xsd:string"/>
72
			<element name="isPermanent" nillable="true" type="xsd:string"/>
73
			<element name="ancienNumero" nillable="true" type="xsd:string"/>
74
			<element name="encodeKeyNomana" nillable="true" type="xsd:string"/>
75
			<element name="codeElement" nillable="true" type="xsd:string"/>
76
			<element name="codeService" nillable="true" type="xsd:string"/>
77
			<element name="encodeKeyIdCompl" nillable="true" type="xsd:string"/>
78
			<element name="valeurIdCompl" nillable="true" type="xsd:string"/>
79

  
80
			</sequence>
81
		</complexType>
82

  
83
	 <element name="request" type="impl:CriteresRequest"/>
84
	 <element name="response" type="impl:RechercheResponse"/>	
85

  
86
	<complexType name="EnregRechercheTiers">
87
			<all>
88
		
89
			<element name="T_0TIERS_ID" nillable="true" type="xsd:string"/>	
90
			<element name="N" nillable="true" type="xsd:string"/>	
91
			<element name="Nom_Enregistrement" nillable="true" type="xsd:string"/>	
92
			<element name="Sigle" nillable="true" type="xsd:string"/>	
93
			<element name="Raison_Sociale" nillable="true" type="xsd:string"/>	
94
			<element name="Raison_Sociale_2" nillable="true" type="xsd:string"/>	
95
			<element name="Code_Postal" nillable="true" type="xsd:string"/>	
96
			<element name="Localite" nillable="true" type="xsd:string"/>
97
			</all>
98
		</complexType>
99
	</schema>
100
  </wsdl:types>
101
  <wsdl:message name="CriteresRequest">
102
    <wsdl:part name="request" element="impl:request">
103
    </wsdl:part>
104
  </wsdl:message>
105
  <wsdl:message name="ListeResponse">
106
    <wsdl:part name="response" element="impl:response">
107
    </wsdl:part>
108
  </wsdl:message>
109
  <wsdl:portType name="RechercheTiers">
110
<wsdl:documentation>Web Service RechercheTiers Astre</wsdl:documentation>
111
    <wsdl:operation name="liste">
112
      <wsdl:input name="CriteresRequest" message="impl:CriteresRequest">
113
    </wsdl:input>
114
      <wsdl:output name="ListeResponse" message="impl:ListeResponse">
115
    </wsdl:output>
116
    </wsdl:operation>
117
  </wsdl:portType>
118
  <wsdl:binding name="RechercheTiersSoapBinding" type="impl:RechercheTiers">
119
    <wsdlsoap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
120
    <wsdl:operation name="liste">
121
      <wsdlsoap:operation soapAction="http://gfi.astre.webservices/gf/RechercheTiers/Chargement"/>
122
      <wsdl:input name="CriteresRequest">
123
        <wsdlsoap:body use="literal"/>
124
      </wsdl:input>
125
      <wsdl:output name="ListeResponse">
126
        <wsdlsoap:body use="literal"/>
127
      </wsdl:output>
128
    </wsdl:operation>
129
  </wsdl:binding>
130
  <wsdl:service name="RechercheTiers">
131
    <wsdl:port name="RechercheTiers" binding="impl:RechercheTiersSoapBinding">
132
      <wsdlsoap:address location="http://10.1.20.153:28001/axis2/services/RechercheTiers/"/>
133
    </wsdl:port>
134
  </wsdl:service>
135
</wsdl:definitions>
tests/data/astregs/RechercheTiers.xml
1
<?xml version='1.0' encoding='utf-8'?><soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"><soapenv:Body><ns1:response xmlns:ns1="http://gfi.astre.webservices/gf/recherchetiers"><ns1:criteres><ns1:NbEnreg>1</ns1:NbEnreg><ns1:ListeResultat></ns1:ListeResultat><ns1:casseCodeTiers>false</ns1:casseCodeTiers><ns1:NbEnregPage>15</ns1:NbEnregPage><ns1:isFinancier></ns1:isFinancier><ns1:numeroTiers></ns1:numeroTiers><ns1:nom></ns1:nom><ns1:nomSigleRaison></ns1:nomSigleRaison><ns1:nomContact></ns1:nomContact><ns1:indicateurAssociation></ns1:indicateurAssociation><ns1:codeFamille></ns1:codeFamille><ns1:libelleFamille></ns1:libelleFamille><ns1:siren>44999696600015</ns1:siren><ns1:agence></ns1:agence><ns1:codeApe></ns1:codeApe><ns1:libelleCodeApe></ns1:libelleCodeApe><ns1:banque></ns1:banque><ns1:guichet></ns1:guichet><ns1:numeroCompte></ns1:numeroCompte><ns1:cleRIB></ns1:cleRIB><ns1:AdrEmail></ns1:AdrEmail><ns1:codePostal></ns1:codePostal><ns1:ville></ns1:ville><ns1:encodeKeyStatut>||</ns1:encodeKeyStatut><ns1:typeTiers></ns1:typeTiers><ns1:isPermanent></ns1:isPermanent><ns1:ancienNumero></ns1:ancienNumero><ns1:encodeKeyNomana></ns1:encodeKeyNomana><ns1:codeElement></ns1:codeElement><ns1:codeService></ns1:codeService><ns1:encodeKeyIdCompl></ns1:encodeKeyIdCompl><ns1:valeurIdCompl></ns1:valeurIdCompl></ns1:criteres><ns1:liste><ns1:EnregRechercheTiersReturn><ns1:T_0TIERS_ID>|253593|</ns1:T_0TIERS_ID><ns1:N>364163</ns1:N><ns1:Nom_Enregistrement>ALLIANCE JUDO 06</ns1:Nom_Enregistrement><ns1:Sigle></ns1:Sigle><ns1:Raison_Sociale>ALLIANCE JUDO 06</ns1:Raison_Sociale><ns1:Raison_Sociale_2></ns1:Raison_Sociale_2><ns1:Code_Postal>06220</ns1:Code_Postal><ns1:Localite>VALLAURIS</ns1:Localite></ns1:EnregRechercheTiersReturn></ns1:liste></ns1:response></soapenv:Body></soapenv:Envelope>
tests/data/astregs/RechercheTiersDetails.wsdl
1
<?xml version="1.0" encoding="UTF-8"?>
2
<wsdl:definitions name="RechercheTiersDetails" targetNamespace="http://gfi.astre.webservices/gf/recherchetiersdetails" xmlns:impl="http://gfi.astre.webservices/gf/recherchetiersdetails" xmlns:apachesoap="http://xml.apache.org/xml-soap" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:wsdlsoap="http://schemas.xmlsoap.org/wsdl/soap/">
3
  <wsdl:types>
4
    <schema elementFormDefault="qualified" targetNamespace="http://gfi.astre.webservices/gf/recherchetiersdetails" xmlns="http://www.w3.org/2001/XMLSchema">
5
	  
6
	
7
	<complexType name="Authentification">
8
		<sequence>
9
			<element name="USERNOM" type="string"/>
10
			<element name="USERPWD" type="string"/>
11
		</sequence>
12
	</complexType>
13
	
14
	<complexType name="Contexte">
15
		<sequence>
16
			<element name="Organisme" type="string"/>
17
			<element name="Budget" type="string"/>
18
			<element name="Exercice" type="string"/>
19
		</sequence>
20
	</complexType>
21
	
22
	<complexType name="CriteresRequest">
23
		<sequence>
24
			<element name="Authentification" type="impl:Authentification"/>
25
			<element name="Contexte" type="impl:Contexte"/>
26
			<element name="Criteres" type="impl:RechercheTiersDetails"/>
27
		</sequence>
28
	</complexType>
29
	
30
	<complexType name="ListeRechercheTiersDetails">
31
			<sequence>
32
				<element maxOccurs="unbounded" minOccurs="0" name="EnregRechercheTiersDetailsReturn" type="impl:EnregRechercheTiersDetails"/>
33
		</sequence>
34
	</complexType>
35
	
36
	 
37
	<complexType name="RechercheResponse">
38
		<sequence>
39
			<element name="criteres" type="impl:RechercheTiersDetails"/>
40
			<element name="liste" type="impl:ListeRechercheTiersDetails"/>
41
		</sequence>
42
	</complexType>			
43

  
44
	<complexType name="RechercheTiersDetails">
45
		<sequence>
46
	
47
			<element name="NbEnreg" nillable="true" type="xsd:string"/>
48
			<element name="ListeResultat" nillable="true" type="xsd:string"/>
49
			<element name="casseCodeTiers" nillable="true" type="xsd:string"/>
50
			<element name="NbEnregPage" nillable="true" type="xsd:string"/>
51
			<element name="isFinancier" nillable="true" type="xsd:string"/>
52
			<element name="numeroTiers" nillable="true" type="xsd:string"/>
53
			<element name="nom" nillable="true" type="xsd:string"/>
54
			<element name="nomSigleRaison" nillable="true" type="xsd:string"/>
55
			<element name="nomContact" nillable="true" type="xsd:string"/>
56
			<element name="indicateurAssociation" nillable="true" type="xsd:string"/>
57
			<element name="codeFamille" nillable="true" type="xsd:string"/>
58
			<element name="libelleFamille" nillable="true" type="xsd:string"/>
59
			<element name="siren" nillable="true" type="xsd:string"/>
60
			<element name="agence" nillable="true" type="xsd:string"/>
61
			<element name="codeApe" nillable="true" type="xsd:string"/>
62
			<element name="libelleCodeApe" nillable="true" type="xsd:string"/>
63
			<element name="banque" nillable="true" type="xsd:string"/>
64
			<element name="guichet" nillable="true" type="xsd:string"/>
65
			<element name="numeroCompte" nillable="true" type="xsd:string"/>
66
			<element name="cleRIB" nillable="true" type="xsd:string"/>
67
			<element name="AdrEmail" nillable="true" type="xsd:string"/>
68
			<element name="codePostal" nillable="true" type="xsd:string"/>
69
			<element name="ville" nillable="true" type="xsd:string"/>
70
			<element name="encodeKeyStatut" nillable="true" type="xsd:string"/>
71
			<element name="typeTiers" nillable="true" type="xsd:string"/>
72
			<element name="isPermanent" nillable="true" type="xsd:string"/>
73
			<element name="ancienNumero" nillable="true" type="xsd:string"/>
74
			<element name="encodeKeyNomana" nillable="true" type="xsd:string"/>
75
			<element name="codeElement" nillable="true" type="xsd:string"/>
76
			<element name="codeService" nillable="true" type="xsd:string"/>
77
			<element name="encodeKeyIdCompl" nillable="true" type="xsd:string"/>
78
			<element name="valeurIdCompl" nillable="true" type="xsd:string"/>
79

  
80
			</sequence>
81
		</complexType>
82

  
83
	 <element name="request" type="impl:CriteresRequest"/>
84
	 <element name="response" type="impl:RechercheResponse"/>	
85

  
86
	<complexType name="EnregRechercheTiersDetails">
87
			<all>
88
		
89
			<element name="TIERS_ID" nillable="true" type="xsd:string"/>	
90
			<element name="Code_tiers" nillable="true" type="xsd:string"/>	
91
			<element name="Organisme" nillable="true" type="xsd:string"/>	
92
			<element name="Nom_enregistrement" nillable="true" type="xsd:string"/>	
93
			<element name="Code_postal" nillable="true" type="xsd:string"/>	
94
			<element name="Libelle_Postale" nillable="true" type="xsd:string"/>	
95
			<element name="Adresse_destinataire" nillable="true" type="xsd:string"/>	
96
			<element name="Telephone" nillable="true" type="xsd:string"/>	
97
			<element name="Indicateur_tiers_financier" nillable="true" type="xsd:string"/>	
98
			<element name="Code_Famille_du_tiers" nillable="true" type="xsd:string"/>	
99
			<element name="libelle_court_de_la_famille" nillable="true" type="xsd:string"/>	
100
			<element name="Adresse_complementaire" nillable="true" type="xsd:string"/>	
101
			<element name="Numero_de_Fax" nillable="true" type="xsd:string"/>	
102
			<element name="le_libelle_court_du_statut" nillable="true" type="xsd:string"/>	
103
			<element name="Sigle" nillable="true" type="xsd:string"/>	
104
			<element name="Complement_geographique" nillable="true" type="xsd:string"/>	
105
			<element name="adresse_email" nillable="true" type="xsd:string"/>	
106
			<element name="Type_Tiers_D_ou_Fournisseur_ou_" nillable="true" type="xsd:string"/>	
107
			<element name="Nature_juridique_du_debiteur" nillable="true" type="xsd:string"/>	
108
			<element name="libelle_court" nillable="true" type="xsd:string"/>	
109
			<element name="Rue_-_Voie" nillable="true" type="xsd:string"/>	
110
			<element name="Page_Web" nillable="true" type="xsd:string"/>	
111
			<element name="Indicateur_tiers_permanent" nillable="true" type="xsd:string"/>	
112
			<element name="Code_APE_tiers" nillable="true" type="xsd:string"/>	
113
			<element name="Libelle_court" nillable="true" type="xsd:string"/>	
114
			<element name="Complement_voie_-_lieu_dit_-_BP" nillable="true" type="xsd:string"/>	
115
			<element name="identifiant_de_tiers_de_reprise" nillable="true" type="xsd:string"/>	
116
			<element name="Tiers_a_declarer_aux__fiscaux" nillable="true" type="xsd:string"/>	
117
			<element name="Numero_SIRET" nillable="true" type="xsd:string"/>
118
			</all>
119
		</complexType>
120
	</schema>
121
  </wsdl:types>
122
  <wsdl:message name="CriteresRequest">
123
    <wsdl:part name="request" element="impl:request">
124
    </wsdl:part>
125
  </wsdl:message>
126
  <wsdl:message name="ListeResponse">
127
    <wsdl:part name="response" element="impl:response">
128
    </wsdl:part>
129
  </wsdl:message>
130
  <wsdl:portType name="RechercheTiersDetails">
131
<wsdl:documentation>Web Service RechercheTiersDetails Astre</wsdl:documentation>
132
    <wsdl:operation name="liste">
133
      <wsdl:input name="CriteresRequest" message="impl:CriteresRequest">
134
    </wsdl:input>
135
      <wsdl:output name="ListeResponse" message="impl:ListeResponse">
136
    </wsdl:output>
137
    </wsdl:operation>
138
  </wsdl:portType>
139
  <wsdl:binding name="RechercheTiersDetailsSoapBinding" type="impl:RechercheTiersDetails">
140
    <wsdlsoap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
141
    <wsdl:operation name="liste">
142
      <wsdlsoap:operation soapAction="http://gfi.astre.webservices/gf/RechercheTiersDetails/Chargement"/>
143
      <wsdl:input name="CriteresRequest">
144
        <wsdlsoap:body use="literal"/>
145
      </wsdl:input>
146
      <wsdl:output name="ListeResponse">
147
        <wsdlsoap:body use="literal"/>
148
      </wsdl:output>
149
    </wsdl:operation>
150
  </wsdl:binding>
151
  <wsdl:service name="RechercheTiersDetails">
152
    <wsdl:port name="RechercheTiersDetails" binding="impl:RechercheTiersDetailsSoapBinding">
153
      <wsdlsoap:address location="http://10.1.20.153:28001/axis2/services/RechercheTiersDetails/"/>
154
    </wsdl:port>
155
  </wsdl:service>
156
</wsdl:definitions>
tests/data/astregs/RechercheTiersDetails.xml
1
<?xml version='1.0' encoding='utf-8'?><soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"><soapenv:Body><ns1:response xmlns:ns1="http://gfi.astre.webservices/gf/recherchetiersdetails"><ns1:criteres><ns1:NbEnreg>1</ns1:NbEnreg><ns1:ListeResultat></ns1:ListeResultat><ns1:casseCodeTiers>false</ns1:casseCodeTiers><ns1:NbEnregPage>15</ns1:NbEnregPage><ns1:isFinancier></ns1:isFinancier><ns1:numeroTiers></ns1:numeroTiers><ns1:nom></ns1:nom><ns1:nomSigleRaison></ns1:nomSigleRaison><ns1:nomContact></ns1:nomContact><ns1:indicateurAssociation></ns1:indicateurAssociation><ns1:codeFamille></ns1:codeFamille><ns1:libelleFamille></ns1:libelleFamille><ns1:siren>500433909*</ns1:siren><ns1:agence></ns1:agence><ns1:codeApe></ns1:codeApe><ns1:libelleCodeApe></ns1:libelleCodeApe><ns1:banque></ns1:banque><ns1:guichet></ns1:guichet><ns1:numeroCompte></ns1:numeroCompte><ns1:cleRIB></ns1:cleRIB><ns1:AdrEmail></ns1:AdrEmail><ns1:codePostal></ns1:codePostal><ns1:ville></ns1:ville><ns1:encodeKeyStatut>||</ns1:encodeKeyStatut><ns1:typeTiers></ns1:typeTiers><ns1:isPermanent></ns1:isPermanent><ns1:ancienNumero></ns1:ancienNumero><ns1:encodeKeyNomana></ns1:encodeKeyNomana><ns1:codeElement></ns1:codeElement><ns1:codeService></ns1:codeService><ns1:encodeKeyIdCompl></ns1:encodeKeyIdCompl><ns1:valeurIdCompl></ns1:valeurIdCompl></ns1:criteres><ns1:liste><ns1:EnregRechercheTiersDetailsReturn><ns1:TIERS_ID>11975</ns1:TIERS_ID><ns1:Code_tiers>173957</ns1:Code_tiers><ns1:Organisme>CG06</ns1:Organisme><ns1:Nom_enregistrement>ASSOCIATION OMNISPORTS DES MONTS D AZUR</ns1:Nom_enregistrement><ns1:Code_postal>06750</ns1:Code_postal><ns1:Libelle_Postale>SERANON</ns1:Libelle_Postale><ns1:Adresse_destinataire>ASS OMNISPORTS DES MONTS D AZUR</ns1:Adresse_destinataire><ns1:Telephone></ns1:Telephone><ns1:Indicateur_tiers_financier>1</ns1:Indicateur_tiers_financier><ns1:Code_Famille_du_tiers>51</ns1:Code_Famille_du_tiers><ns1:libelle_court_de_la_famille>PES-ASSOCIATIONS</ns1:libelle_court_de_la_famille><ns1:Adresse_complementaire></ns1:Adresse_complementaire><ns1:Numero_de_Fax></ns1:Numero_de_Fax><ns1:le_libelle_court_du_statut>validé</ns1:le_libelle_court_du_statut><ns1:Sigle></ns1:Sigle><ns1:Complement_geographique></ns1:Complement_geographique><ns1:adresse_email></ns1:adresse_email><ns1:Type_Tiers_D_ou_Fournisseur_ou_>*</ns1:Type_Tiers_D_ou_Fournisseur_ou_><ns1:Nature_juridique_du_debiteur>F1</ns1:Nature_juridique_du_debiteur><ns1:libelle_court></ns1:libelle_court><ns1:Rue_-_Voie xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:nil="1" /><ns1:Page_Web></ns1:Page_Web><ns1:Indicateur_tiers_permanent>1</ns1:Indicateur_tiers_permanent><ns1:Code_APE_tiers></ns1:Code_APE_tiers><ns1:Libelle_court xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:nil="1" /><ns1:Complement_voie_-_lieu_dit_-_BP xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:nil="1" /><ns1:identifiant_de_tiers_de_reprise>173957</ns1:identifiant_de_tiers_de_reprise><ns1:Tiers_a_declarer_aux__fiscaux>0</ns1:Tiers_a_declarer_aux__fiscaux><ns1:Numero_SIRET>50043390900016</ns1:Numero_SIRET></ns1:EnregRechercheTiersDetailsReturn></ns1:liste></ns1:response></soapenv:Body></soapenv:Envelope>
tests/data/astregs/RechercheTiersNoResult.xml
1
<?xml version='1.0' encoding='utf-8'?><soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"><soapenv:Body><ns1:response xmlns:ns1="http://gfi.astre.webservices/gf/recherchetiers"><ns1:criteres><ns1:NbEnreg>0</ns1:NbEnreg><ns1:ListeResultat></ns1:ListeResultat><ns1:casseCodeTiers>false</ns1:casseCodeTiers><ns1:NbEnregPage>15</ns1:NbEnregPage><ns1:isFinancier></ns1:isFinancier><ns1:numeroTiers></ns1:numeroTiers><ns1:nom></ns1:nom><ns1:nomSigleRaison></ns1:nomSigleRaison><ns1:nomContact></ns1:nomContact><ns1:indicateurAssociation></ns1:indicateurAssociation><ns1:codeFamille></ns1:codeFamille><ns1:libelleFamille></ns1:libelleFamille><ns1:siren>449996966000</ns1:siren><ns1:agence></ns1:agence><ns1:codeApe></ns1:codeApe><ns1:libelleCodeApe></ns1:libelleCodeApe><ns1:banque></ns1:banque><ns1:guichet></ns1:guichet><ns1:numeroCompte></ns1:numeroCompte><ns1:cleRIB></ns1:cleRIB><ns1:AdrEmail></ns1:AdrEmail><ns1:codePostal></ns1:codePostal><ns1:ville></ns1:ville><ns1:encodeKeyStatut>||</ns1:encodeKeyStatut><ns1:typeTiers></ns1:typeTiers><ns1:isPermanent></ns1:isPermanent><ns1:ancienNumero></ns1:ancienNumero><ns1:encodeKeyNomana></ns1:encodeKeyNomana><ns1:codeElement></ns1:codeElement><ns1:codeService></ns1:codeService><ns1:encodeKeyIdCompl></ns1:encodeKeyIdCompl><ns1:valeurIdCompl></ns1:valeurIdCompl></ns1:criteres><ns1:liste /></ns1:response></soapenv:Body></soapenv:Envelope>
tests/data/astregs/Tiers.wsdl
1
<?xml version="1.0" encoding="UTF-8"?>
2
<wsdl:definitions name="Tiers" targetNamespace="http://gfi.astre.webservices/gf/tiers" xmlns:impl="http://gfi.astre.webservices/gf/tiers" xmlns:apachesoap="http://xml.apache.org/xml-soap" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:wsdlsoap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:intf="http://gfi.astre.webservices/gf/tiers">
3
  <wsdl:types>
4
    <schema elementFormDefault="qualified" targetNamespace="http://gfi.astre.webservices/gf/tiers" xmlns="http://www.w3.org/2001/XMLSchema">
5
				<!--  request et response -->	
6
			
7
	<complexType name="Authentification">
8
		<sequence>
9
			<element name="USERNOM" type="string"/>
10
			<element name="USERPWD" type="string"/>
11
		</sequence>
12
	</complexType>
13
	
14
	<complexType name="Contexte">
15
		<sequence>
16
			<element name="Organisme" type="string"/>
17
			<element name="Budget" type="string"/>
18
			<element name="Exercice" type="string"/>
19
		</sequence>
20
	</complexType>
21
	
22
	<complexType name="TiersRequest">
23
				<sequence>
24
			<element name="Authentification" type="impl:Authentification"/>
25
			<element name="Contexte" type="impl:Contexte"/>
26
		<element name="Tiers" type="impl:Tiers"/>
27
				</sequence>
28
			</complexType>
29
		<complexType name="TiersResponse">
30
			<sequence>		
31
				<element name="TiersReturn" type="impl:Tiers"/>
32
			</sequence>
33
		</complexType>
34
		
35
		<complexType name="Tiers">
36
		    <sequence>
37
         <element name="Financier" nillable="true" type="xsd:string"/>
38
         <element name="CodeTiers" nillable="true" type="xsd:string"/>
39
         <element name="CodeFamille" nillable="true" type="xsd:string"/>
40
         <element name="CatTiers" nillable="true" type="xsd:string"/>
41
         <element name="CodeCivilite" nillable="true" type="xsd:string"/>
42
         <element name="NomEnregistrement" nillable="true" type="xsd:string"/>
43
         <element name="Nom" nillable="true" type="xsd:string"/>
44
         <element name="Prenom" nillable="true" type="xsd:string"/>
45
         <element name="Sigle" nillable="true" type="xsd:string"/>
46
         <element name="Organisme" nillable="true" type="xsd:string"/>
47
         <element name="RaisonSociale3" nillable="true" type="xsd:string"/>
48
         <element name="RaisonSociale4" nillable="true" type="xsd:string"/>
49
         <element name="RaisonSociale5" nillable="true" type="xsd:string"/>
50
         <element name="RaisonSociale6" nillable="true" type="xsd:string"/>
51
         <element name="LibelleCourrier" nillable="true" type="xsd:string"/>
52
         <element name="EncodeKeyNatjur" nillable="true" type="xsd:string"/>
53
         <element name="CodeAPE" nillable="true" type="xsd:string"/>
54
         <element name="NumeroSiret" nillable="true" type="xsd:string"/>
55
         <element name="NumeroSiretFin" nillable="true" type="xsd:string"/>
56
         <element name="Commentaire" nillable="true" type="xsd:string"/>
57
         <element name="AdresseDestinataire" nillable="true" type="xsd:string"/>
58
         <element name="AdresseTitre" nillable="true" type="xsd:string"/>
59
         <element name="IdentifiantAdresse" nillable="true" type="xsd:string"/>
60
         <element name="AdresseIsAdresseDeFacturation" nillable="true" type="xsd:string"/>
61
         <element name="AdresseIsAdresseDeCommande" nillable="true" type="xsd:string"/>
62
         <element name="AdresseComplementDestinataire" nillable="true" type="xsd:string"/>
63
         <element name="AdresseComplementaire" nillable="true" type="xsd:string"/>
64
         <element name="AdresseLibelleRue" nillable="true" type="xsd:string"/>
65
         <element name="AdresseComplementVoie" nillable="true" type="xsd:string"/>
66
         <element name="AdresseCodePostal" nillable="true" type="xsd:string"/>
67
         <element name="AdresseBureauDistributeur" nillable="true" type="xsd:string"/>
68
         <element name="AdresseCodePays" nillable="true" type="xsd:string"/>
69
         <element name="AdresseLibellePays" nillable="true" type="xsd:string"/>
70
         <element name="NumeroTelephone" nillable="true" type="xsd:string"/>
71
         <element name="NumeroFax" nillable="true" type="xsd:string"/>
72
         <element name="Mail" nillable="true" type="xsd:string"/>
73
         <element name="SiteWeb" nillable="true" type="xsd:string"/>
74
         <element name="CodeTiersReprise" nillable="true" type="xsd:string"/>
75
         <element name="StatutTiers" nillable="true" type="xsd:string"/>
76
         <element name="Type" nillable="true" type="xsd:string"/>
77
         <element name="Permanent" nillable="true" type="xsd:string"/>
78
         <element name="IndSeuil" nillable="true" type="xsd:string"/>
79
         <element name="DelaiSuiviFacture" nillable="true" type="xsd:string"/>
80
         <element name="Remise" nillable="true" type="xsd:string"/>
81
         <element name="DeclarationFiscale" nillable="true" type="xsd:string"/>
82
         <element name="IndicateurTiersSubrogatoire" nillable="true" type="xsd:string"/>
83
         <element name="ValeurIdentifiant0" nillable="true" type="xsd:string"/>
84
         <element name="ValeurIdentifiant1" nillable="true" type="xsd:string"/>
85
         <element name="ValeurIdentifiant2" nillable="true" type="xsd:string"/>
86
         <element name="ValeurIdentifiant3" nillable="true" type="xsd:string"/>
87
         <element name="ValeurIdentifiant4" nillable="true" type="xsd:string"/>
88
         <element name="ValeurIdentifiant5" nillable="true" type="xsd:string"/>
89
         <element name="ValeurIdentifiant6" nillable="true" type="xsd:string"/>
90
         <element name="ValeurIdentifiant7" nillable="true" type="xsd:string"/>
91
         <element name="ValeurIdentifiant8" nillable="true" type="xsd:string"/>
92
         <element name="ValeurIdentifiant9" nillable="true" type="xsd:string"/>
93
         <element name="NoDeclarationPref" nillable="true" type="xsd:string"/>
94
         <element name="TiersContactId" nillable="true" type="xsd:string"/>
95
         <element name="EncodeKeyContact" nillable="true" type="xsd:string"/>
96
         <element name="EncodeKeyFonction" nillable="true" type="xsd:string"/>
97
         <element name="LibelleFonction" nillable="true" type="xsd:string"/>
98
         <element name="DateDebutFonction" nillable="true" type="xsd:string"/> 
99
         <element name="DateFinFonction" nillable="true" type="xsd:string"/>
100
</sequence>
101
	</complexType>
102
	
103
	<complexType name="Tiers_Cle">
104
		<sequence>
105
			<element name="CodeTiers" nillable="true" type="xsd:string"/>
106
		</sequence>
107
	</complexType>
108
	
109
	<complexType name="TiersRequest_Cles">
110
	   	<sequence>
111
			<element name="Authentification" type="impl:Authentification"/>
112
			<element name="Contexte" type="impl:Contexte"/>
113
		<element name="TiersCle" type="impl:Tiers_Cle"/>
114
		
115
				</sequence>
116
			</complexType>
117
			
118
		<element name="creation">
119
			<complexType>
120
				<sequence>
121
					<element name="request" type="impl:TiersRequest"/>
122
				</sequence>
123
			</complexType>
124
		</element>
125
		
126
		<element name="creationResponse">
127
			<complexType>
128
				<sequence>
129
					<element name="response" type="impl:TiersResponse"/>
130
				</sequence>
131
			</complexType>
132
		</element>
133
		
134
		<element name="modification">
135
			<complexType>
136
				<sequence>
137
					<element name="request" type="impl:TiersRequest"/>
138
				</sequence>
139
			</complexType>
140
		</element>
141
		
142
		<element name="modificationResponse">
143
			<complexType>
144
				<sequence>
145
					<element name="response" type="impl:TiersResponse"/>
146
				</sequence>
147
			</complexType>
148
		</element>
149
		
150
		<element name="suppression">
151
			<complexType>
152
				<sequence>
153
					<element name="request" type="impl:TiersRequest_Cles"/>
154
				</sequence>
155
			</complexType>
156
		</element>
157
		
158
		<element name="suppressionResponse">
159
			<complexType>
160
				<sequence>
161
					<element name="response" type="impl:TiersResponse"/>
162
				</sequence>
163
			</complexType>
164
		</element>
165
		
166
		<element name="chargement">
167
			<complexType>
168
				<sequence>
169
					<element name="request" type="impl:TiersRequest_Cles"/>
170
				</sequence>
171
			</complexType>
172
		</element>
173
		
174
		<element name="chargementResponse">
175
			<complexType>
176
				<sequence>
177
					<element name="response" type="impl:TiersResponse"/>
178
				</sequence>
179
			</complexType>
180
		</element>
181
		
182
		
183
		</schema>
184
  </wsdl:types>
185
  <wsdl:message name="modificationResponse">
186
    <wsdl:part name="response" element="impl:modificationResponse">
187
    </wsdl:part>
188
  </wsdl:message>
189
  <wsdl:message name="suppressionRequest">
190
    <wsdl:part name="request" element="impl:suppression">
191
    </wsdl:part>
192
  </wsdl:message>
193
  <wsdl:message name="chargementRequest">
194
    <wsdl:part name="request" element="impl:chargement">
195
    </wsdl:part>
196
  </wsdl:message>
197
  <wsdl:message name="suppressionResponse">
198
    <wsdl:part name="response" element="impl:suppressionResponse">
199
    </wsdl:part>
200
  </wsdl:message>
201
  <wsdl:message name="creationRequest">
202
    <wsdl:part name="request" element="impl:creation">
203
    </wsdl:part>
204
  </wsdl:message>
205
  <wsdl:message name="modificationRequest">
206
    <wsdl:part name="request" element="impl:modification">
207
    </wsdl:part>
208
  </wsdl:message>
209
  <wsdl:message name="creationResponse">
210
    <wsdl:part name="response" element="impl:creationResponse">
211
    </wsdl:part>
212
  </wsdl:message>
213
  <wsdl:message name="chargementResponse">
214
    <wsdl:part name="response" element="impl:chargementResponse">
215
    </wsdl:part>
216
  </wsdl:message>
217
  <wsdl:portType name="Tiers">
218
<wsdl:documentation>Web service des Tiers Astre </wsdl:documentation>
219
    <wsdl:operation name="Modification">
220
<wsdl:documentation>
221
				le champ encodeKey est obligatoire ainsi que le champ à modifier
222
			</wsdl:documentation>
223
      <wsdl:input name="modificationRequest" message="impl:modificationRequest">
224
    </wsdl:input>
225
      <wsdl:output name="modificationResponse" message="impl:modificationResponse">
226
    </wsdl:output>
227
    </wsdl:operation>
228
    <wsdl:operation name="Chargement">
229
<wsdl:documentation>
230
				le champ encodeKey est obligatoire
231
			</wsdl:documentation>
232
      <wsdl:input name="chargementRequest" message="impl:chargementRequest">
233
    </wsdl:input>
234
      <wsdl:output name="chargementResponse" message="impl:chargementResponse">
235
    </wsdl:output>
236
    </wsdl:operation>
237
    <wsdl:operation name="Creation">
238
<wsdl:documentation>
239
				tous les champs sont obligatoires
240
			</wsdl:documentation>
241
      <wsdl:input name="creationRequest" message="impl:creationRequest">
242
    </wsdl:input>
243
      <wsdl:output name="creationResponse" message="impl:creationResponse">
244
    </wsdl:output>
245
    </wsdl:operation>
246
    <wsdl:operation name="Suppression">
247
<wsdl:documentation>
248
				tous les champs sont obligatoires
249
			</wsdl:documentation>
250
      <wsdl:input name="suppressionRequest" message="impl:suppressionRequest">
251
    </wsdl:input>
252
      <wsdl:output name="suppressionResponse" message="impl:suppressionResponse">
253
    </wsdl:output>
254
    </wsdl:operation>
255
  </wsdl:portType>
256
  <wsdl:binding name="TiersSoapBinding" type="impl:Tiers">
257
    <wsdlsoap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
258
    <wsdl:operation name="Modification">
259
      <wsdlsoap:operation soapAction=""/>
260
      <wsdl:input name="modificationRequest">
261
        <wsdlsoap:body use="literal"/>
262
      </wsdl:input>
263
      <wsdl:output name="modificationResponse">
264
        <wsdlsoap:body use="literal"/>
265
      </wsdl:output>
266
    </wsdl:operation>
267
    <wsdl:operation name="Suppression">
268
      <wsdlsoap:operation soapAction=""/>
269
      <wsdl:input name="suppressionRequest">
270
        <wsdlsoap:body use="literal"/>
271
      </wsdl:input>
272
      <wsdl:output name="suppressionResponse">
273
        <wsdlsoap:body use="literal"/>
274
      </wsdl:output>
275
    </wsdl:operation>
276
    <wsdl:operation name="Creation">
277
      <wsdlsoap:operation soapAction=""/>
278
      <wsdl:input name="creationRequest">
279
        <wsdlsoap:body use="literal"/>
280
      </wsdl:input>
281
      <wsdl:output name="creationResponse">
282
        <wsdlsoap:body use="literal"/>
283
      </wsdl:output>
284
    </wsdl:operation>
285
    <wsdl:operation name="Chargement">
286
      <wsdlsoap:operation soapAction=""/>
287
      <wsdl:input name="chargementRequest">
288
        <wsdlsoap:body use="literal"/>
289
      </wsdl:input>
290
      <wsdl:output name="chargementResponse">
291
        <wsdlsoap:body use="literal"/>
292
      </wsdl:output>
293
    </wsdl:operation>
294
  </wsdl:binding>
295
  <wsdl:service name="Tiers">
296
    <wsdl:port name="Tiers" binding="impl:TiersSoapBinding">
297
      <wsdlsoap:address location="http://10.1.20.153:28001/axis2/services/Tiers/"/>
298
    </wsdl:port>
299
  </wsdl:service>
300
</wsdl:definitions>
tests/data/astregs/Tiers.xml
1
<?xml version='1.0' encoding='utf-8'?><soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"><soapenv:Body><ns1:chargementResponse xmlns:ns1="http://gfi.astre.webservices/gf/tiers"><ns1:response><ns1:TiersReturn><ns1:Financier>true</ns1:Financier><ns1:CodeTiers>173957</ns1:CodeTiers><ns1:CodeFamille>51</ns1:CodeFamille><ns1:CatTiers>50</ns1:CatTiers><ns1:CodeCivilite></ns1:CodeCivilite><ns1:NomEnregistrement>ASSOCIATION OMNISPORTS DES MONTS D AZUR</ns1:NomEnregistrement><ns1:Nom></ns1:Nom><ns1:Prenom></ns1:Prenom><ns1:Sigle></ns1:Sigle><ns1:Organisme>CG06</ns1:Organisme><ns1:RaisonSociale3>ASSOCIATION OMNISPORTS DES</ns1:RaisonSociale3><ns1:RaisonSociale4>MONTS D&amp;#39;AZUR</ns1:RaisonSociale4><ns1:RaisonSociale5></ns1:RaisonSociale5><ns1:RaisonSociale6></ns1:RaisonSociale6><ns1:LibelleCourrier>ASS OMNISPORTS DES MONTS D AZUR</ns1:LibelleCourrier><ns1:EncodeKeyNatjur>F1</ns1:EncodeKeyNatjur><ns1:CodeAPE></ns1:CodeAPE><ns1:NumeroSiret>500433909</ns1:NumeroSiret><ns1:NumeroSiretFin>00016</ns1:NumeroSiretFin><ns1:Commentaire>Autres activités liées au sport (9319Z)</ns1:Commentaire><ns1:AdresseDestinataire>ASS OMNISPORTS DES MONTS D AZUR</ns1:AdresseDestinataire><ns1:AdresseTitre>ADRESSE PROFESSIONNELLE</ns1:AdresseTitre><ns1:IdentifiantAdresse>22791</ns1:IdentifiantAdresse><ns1:AdresseIsAdresseDeFacturation>true</ns1:AdresseIsAdresseDeFacturation><ns1:AdresseIsAdresseDeCommande>true</ns1:AdresseIsAdresseDeCommande><ns1:AdresseComplementDestinataire></ns1:AdresseComplementDestinataire><ns1:AdresseComplementaire></ns1:AdresseComplementaire><ns1:AdresseLibelleRue>271 CHEMIN DE CURNIER</ns1:AdresseLibelleRue><ns1:AdresseComplementVoie></ns1:AdresseComplementVoie><ns1:AdresseCodePostal>06750</ns1:AdresseCodePostal><ns1:AdresseBureauDistributeur>SERANON</ns1:AdresseBureauDistributeur><ns1:AdresseCodePays></ns1:AdresseCodePays><ns1:AdresseLibellePays>FRANCE</ns1:AdresseLibellePays><ns1:NumeroTelephone></ns1:NumeroTelephone><ns1:NumeroFax></ns1:NumeroFax><ns1:Mail></ns1:Mail><ns1:SiteWeb></ns1:SiteWeb><ns1:CodeTiersReprise>173957</ns1:CodeTiersReprise><ns1:StatutTiers>VALIDE</ns1:StatutTiers><ns1:Type>*</ns1:Type><ns1:Permanent>true</ns1:Permanent><ns1:IndSeuil>false</ns1:IndSeuil><ns1:DelaiSuiviFacture>0</ns1:DelaiSuiviFacture><ns1:Remise>0,00</ns1:Remise><ns1:DeclarationFiscale>false</ns1:DeclarationFiscale><ns1:IndicateurTiersSubrogatoire>false</ns1:IndicateurTiersSubrogatoire><ns1:ValeurIdentifiant0></ns1:ValeurIdentifiant0><ns1:ValeurIdentifiant1></ns1:ValeurIdentifiant1><ns1:ValeurIdentifiant2></ns1:ValeurIdentifiant2><ns1:ValeurIdentifiant3></ns1:ValeurIdentifiant3><ns1:ValeurIdentifiant4></ns1:ValeurIdentifiant4><ns1:ValeurIdentifiant5></ns1:ValeurIdentifiant5><ns1:ValeurIdentifiant6></ns1:ValeurIdentifiant6><ns1:ValeurIdentifiant7></ns1:ValeurIdentifiant7><ns1:ValeurIdentifiant8></ns1:ValeurIdentifiant8><ns1:ValeurIdentifiant9></ns1:ValeurIdentifiant9><ns1:NoDeclarationPref></ns1:NoDeclarationPref><ns1:TiersContactId>12967</ns1:TiersContactId><ns1:EncodeKeyContact>13012</ns1:EncodeKeyContact><ns1:EncodeKeyFonction></ns1:EncodeKeyFonction><ns1:LibelleFonction></ns1:LibelleFonction><ns1:DateDebutFonction></ns1:DateDebutFonction><ns1:DateFinFonction></ns1:DateFinFonction></ns1:TiersReturn></ns1:response></ns1:chargementResponse></soapenv:Body></soapenv:Envelope>
tests/test_astregs.py
1
# -*- coding: utf-8 -*-
2

  
3
import os
4
import mock
5
import pytest
6

  
7
from passerelle.apps.astregs.models import AstreGS, Link
8

  
9
from . import utils
10

  
11
BASE_URL = 'https://test-ws-astre-gs.departement06.fr/axis2/services/'
12

  
13
def contact_search_side_effect(wsdl_url, **kwargs):
14
    if 'Tiers' in wsdl_url:
15
        response_content = file(os.path.join(os.path.dirname(__file__),
16
                                'data', 'astregs', 'Tiers.xml')).read()
17
    else:
18
        response_content = file(os.path.join(os.path.dirname(__file__),
19
                                'data', 'astregs', 'Contact.xml')).read()
20
    return mock.Mock(content=response_content, status_code=200,
21
                     headers={'Content-Type': 'text/xml'})
22

  
23
def search_wsdl_side_effect(wsdl_url, **kwargs):
24
    if 'Tiers' in wsdl_url:
25
        response_content = file(os.path.join(os.path.dirname(__file__),
26
                                'data', 'astregs', 'Tiers.wsdl')).read()
27
    else:
28
        response_content = file(os.path.join(os.path.dirname(__file__),
29
                                'data', 'astregs', 'Contact.wsdl')).read()
30
    return mock.Mock(content=response_content, status_code=200,
31
                     headers={'Content-Type': 'text/xml'})
32

  
33

  
34
@pytest.fixture
35
def connector(db):
36
    return utils.make_resource(AstreGS,
37
            title='Test', slug='test',
38
            description='test', wsdl_base_url=BASE_URL,
39
            username='CS-FORML', password='secret',
40
            organism='CG06', budget='01',
41
            exercice='2019'
42
    )
43

  
44

  
45
@mock.patch('passerelle.utils.Request.get')
46
@mock.patch('passerelle.utils.Request.post')
47
def test_search_association_by_siren(mocked_post, mocked_get, connector, app):
48
    wsdl_content = file(os.path.join(os.path.dirname(__file__),
49
                                     'data', 'astregs', 'RechercheTiersDetails.wsdl')).read()
50
    response_content = file(os.path.join(os.path.dirname(__file__),
51
                                     'data', 'astregs', 'RechercheTiersDetails.xml')).read()
52
    mocked_get.return_value = mock.Mock(content=wsdl_content)
53
    mocked_post.return_value = mock.Mock(content=response_content, status_code=200,
54
                                         headers={'Content-Type': 'text/xml'})
55
    resp = app.get('/astregs/test/associations', params={'siren': '500433909'})
56
    assert mocked_get.call_args[0][0] == '%sRechercheTiersDetails?wsdl' % BASE_URL
57
    assert mocked_post.call_args[0][0] == '%sRechercheTiersDetails/' % BASE_URL
58
    assert isinstance(resp.json['data'], list)
59
    assert len(resp.json['data']) > 0
60
    assert resp.json['data'][0]['id'] == '50043390900016'
61
    assert resp.json['data'][0]['text'] == '50043390900016 - ASSOCIATION OMNISPORTS DES MONTS D AZUR'
62
    assert resp.json['data'][0]['code'] == '173957'
63
    assert resp.json['data'][0]['name'] == 'ASSOCIATION OMNISPORTS DES MONTS D AZUR'
64

  
65

  
66
@mock.patch('passerelle.utils.Request.get')
67
@mock.patch('passerelle.utils.Request.post')
68
def test_check_association_presence(mocked_post, mocked_get, connector, app):
69
    wsdl_content = file(os.path.join(os.path.dirname(__file__),
70
                                     'data', 'astregs', 'RechercheTiers.wsdl')).read()
71
    response_content = file(os.path.join(os.path.dirname(__file__),
72
                                     'data', 'astregs', 'RechercheTiers.xml')).read()
73
    mocked_get.return_value = mock.Mock(content=wsdl_content)
74
    mocked_post.return_value = mock.Mock(content=response_content, status_code=200,
75
                                         headers={'Content-Type': 'text/xml'})
76
    resp = app.get('/astregs/test/check-association-by-siret', params={'siret': '50043390900014'})
77
    assert resp.json['exists'] == True
78
    response_content = file(os.path.join(os.path.dirname(__file__),
79
                                     'data', 'astregs', 'RechercheTiersNoResult.xml')).read()
80
    mocked_post.return_value = mock.Mock(content=response_content, status_code=200,
81
                                         headers={'Content-Type': 'text/xml'})
82
    resp = app.get('/astregs/test/check-association-by-siret', params={'siret': 'unknown'})
83
    assert resp.json['exists'] == False
84

  
85

  
86
@mock.patch('passerelle.utils.Request.get', side_effect=search_wsdl_side_effect)
87
@mock.patch('passerelle.utils.Request.post', side_effect=contact_search_side_effect)
88
def test_association_linking_means(mocked_post, mocked_get, client, connector, app):
89
    resp = app.get('/astregs/test/get-association-link-means', params={'association_id': '42'})
90
    assert len(resp.json['data']) == 3
91
    for result in resp.json['data']:
92
        assert 'id' in result
93
        assert 'text' in result
94
        assert 'type' in result
95
        assert 'value' in result
96

  
97
@mock.patch('passerelle.utils.Request.get', side_effect=search_wsdl_side_effect)
98
@mock.patch('passerelle.utils.Request.post', side_effect=contact_search_side_effect)
99
def test_link_user_to_association(mocked_post, mocked_get, client, connector, app):
100
    assert Link.objects.count() == 0
101
    resp = app.get('/astregs/test/get-association-link-means', params={'association_id': '42'})
102
    assert len(resp.json['data']) == 3
103
    resp = app.post_json('/astregs/test/link', params={'association_id': '42', 'NameID': 'user_name_id'})
104
    assert Link.objects.filter(name_id='user_name_id', association_id='42').count() == 1
105
    link = Link.objects.get(name_id='user_name_id', association_id='42')
106
    assert resp.json['association_id'] == link.association_id
107
    assert resp.json['link'] == link.pk
108
    assert resp.json['created'] == True
109
    resp = app.post_json('/astregs/test/link', params={'association_id': '42', 'NameID': 'user_name_id'})
110
    assert resp.json['created'] == False
111

  
112

  
113
@mock.patch('passerelle.utils.Request.get', side_effect=search_wsdl_side_effect)
114
@mock.patch('passerelle.utils.Request.post', side_effect=contact_search_side_effect)
115
def test_unlink_user_from_association(mocked_post, mocked_get, connector, app):
116
    resp = app.get('/astregs/test/get-association-link-means', params={'association_id': '42'})
117
    resp = app.post_json('/astregs/test/link', params={'association_id': '42', 'NameID': 'user_name_id'})
118
    resp = app.get('/astregs/test/unlink', params={'NameID': 'user_name_id', 'association_id': '42'})
119
    assert resp.json['deleted']
120
    resp = app.get('/astregs/test/unlink', params={'NameID': 'user_name_id', 'association_id': '42'}, status=404)
0
-