def _create_saml_provider_config(): provider_id = 'saml.{0}'.format(_random_string()) return auth.create_saml_provider_config( provider_id=provider_id, idp_entity_id='IDP_ENTITY_ID', sso_url='https://example.com/login', x509_certificates=[X509_CERTIFICATES[0]], rp_entity_id='RP_ENTITY_ID', callback_url='https://projectId.firebaseapp.com/__/auth/handler', display_name='SAML_DISPLAY_NAME', enabled=True)
def test_create(self, user_mgt_app): recorder = _instrument_provider_mgt(user_mgt_app, 200, SAML_PROVIDER_CONFIG_RESPONSE) provider_config = auth.create_saml_provider_config( **self.VALID_CREATE_OPTIONS, app=user_mgt_app) self._assert_provider_config(provider_config) assert len(recorder) == 1 req = recorder[0] assert req.method == 'POST' assert req.url == '{0}/inboundSamlConfigs?inboundSamlConfigId=saml.provider'.format( USER_MGT_URLS['PREFIX']) got = json.loads(req.body.decode()) assert got == self.SAML_CONFIG_REQUEST
def create_saml_provider_config(): # [START create_saml_provider] saml = auth.create_saml_provider_config( display_name='SAML provider name', enabled=True, provider_id='saml.myProvider', idp_entity_id='IDP_ENTITY_ID', sso_url='https://example.com/saml/sso/1234/', x509_certificates=[ '-----BEGIN CERTIFICATE-----\nCERT1...\n-----END CERTIFICATE-----', '-----BEGIN CERTIFICATE-----\nCERT2...\n-----END CERTIFICATE-----', ], rp_entity_id='P_ENTITY_ID', callback_url='https://project-id.firebaseapp.com/__/auth/handler') print('Created new SAML provider:', saml.provider_id)
def test_create_empty_values(self, user_mgt_app): recorder = _instrument_provider_mgt(user_mgt_app, 200, SAML_PROVIDER_CONFIG_RESPONSE) options = dict(self.VALID_CREATE_OPTIONS) options['display_name'] = '' options['enabled'] = False want = dict(self.SAML_CONFIG_REQUEST) want['displayName'] = '' want['enabled'] = False provider_config = auth.create_saml_provider_config(**options, app=user_mgt_app) self._assert_provider_config(provider_config) assert len(recorder) == 1 req = recorder[0] assert req.method == 'POST' assert req.url == '{0}/inboundSamlConfigs?inboundSamlConfigId=saml.provider'.format( USER_MGT_URLS['PREFIX']) got = json.loads(req.body.decode()) assert got == want
def test_create_invalid_args(self, user_mgt_app, invalid_opts): options = dict(self.VALID_CREATE_OPTIONS) options.update(invalid_opts) with pytest.raises(ValueError): auth.create_saml_provider_config(**options, app=user_mgt_app)