예제 #1
0
 def test_check_conflicts_4(self):
     with pytest.raises(AssertionError) as e:
         config._set_option("global.sharingMode", "s3", "test")
         config._set_option("s3.bucket", "some.bucket", "test")
         config._set_option("s3.accessKeyId", "some.key", "test")
         config._set_option("s3.secretAccessKey", None, "<default>")
         config._check_conflicts()
     self.assertEqual(
         str(e.value),
         "In config.toml, s3.accessKeyId and s3.secretAccessKey must either both be set or both be unset.",
     )
예제 #2
0
    def test_check_conflicts_s3_absolute_url(self):
        """Test that non-absolute s3.url values get made absolute"""
        config._set_option("global.sharingMode", "s3", "test")
        config._set_option("s3.bucket", "some.bucket", "test")
        config._set_option("s3.accessKeyId", "some.key", "test")
        config._set_option("s3.secretAccessKey", "some.key", "test")

        # This absolute URL should *not* be modified in check_conflicts:
        absolute_url = "https://absolute.url"
        config._set_option("s3.url", absolute_url, "test")
        config._check_conflicts()
        self.assertEqual(absolute_url, config.get_option("s3.url"))

        # This non-absolute URL *should* be modified with a '//' prefix:
        relative_url = "relative.url"
        config._set_option("s3.url", relative_url, "test")
        config._check_conflicts()
        self.assertEqual("//" + relative_url, config.get_option("s3.url"))
예제 #3
0
 def test_check_conflicts_server_csrf(self, get_logger):
     config._set_option("server.enableXsrfProtection", True, "test")
     config._set_option("server.enableCORS", True, "test")
     mock_logger = get_logger()
     config._check_conflicts()
     mock_logger.warning.assert_called_once()
예제 #4
0
 def test_check_conflicts_server_csrf(self):
     config._set_option("server.enableCSRFProtection", True, "test")
     config._set_option("server.enableCORS", True, "test")
     with patch("streamlit.config.LOGGER") as patched_logger:
         config._check_conflicts()
         patched_logger.warning.assert_called_once()
예제 #5
0
 def test_check_conflicts_5(self):
     with pytest.raises(AssertionError) as e:
         config._set_option('global.sharingMode', 'streamlit-public', 'test')
         config._set_option('s3.profile', 'some.profile', 'test')
         config._check_conflicts()
     self.assertEqual(str(e.value), 'In config.toml, S3 should not be configured when global.sharingMode is set to "streamlit-public".')
예제 #6
0
 def test_check_conflicts_3(self):
     with pytest.raises(AssertionError) as e:
         config._set_option('global.sharingMode', 's3', 'test')
         config._set_option('s3.bucket', None, '<default>')
         config._check_conflicts()
     self.assertEqual(str(e.value), 'When global.sharingMode is set to "s3", s3.bucket must also be set')