Clean up the auto generated domain

During the federation test, when creating an identity provider, a
new domain will be created as well. This auto generated domain
should be cleaned up when test exit.

Depends-on: https://review.openstack.org/#/c/628132/
Change-Id: I6dcd0a0154c8658585a98ae138825881fe51d664
diff --git a/keystone_tempest_plugin/tests/api/identity/v3/test_identity_providers.py b/keystone_tempest_plugin/tests/api/identity/v3/test_identity_providers.py
index 97f651f..fef14ea 100644
--- a/keystone_tempest_plugin/tests/api/identity/v3/test_identity_providers.py
+++ b/keystone_tempest_plugin/tests/api/identity/v3/test_identity_providers.py
@@ -43,6 +43,13 @@
     def _create_idp(self, idp_id, idp_ref):
         idp = self.idps_client.create_identity_provider(
             idp_id, **idp_ref)['identity_provider']
+        if not idp_ref.get('domain_id'):
+            self.addCleanup(
+                self.keystone_manager.domains_client.delete_domain,
+                idp['domain_id'])
+            self.addCleanup(
+                self.keystone_manager.domains_client.update_domain,
+                idp['domain_id'], enabled=False)
         self.addCleanup(
             self.idps_client.delete_identity_provider, idp_id)
         return idp
diff --git a/keystone_tempest_plugin/tests/scenario/test_federated_authentication.py b/keystone_tempest_plugin/tests/scenario/test_federated_authentication.py
index 24d7416..7814c0a 100644
--- a/keystone_tempest_plugin/tests/scenario/test_federated_authentication.py
+++ b/keystone_tempest_plugin/tests/scenario/test_federated_authentication.py
@@ -50,9 +50,15 @@
 
     def _setup_idp(self):
         remote_ids = CONF.fed_scenario.idp_remote_ids
-        self.idps_client.create_identity_provider(
+        idp = self.idps_client.create_identity_provider(
             self.idp_id, remote_ids=remote_ids, enabled=True)
         self.addCleanup(
+            self.keystone_manager.domains_client.delete_domain,
+            idp['identity_provider']['domain_id'])
+        self.addCleanup(
+            self.keystone_manager.domains_client.update_domain,
+            idp['identity_provider']['domain_id'], enabled=False)
+        self.addCleanup(
             self.idps_client.delete_identity_provider, self.idp_id)
 
     def _setup_mapping(self):