diff --git a/spec/marten/conf/global_settings/assets_spec.cr b/spec/marten/conf/global_settings/assets_spec.cr index f8fda28b4..8db2f9774 100644 --- a/spec/marten/conf/global_settings/assets_spec.cr +++ b/spec/marten/conf/global_settings/assets_spec.cr @@ -20,6 +20,25 @@ describe Marten::Conf::GlobalSettings::Assets do end end + describe "#app_dirs?" do + it "returns true by default" do + assets_conf = Marten::Conf::GlobalSettings::Assets.new + assets_conf.app_dirs?.should be_true + end + + it "returns true if configured accordingly" do + assets_conf = Marten::Conf::GlobalSettings::Assets.new + assets_conf.app_dirs = true + assets_conf.app_dirs?.should be_true + end + + it "returns false if configured accordingly" do + assets_conf = Marten::Conf::GlobalSettings::Assets.new + assets_conf.app_dirs = false + assets_conf.app_dirs?.should be_false + end + end + describe "#app_dirs=" do it "allows to change the app_dirs confiuration as expected" do assets_conf = Marten::Conf::GlobalSettings::Assets.new diff --git a/spec/marten/conf/global_settings/csrf_spec.cr b/spec/marten/conf/global_settings/csrf_spec.cr index a1980187a..ad33b7944 100644 --- a/spec/marten/conf/global_settings/csrf_spec.cr +++ b/spec/marten/conf/global_settings/csrf_spec.cr @@ -35,6 +35,19 @@ describe Marten::Conf::GlobalSettings::CSRF do end end + describe "#cookie_http_only?" do + it "returns false by default" do + csrf_conf = Marten::Conf::GlobalSettings::CSRF.new + csrf_conf.cookie_http_only?.should be_false + end + + it "returns the configured value if applicable" do + csrf_conf = Marten::Conf::GlobalSettings::CSRF.new + csrf_conf.cookie_http_only = true + csrf_conf.cookie_http_only?.should be_true + end + end + describe "#cookie_http_only=" do it "allows to configure that client-side JS scripts should not have access to the CSRF cookie" do csrf_conf = Marten::Conf::GlobalSettings::CSRF.new @@ -125,6 +138,19 @@ describe Marten::Conf::GlobalSettings::CSRF do end end + describe "#cookie_secure?" do + it "returns false by default" do + csrf_conf = Marten::Conf::GlobalSettings::CSRF.new + csrf_conf.cookie_secure?.should be_false + end + + it "returns the configured value if applicable" do + csrf_conf = Marten::Conf::GlobalSettings::CSRF.new + csrf_conf.cookie_secure = true + csrf_conf.cookie_secure?.should be_true + end + end + describe "#cookie_secure=" do it "allows to configure whether a secure cookie should be used" do csrf_conf = Marten::Conf::GlobalSettings::CSRF.new @@ -146,6 +172,19 @@ describe Marten::Conf::GlobalSettings::CSRF do end end + describe "#protection_enabled?" do + it "returns true by default" do + csrf_conf = Marten::Conf::GlobalSettings::CSRF.new + csrf_conf.protection_enabled?.should be_true + end + + it "returns the configured value if applicable" do + csrf_conf = Marten::Conf::GlobalSettings::CSRF.new + csrf_conf.protection_enabled = false + csrf_conf.protection_enabled?.should be_false + end + end + describe "#protection_enabled=" do it "allows to disable the CSRF protection" do csrf_conf = Marten::Conf::GlobalSettings::CSRF.new @@ -215,6 +254,19 @@ describe Marten::Conf::GlobalSettings::CSRF do end end + describe "#use_session?" do + it "returns false by default" do + csrf_conf = Marten::Conf::GlobalSettings::CSRF.new + csrf_conf.use_session?.should be_false + end + + it "returns the configured value if applicable" do + csrf_conf = Marten::Conf::GlobalSettings::CSRF.new + csrf_conf.use_session = true + csrf_conf.use_session?.should be_true + end + end + describe "#use_session=" do it "allows to store the CSRF token inside a session" do csrf_conf = Marten::Conf::GlobalSettings::CSRF.new diff --git a/spec/marten/conf/global_settings/sessions_spec.cr b/spec/marten/conf/global_settings/sessions_spec.cr index 361091d57..5a2321a4e 100644 --- a/spec/marten/conf/global_settings/sessions_spec.cr +++ b/spec/marten/conf/global_settings/sessions_spec.cr @@ -35,6 +35,19 @@ describe Marten::Conf::GlobalSettings::Sessions do end end + describe "#cookie_http_only?" do + it "returns false by default" do + sessions_conf = Marten::Conf::GlobalSettings::Sessions.new + sessions_conf.cookie_http_only?.should be_false + end + + it "returns the configured value if applicable" do + sessions_conf = Marten::Conf::GlobalSettings::Sessions.new + sessions_conf.cookie_http_only = true + sessions_conf.cookie_http_only?.should be_true + end + end + describe "#cookie_http_only=" do it "allows to configure that client-side JS scripts should not have access to the session cookie" do sessions_conf = Marten::Conf::GlobalSettings::Sessions.new @@ -125,6 +138,19 @@ describe Marten::Conf::GlobalSettings::Sessions do end end + describe "#cookie_secure?" do + it "returns false by default" do + sessions_conf = Marten::Conf::GlobalSettings::Sessions.new + sessions_conf.cookie_secure?.should be_false + end + + it "returns the configured value if applicable" do + sessions_conf = Marten::Conf::GlobalSettings::Sessions.new + sessions_conf.cookie_secure = true + sessions_conf.cookie_secure?.should be_true + end + end + describe "#cookie_secure=" do it "allows to configure whether a secure cookie should be used" do sessions_conf = Marten::Conf::GlobalSettings::Sessions.new diff --git a/spec/marten/conf/global_settings/strict_transport_security_spec.cr b/spec/marten/conf/global_settings/strict_transport_security_spec.cr index e8e295163..6159e6704 100644 --- a/spec/marten/conf/global_settings/strict_transport_security_spec.cr +++ b/spec/marten/conf/global_settings/strict_transport_security_spec.cr @@ -14,6 +14,19 @@ describe Marten::Conf::GlobalSettings::StrictTransportSecurity do end end + describe "#include_sub_domains?" do + it "returns false by default" do + sts_config = Marten::Conf::GlobalSettings::StrictTransportSecurity.new + sts_config.include_sub_domains?.should be_false + end + + it "returns the customized value if applicable" do + sts_config = Marten::Conf::GlobalSettings::StrictTransportSecurity.new + sts_config.include_sub_domains = true + sts_config.include_sub_domains?.should be_true + end + end + describe "#include_sub_domains=" do it "allows to specify a custom setting value as expected" do sts_config = Marten::Conf::GlobalSettings::StrictTransportSecurity.new @@ -56,6 +69,19 @@ describe Marten::Conf::GlobalSettings::StrictTransportSecurity do end end + describe "#preload?" do + it "returns false by default" do + sts_config = Marten::Conf::GlobalSettings::StrictTransportSecurity.new + sts_config.preload?.should be_false + end + + it "returns the customized value if applicable" do + sts_config = Marten::Conf::GlobalSettings::StrictTransportSecurity.new + sts_config.preload = true + sts_config.preload?.should be_true + end + end + describe "#preload=" do it "allows to specify a custom setting value as expected" do sts_config = Marten::Conf::GlobalSettings::StrictTransportSecurity.new diff --git a/spec/marten/conf/global_settings/templates_spec.cr b/spec/marten/conf/global_settings/templates_spec.cr index 398f5f098..cc9944d1b 100644 --- a/spec/marten/conf/global_settings/templates_spec.cr +++ b/spec/marten/conf/global_settings/templates_spec.cr @@ -20,6 +20,25 @@ describe Marten::Conf::GlobalSettings::Templates do end end + describe "#app_dirs?" do + it "returns true by default" do + templates_conf = Marten::Conf::GlobalSettings::Templates.new + templates_conf.app_dirs?.should be_true + end + + it "returns true if configured accordingly" do + templates_conf = Marten::Conf::GlobalSettings::Templates.new + templates_conf.app_dirs = true + templates_conf.app_dirs?.should be_true + end + + it "returns false if configured accordingly" do + templates_conf = Marten::Conf::GlobalSettings::Templates.new + templates_conf.app_dirs = false + templates_conf.app_dirs?.should be_false + end + end + describe "#app_dirs=" do it "allows to change the app_dirs confiuration as expected" do templates_conf = Marten::Conf::GlobalSettings::Templates.new @@ -51,6 +70,25 @@ describe Marten::Conf::GlobalSettings::Templates do end end + describe "#cached?" do + it "returns false by default" do + templates_conf = Marten::Conf::GlobalSettings::Templates.new + templates_conf.cached?.should be_false + end + + it "returns true if configured accordingly" do + templates_conf = Marten::Conf::GlobalSettings::Templates.new + templates_conf.cached = true + templates_conf.cached?.should be_true + end + + it "returns false if configured accordingly" do + templates_conf = Marten::Conf::GlobalSettings::Templates.new + templates_conf.cached = false + templates_conf.cached?.should be_false + end + end + describe "#cached=" do it "allows to change the cached configuration as expected" do templates_conf = Marten::Conf::GlobalSettings::Templates.new diff --git a/spec/marten/conf/global_settings_spec.cr b/spec/marten/conf/global_settings_spec.cr index 1ccda94ef..e3450919a 100644 --- a/spec/marten/conf/global_settings_spec.cr +++ b/spec/marten/conf/global_settings_spec.cr @@ -385,6 +385,19 @@ describe Marten::Conf::GlobalSettings do end end + describe "#port_reuse?" do + it "returns true by default" do + global_settings = Marten::Conf::GlobalSettings.new + global_settings.port_reuse?.should be_true + end + + it "returns the specific port reuse configuration if explicitely set" do + global_settings = Marten::Conf::GlobalSettings.new + global_settings.port_reuse = false + global_settings.port_reuse?.should be_false + end + end + describe "#port_reuse=" do it "allows to configure whether the port_reuse boolean configuration option" do global_settings = Marten::Conf::GlobalSettings.new @@ -601,6 +614,19 @@ describe Marten::Conf::GlobalSettings do end end + describe "#use_x_forwarded_host?" do + it "returns false by default" do + global_settings = Marten::Conf::GlobalSettings.new + global_settings.use_x_forwarded_host?.should be_false + end + + it "returns the configured boolean value if explicitely set" do + global_settings = Marten::Conf::GlobalSettings.new + global_settings.use_x_forwarded_host = true + global_settings.use_x_forwarded_host?.should be_true + end + end + describe "#use_x_forwarded_host=" do it "allows to configure whether the X-Forwarded-Host header should be used" do global_settings = Marten::Conf::GlobalSettings.new @@ -622,6 +648,19 @@ describe Marten::Conf::GlobalSettings do end end + describe "#use_x_forwarded_port?" do + it "returns false by default" do + global_settings = Marten::Conf::GlobalSettings.new + global_settings.use_x_forwarded_port?.should be_false + end + + it "returns the configured boolean value if explicitely set" do + global_settings = Marten::Conf::GlobalSettings.new + global_settings.use_x_forwarded_port = true + global_settings.use_x_forwarded_port?.should be_true + end + end + describe "#use_x_forwarded_port=" do it "allows to configure whether the X-Forwarded-Port header should be used" do global_settings = Marten::Conf::GlobalSettings.new @@ -643,6 +682,19 @@ describe Marten::Conf::GlobalSettings do end end + describe "#use_x_forwarded_proto?" do + it "returns false by default" do + global_settings = Marten::Conf::GlobalSettings.new + global_settings.use_x_forwarded_proto?.should be_false + end + + it "returns the configured boolean value if explicitely set" do + global_settings = Marten::Conf::GlobalSettings.new + global_settings.use_x_forwarded_proto = true + global_settings.use_x_forwarded_proto?.should be_true + end + end + describe "#use_x_forwarded_proto=" do it "allows to configure whether the X-Forwarded-Proto header should be used" do global_settings = Marten::Conf::GlobalSettings.new diff --git a/src/marten/conf/global_settings.cr b/src/marten/conf/global_settings.cr index d50f3a467..a556b183c 100644 --- a/src/marten/conf/global_settings.cr +++ b/src/marten/conf/global_settings.cr @@ -60,6 +60,9 @@ module Marten # Returns a boolean indicating whether multiple processes can bind to the same HTTP server port. getter port_reuse + # :ditto: + getter? port_reuse + # Returns the default value to use for the Referrer-Policy header. # # The value of this setting will be used by the `Marten::Middleware::ReferrerPolicy` middleware when inserting the @@ -84,12 +87,21 @@ module Marten # Returns a boolean indicating whether the X-Forwarded-Host header is used to look for the host. getter use_x_forwarded_host + # :ditto: + getter? use_x_forwarded_host + # Returns a boolean indicating if the X-Forwarded-Port header is used to determine the port of a request. getter use_x_forwarded_port + # :ditto: + getter? use_x_forwarded_port + # Returns a boolean indicating if the X-Forwarded-Proto header is used to determine whether a request is secure. getter use_x_forwarded_proto + # :ditto: + getter? use_x_forwarded_proto + # Returns the value to use for the X-Frame-Options header when the associated middleware is used. # # The value of this setting will be used by the `Marten::Middleware::XFrameOptions` middleware when inserting the diff --git a/src/marten/conf/global_settings/assets.cr b/src/marten/conf/global_settings/assets.cr index bea166859..82acb605d 100644 --- a/src/marten/conf/global_settings/assets.cr +++ b/src/marten/conf/global_settings/assets.cr @@ -14,6 +14,9 @@ module Marten # Returns a boolean indicating whether assets should be looked for inside installed applications. getter app_dirs + # :ditto: + getter? app_dirs + # Returns an array of directories where assets should be looked for. # # The order of these directories is important as it defines the order in which assets are searched for. diff --git a/src/marten/conf/global_settings/csrf.cr b/src/marten/conf/global_settings/csrf.cr index b6c3b1721..32c5b6d6e 100644 --- a/src/marten/conf/global_settings/csrf.cr +++ b/src/marten/conf/global_settings/csrf.cr @@ -23,6 +23,9 @@ module Marten # Returns a boolean indicating whether client-side scripts should have access to the CSRF token cookie. getter cookie_http_only + # :ditto: + getter? cookie_http_only + # Returns the max age (in seconds) of the CSRF cookie. # # By default, CSRF cookie max age is set to `31556952` (approximatively one year). @@ -37,12 +40,21 @@ module Marten # Returns a boolean indicating whether to use a secure cookie for the CSRF cookie. getter cookie_secure + # :ditto: + getter? cookie_secure + # Returns a boolean indicating if CSRF protection is enabled globally (defaults to `true`). getter protection_enabled + # :ditto: + getter? protection_enabled + # Returns a boolean indicating if the CSRF token is stored inside the session. getter use_session + # :ditto: + getter? use_session + # Returns the array of CSRF-trusted origins. getter trusted_origins diff --git a/src/marten/conf/global_settings/sessions.cr b/src/marten/conf/global_settings/sessions.cr index 8e6579367..8a8545d4c 100644 --- a/src/marten/conf/global_settings/sessions.cr +++ b/src/marten/conf/global_settings/sessions.cr @@ -17,6 +17,9 @@ module Marten # Returns a boolean indicating whether client-side scripts should have access to the session cookie. getter cookie_http_only + # :ditto: + getter? cookie_http_only + # Returns the max age (in seconds) of the session cookie. # # By default, the session cookie max age is set to `1209600` (two weeks). @@ -31,6 +34,9 @@ module Marten # Returns a boolean indicating whether to use a secure cookie for the session cookie. getter cookie_secure + # :ditto: + getter? cookie_secure + # Returns the identifier of the store that should be used to handle sessions. getter store diff --git a/src/marten/conf/global_settings/strict_stransport_security.cr b/src/marten/conf/global_settings/strict_stransport_security.cr index 9a5b01797..40d0ae719 100644 --- a/src/marten/conf/global_settings/strict_stransport_security.cr +++ b/src/marten/conf/global_settings/strict_stransport_security.cr @@ -10,6 +10,9 @@ module Marten # Indicates if the `includeSubDomains` directive should be set on the Strict-Transport-Security header. getter include_sub_domains + # :ditto: + getter? include_sub_domains + # Returns the max age to use for the Strict-Transport-Security header. # # A `nil` value indicates that the Strict-Transport-Security header will not be set. @@ -18,6 +21,9 @@ module Marten # Indicates if the `preload` directive should be set on the Strict-Transport-Security header. getter preload + # :ditto: + getter? preload + # Allows to define if the `includeSubDomains` directive should be set on the Strict-Transport-Security header. setter include_sub_domains diff --git a/src/marten/conf/global_settings/templates.cr b/src/marten/conf/global_settings/templates.cr index b95aacdfe..bd5ed43f9 100644 --- a/src/marten/conf/global_settings/templates.cr +++ b/src/marten/conf/global_settings/templates.cr @@ -14,9 +14,15 @@ module Marten # Returns a boolean indicating whether templates should be looked for inside installed applications. getter app_dirs + # :ditto: + getter? app_dirs + # Returns a boolean indicating whether templates should be kept in a memory cache upon being loaded and parsed. getter cached + # :ditto: + getter? cached + # Returns an array of context producers that will be used to populate the context for each template. getter context_producers @@ -28,12 +34,12 @@ module Marten # Returns a boolean indicating whether included templates should be isolated from the outer context by default. getter isolated_inclusions - # Returns the list of template loaders or nil - getter loaders - # :ditto: getter? isolated_inclusions + # Returns the list of template loaders or nil + getter loaders + # Returns `true` if the strict variables mode is enabled. getter strict_variables