From 58fe2f256fccc14f5078e9fde9b9f7b2219a06e5 Mon Sep 17 00:00:00 2001 From: anc Date: Tue, 8 Apr 2014 18:44:06 +0100 Subject: [PATCH] Add tests and comments re constraints in /info Add test to check that only the expected keys are reported by proxy in /info, and add comments to raise awareness that default constraints will be automatically published by proxy in response to /info requests. Change-Id: Ia5f6339b06cdc2e1dc960d1f75562a2505530202 --- etc/swift.conf-sample | 3 ++- swift/common/constraints.py | 4 ++++ test/unit/proxy/test_server.py | 4 ++++ 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/etc/swift.conf-sample b/etc/swift.conf-sample index 50c0463bd8..8bb8c4ae5e 100644 --- a/etc/swift.conf-sample +++ b/etc/swift.conf-sample @@ -10,7 +10,8 @@ swift_hash_path_prefix = changeme # The swift-constraints section sets the basic constraints on data -# saved in the swift cluster. +# saved in the swift cluster. These constraints are automatically +# published by the proxy server in responses to /info requests. [swift-constraints] diff --git a/swift/common/constraints.py b/swift/common/constraints.py index 84545fce92..d3cbea0863 100644 --- a/swift/common/constraints.py +++ b/swift/common/constraints.py @@ -34,6 +34,10 @@ ACCOUNT_LISTING_LIMIT = 10000 MAX_ACCOUNT_NAME_LENGTH = 256 MAX_CONTAINER_NAME_LENGTH = 256 +# If adding an entry to DEFAULT_CONSTRAINTS, note that +# these constraints are automatically published by the +# proxy server in responses to /info requests, with values +# updated by reload_constraints() DEFAULT_CONSTRAINTS = { 'max_file_size': MAX_FILE_SIZE, 'max_meta_name_length': MAX_META_NAME_LENGTH, diff --git a/test/unit/proxy/test_server.py b/test/unit/proxy/test_server.py index abd49599a0..3925910612 100644 --- a/test/unit/proxy/test_server.py +++ b/test/unit/proxy/test_server.py @@ -5915,6 +5915,10 @@ class TestSwiftInfo(unittest.TestCase): constraints.MAX_CONTAINER_NAME_LENGTH) self.assertEqual(si['max_object_name_length'], constraints.MAX_OBJECT_NAME_LENGTH) + self.assertTrue('strict_cors_mode' in si) + # this next test is deliberately brittle in order to alert if + # other items are added to swift info + self.assertEqual(len(si), 13) if __name__ == '__main__':