X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/ed16f0c1f600acd7bab81796ec22fde90ecdfa7f..d0379cea8627ec6a2f507def8b5587bbd6edd72b:/services/fuse/tests/test_token_expiry.py diff --git a/services/fuse/tests/test_token_expiry.py b/services/fuse/tests/test_token_expiry.py index 1b1be18448..9756b2efe3 100644 --- a/services/fuse/tests/test_token_expiry.py +++ b/services/fuse/tests/test_token_expiry.py @@ -1,3 +1,7 @@ +# Copyright (C) The Arvados Authors. All rights reserved. +# +# SPDX-License-Identifier: AGPL-3.0 + import apiclient import arvados import arvados_fuse @@ -15,8 +19,8 @@ from .integration_test import IntegrationTest logger = logging.getLogger('arvados.arv-mount') class TokenExpiryTest(IntegrationTest): - def __init__(self, *args, **kwargs): - super(TokenExpiryTest, self).__init__(*args, **kwargs) + def setUp(self): + super(TokenExpiryTest, self).setUp() self.test_start_time = time.time() self.time_now = int(time.time())+1 @@ -35,6 +39,11 @@ class TokenExpiryTest(IntegrationTest): @mock.patch('arvados.keep.KeepClient.get') @IntegrationTest.mount(argv=['--mount-by-id', 'zzz']) def test_refresh_old_manifest(self, mocked_get, mocked_time, mocked_open): + # This test (and associated behavior) is still not strong + # enough. We should ensure old tokens are never used even if + # blobSignatureTtl seconds elapse between open() and + # read(). See https://dev.arvados.org/issues/10008 + mocked_get.return_value = 'fake data' mocked_time.side_effect = self.fake_time mocked_open.side_effect = self.fake_open @@ -44,10 +53,13 @@ class TokenExpiryTest(IntegrationTest): with mock.patch.object(self.mount.api.collections(), 'get', wraps=self.mount.api.collections().get) as mocked_get: self.pool_test(os.path.join(self.mnt, 'zzz')) - self.assertEqual(3, mocked_open.call_count) - self.assertEqual( - 4, mocked_get.call_count, - 'Not enough calls to collections().get(): expected 4, got {!r}'.format( + # open() several times here to make sure we don't reach our + # quota of mocked_get.call_count dishonestly (e.g., the first + # open causes 5 mocked_get, and the rest cause none). + self.assertEqual(8, mocked_open.call_count) + self.assertGreaterEqual( + mocked_get.call_count, 8, + 'Not enough calls to collections().get(): expected 8, got {!r}'.format( mocked_get.mock_calls)) @staticmethod @@ -55,6 +67,6 @@ class TokenExpiryTest(IntegrationTest): uuid = 'zzzzz-4zz18-op4e2lbej01tcvu' fnm = 'zzzzz-8i9sb-0vsrcqi7whchuil.log.txt' os.listdir(os.path.join(zzz, uuid)) - for _ in range(3): + for _ in range(8): with open(os.path.join(zzz, uuid, fnm)) as f: f.read()