示例#1
0
 def test_bad_attributes(self, mocked):
     FakeConfig('http://localhost:8088/sso', 'http://localhost:8088/')
     validator = SpidMetadataValidator()
     metadata = create_sp_metadata(
         entity_id='http://test.sp',
         authn_request_signed='true',
         assertion_consumer_services=[Acs(location='http://test.sp/acs')],
         attribute_consuming_services=[
             Atcs(
                 service_name='test_1',
                 attributes=['badAttr']
             )
         ],
         single_logout_services=[
             Slo(binding=BINDING_HTTP_POST, location='http://test.sp/slo')
         ],
         keys=[Key('signing', 'somevalue123')],
         check_attributes=False
     ).to_xml()
     with pytest.raises(SPIDValidationError) as excinfo:
         validator.validate(metadata)
     exc = excinfo.value
     self.assertEqual(
         'EntityDescriptor/SPSSODescriptor/AttributeConsumingService/0/RequestedAttribute/0 - attribute: Name',
         exc.details[0].path
     )
     self.assertEqual('Il valore dell\'elemento non corrisponde a nessuno dei valori attesi ({}):'.format(
         ', '.join(settings.SPID_ATTRIBUTES_NAMES)), exc.details[0].message)
示例#2
0
 def test_keydescriptor_no_signing(self, mocked):
     FakeConfig('http://localhost:8088/sso', 'http://localhost:8088/')
     validator = SpidMetadataValidator()
     metadata = create_sp_metadata(
         entity_id='http://test.sp',
         authn_request_signed='true',
         assertion_consumer_services=[Acs(location='http://test.sp/acs')],
         attribute_consuming_services=[
             Atcs(
                 service_name='test_1',
                 attributes=['spidCode']
             )
         ],
         single_logout_services=[
             Slo(binding=BINDING_HTTP_POST, location='http://test.sp/slo')
         ],
         keys=[Key('encryption', 'somevalue123')]
     ).to_xml()
     with pytest.raises(SPIDValidationError) as excinfo:
         validator.validate(metadata)
     exc = excinfo.value
     self.assertEqual(
         'EntityDescriptor/SPSSODescriptor/KeyDescriptor',
         exc.details[0].path
     )
     self.assertEqual('Deve essere presente almeno una chiave con attributo use uguale a "signing"',
                      exc.details[0].message)
示例#3
0
 def test_valid_metadata(self, mocked):
     FakeConfig('http://localhost:8088/sso', 'http://localhost:8088/')
     validator = SpidMetadataValidator()
     metadata = create_sp_metadata(
         entity_id='http://test.sp',
         authn_request_signed='true',
         assertion_consumer_services=[Acs(location='http://test.sp/acs')],
         attribute_consuming_services=[
             Atcs(service_name='test_1', attributes=['spidCode'])
         ],
         single_logout_services=[
             Slo(binding=BINDING_HTTP_POST, location='http://test.sp/slo')
         ],
         keys=[Key('signing', 'somevalue123')]).to_xml()
     validator.validate(metadata)
示例#4
0
 def __init__(self):
     self._validators = ValidatorGroup([
         XMLMetadataFormatValidator(),
         ServiceProviderMetadataXMLSchemaValidator(),
         SpidMetadataValidator(),
     ])
     self._index_metadata()
示例#5
0
 def test_missing_slo(self, mocked):
     FakeConfig('http://localhost:8088/sso', 'http://localhost:8088/')
     validator = SpidMetadataValidator()
     metadata = create_sp_metadata(
         entity_id='http://test.sp',
         authn_request_signed='true',
         assertion_consumer_services=[Acs(location='http://test.sp/acs')],
         attribute_consuming_services=[
             Atcs(service_name='test_1', attributes=['spidCode'])
         ],
         single_logout_services=[],
         keys=[Key('signing', 'somevalue123')]).to_xml()
     with pytest.raises(SPIDValidationError) as excinfo:
         validator.validate(metadata)
     exc = excinfo.value
     self.assertEqual(
         'EntityDescriptor/SPSSODescriptor/SingleLogoutService',
         exc.details[0].path)
     self.assertEqual('required key not provided', exc.details[0].message)
示例#6
0
 def __init__(self):
     self._loaders = []
     for source_type, source_params in config.params.metadata.items():
         self._loaders.append({
             'local': ServiceProviderMetadataFileLoader,
             'remote': ServiceProviderMetadataHTTPLoader,
             'db': ServiceProviderMetadataDbLoader,
         }[source_type](source_params))
     self._validators = ValidatorGroup([
         XMLMetadataFormatValidator(),
         ServiceProviderMetadataXMLSchemaValidator(),
         SpidMetadataValidator(),
     ])