"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "keystone/tests/unit/test_backend_sql.py" between
keystone-18.0.0.tar.gz and keystone-19.0.0.tar.gz

About: OpenStack Keystone (Core Service: Identity) provides an authentication and authorization service for other OpenStack services. Provides a catalog of endpoints for all OpenStack services.
The "Wallaby" series (latest release).

test_backend_sql.py  (keystone-18.0.0):test_backend_sql.py  (keystone-19.0.0)
skipping to change at line 19 skipping to change at line 19
# Unless required by applicable law or agreed to in writing, software # Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations # License for the specific language governing permissions and limitations
# under the License. # under the License.
import datetime import datetime
from unittest import mock from unittest import mock
import uuid import uuid
import fixtures
import freezegun import freezegun
from oslo_db import exception as db_exception from oslo_db import exception as db_exception
from oslo_db import options from oslo_db import options
from oslo_log import log
import sqlalchemy import sqlalchemy
from sqlalchemy import exc from sqlalchemy import exc
from testtools import matchers from testtools import matchers
from keystone.common import driver_hints from keystone.common import driver_hints
from keystone.common import provider_api from keystone.common import provider_api
from keystone.common import sql from keystone.common import sql
from keystone.common.sql import core from keystone.common.sql import core
import keystone.conf import keystone.conf
from keystone.credential.providers import fernet as credential_provider from keystone.credential.providers import fernet as credential_provider
skipping to change at line 981 skipping to change at line 983
self.assertIsNone(resp) self.assertIsNone(resp)
resp = PROVIDERS.resource_api.check_project_depth(max_depth=3) resp = PROVIDERS.resource_api.check_project_depth(max_depth=3)
self.assertIsNone(resp) self.assertIsNone(resp)
resp = PROVIDERS.resource_api.check_project_depth(max_depth=4) resp = PROVIDERS.resource_api.check_project_depth(max_depth=4)
self.assertIsNone(resp) self.assertIsNone(resp)
# if max_depth < current project depth, raise LimitTreeExceedError # if max_depth < current project depth, raise LimitTreeExceedError
self.assertRaises(exception.LimitTreeExceedError, self.assertRaises(exception.LimitTreeExceedError,
PROVIDERS.resource_api.check_project_depth, PROVIDERS.resource_api.check_project_depth,
2) 2)
def test_update_user_with_stale_data_forces_retry(self):
# Capture log output so we know oslo.db attempted a retry
log_fixture = self.useFixture(fixtures.FakeLogger(level=log.DEBUG))
# Create a new user
user_dict = unit.new_user_ref(
domain_id=CONF.identity.default_domain_id)
new_user_dict = PROVIDERS.identity_api.create_user(user_dict)
side_effects = [
# Raise a StaleDataError simulating that another client has
# updated the user's password while this client's request was
# being processed
sqlalchemy.orm.exc.StaleDataError,
# The oslo.db library will retry the request, so the second
# time this method is called let's return a valid session
# object
sql.session_for_write()
]
with mock.patch('keystone.common.sql.session_for_write') as m:
m.side_effect = side_effects
# Update a user's attribute, the first attempt will fail but
# oslo.db will handle the exception and retry, the second attempt
# will succeed
new_user_dict['email'] = uuid.uuid4().hex
PROVIDERS.identity_api.update_user(
new_user_dict['id'], new_user_dict)
# Make sure oslo.db retried the update by checking the log output
expected_log_message = (
'Performing DB retry for function keystone.identity.backends.'
'sql.Identity.update_user'
)
self.assertIn(expected_log_message, log_fixture.output)
class SqlTrust(SqlTests, trust_tests.TrustTests): class SqlTrust(SqlTests, trust_tests.TrustTests):
def test_trust_expires_at_int_matches_expires_at(self): def test_trust_expires_at_int_matches_expires_at(self):
with sql.session_for_write() as session: with sql.session_for_write() as session:
new_id = uuid.uuid4().hex new_id = uuid.uuid4().hex
self.create_sample_trust(new_id) self.create_sample_trust(new_id)
trust_ref = session.query(trust_sql.TrustModel).get(new_id) trust_ref = session.query(trust_sql.TrustModel).get(new_id)
self.assertIsNotNone(trust_ref._expires_at) self.assertIsNotNone(trust_ref._expires_at)
self.assertEqual(trust_ref._expires_at, trust_ref.expires_at_int) self.assertEqual(trust_ref._expires_at, trust_ref.expires_at_int)
self.assertEqual(trust_ref.expires_at, trust_ref.expires_at_int) self.assertEqual(trust_ref.expires_at, trust_ref.expires_at_int)
 End of changes. 3 change blocks. 
0 lines changed or deleted 38 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)