Deploying to gh-pages from @ 697c6124c1f1fe7b4d7679bee1eb67532abbdb1f 🚀

This commit is contained in:
realaravinth
2023-10-18 12:23:23 +00:00
parent 2b74f089ac
commit 37473c0e1e
9 changed files with 329 additions and 8 deletions

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1 @@
<!DOCTYPE html><html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><meta name="generator" content="rustdoc"><meta name="description" content="API documentation for the Rust `DEPRECATED_ENV_VARS` constant in crate `mcaptcha`."><title>DEPRECATED_ENV_VARS in mcaptcha::settings - Rust</title><link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/SourceSerif4-Regular-46f98efaafac5295.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/FiraSans-Regular-018c141bf0843ffd.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/FiraSans-Medium-8f9a781e4970d388.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/SourceCodePro-Regular-562dcc5011b6de7d.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/SourceSerif4-Bold-a2c9cd1067f8b328.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/SourceCodePro-Semibold-d899c5a5c4aeb14a.ttf.woff2"><link rel="stylesheet" href="../../static.files/normalize-76eba96aa4d2e634.css"><link rel="stylesheet" href="../../static.files/rustdoc-cb6f1f67f1bcd037.css" id="mainThemeStyle"><meta name="rustdoc-vars" data-root-path="../../" data-static-root-path="../../static.files/" data-current-crate="mcaptcha" data-themes="" data-resource-suffix="" data-rustdoc-version="1.73.0 (cc66ad468 2023-10-03)" data-channel="1.73.0" data-search-js="search-6dfdfced5eff6596.js" data-settings-js="settings-de11bff964e9d4e5.js" data-settings-css="settings-8c76f75bfb6bd192.css" data-theme-light-css="light-1596385f77d47ef2.css" data-theme-dark-css="dark-0a43001d3fc2282c.css" data-theme-ayu-css="ayu-fd19013d6ce078bf.css" ><script src="../../static.files/storage-db41da1a38ea3cb8.js"></script><script defer src="sidebar-items.js"></script><script defer src="../../static.files/main-0795b7d26be81095.js"></script><noscript><link rel="stylesheet" media="(prefers-color-scheme:light)" href="../../static.files/light-1596385f77d47ef2.css"><link rel="stylesheet" media="(prefers-color-scheme:dark)" href="../../static.files/dark-0a43001d3fc2282c.css"><link rel="stylesheet" href="../../static.files/noscript-cffde32267a19fd6.css"></noscript><link rel="alternate icon" type="image/png" href="../../static.files/favicon-16x16-8b506e7a72182f1c.png"><link rel="alternate icon" type="image/png" href="../../static.files/favicon-32x32-422f7d1d52889060.png"><link rel="icon" type="image/svg+xml" href="../../static.files/favicon-2c020d218678b618.svg"></head><body class="rustdoc constant"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="mobile-topbar"><button class="sidebar-menu-toggle">&#9776;</button><a class="logo-container" href="../../mcaptcha/index.html"><img class="rust-logo" src="../../static.files/rust-logo-151179464ae7ed46.svg" alt="logo"></a><h2></h2></nav><nav class="sidebar"><a class="logo-container" href="../../mcaptcha/index.html"><img class="rust-logo" src="../../static.files/rust-logo-151179464ae7ed46.svg" alt="logo"></a><div class="sidebar-elems"><h2><a href="index.html">In mcaptcha::settings</a></h2></div></nav><main><div class="width-limiter"><nav class="sub"><form class="search-form"><span></span><input class="search-input" name="search" aria-label="Run search in the documentation" autocomplete="off" spellcheck="false" placeholder="Click or press S to search, ? for more options…" type="search"><div id="help-button" title="help" tabindex="-1"><a href="../../help.html">?</a></div><div id="settings-menu" tabindex="-1"><a href="../../settings.html" title="settings"><img width="22" height="22" alt="Change settings" src="../../static.files/wheel-7b819b6101059cd0.svg"></a></div></form></nav><section id="main-content" class="content"><div class="main-heading"><h1>Constant <a href="../index.html">mcaptcha</a>::<wbr><a href="index.html">settings</a>::<wbr><a class="constant" href="#">DEPRECATED_ENV_VARS</a><button id="copy-path" title="Copy item path to clipboard"><img src="../../static.files/clipboard-7571035ce49a181d.svg" width="19" height="18" alt="Copy item path"></button></h1><span class="out-of-band"><a class="src" href="../../src/mcaptcha/settings.rs.html#160-184">source</a> · <button id="toggle-all-docs" title="collapse all docs">[<span>&#x2212;</span>]</button></span></div><pre class="rust item-decl"><code>const DEPRECATED_ENV_VARS: [(&amp;<a class="primitive" href="https://doc.rust-lang.org/1.73.0/std/primitive.str.html">str</a>, &amp;<a class="primitive" href="https://doc.rust-lang.org/1.73.0/std/primitive.str.html">str</a>); <a class="primitive" href="https://doc.rust-lang.org/1.73.0/std/primitive.array.html">23</a>];</code></pre></section></div></main></body></html>

File diff suppressed because one or more lines are too long

View File

@@ -1 +1 @@
window.SIDEBAR_ITEMS = {"constant":["ENV_VAR_CONFIG"],"enum":["DBType"],"struct":["Captcha","Database","DefaultDifficultyStrategy","Redis","Server","Settings","Smtp"]}; window.SIDEBAR_ITEMS = {"constant":["DEPRECATED_ENV_VARS","ENV_VAR_CONFIG"],"enum":["DBType"],"struct":["Captcha","Database","DefaultDifficultyStrategy","Redis","Server","Settings","Smtp"]};

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@@ -404,6 +404,166 @@
<a href="#404" id="404">404</a> <a href="#404" id="404">404</a>
<a href="#405" id="405">405</a> <a href="#405" id="405">405</a>
<a href="#406" id="406">406</a> <a href="#406" id="406">406</a>
<a href="#407" id="407">407</a>
<a href="#408" id="408">408</a>
<a href="#409" id="409">409</a>
<a href="#410" id="410">410</a>
<a href="#411" id="411">411</a>
<a href="#412" id="412">412</a>
<a href="#413" id="413">413</a>
<a href="#414" id="414">414</a>
<a href="#415" id="415">415</a>
<a href="#416" id="416">416</a>
<a href="#417" id="417">417</a>
<a href="#418" id="418">418</a>
<a href="#419" id="419">419</a>
<a href="#420" id="420">420</a>
<a href="#421" id="421">421</a>
<a href="#422" id="422">422</a>
<a href="#423" id="423">423</a>
<a href="#424" id="424">424</a>
<a href="#425" id="425">425</a>
<a href="#426" id="426">426</a>
<a href="#427" id="427">427</a>
<a href="#428" id="428">428</a>
<a href="#429" id="429">429</a>
<a href="#430" id="430">430</a>
<a href="#431" id="431">431</a>
<a href="#432" id="432">432</a>
<a href="#433" id="433">433</a>
<a href="#434" id="434">434</a>
<a href="#435" id="435">435</a>
<a href="#436" id="436">436</a>
<a href="#437" id="437">437</a>
<a href="#438" id="438">438</a>
<a href="#439" id="439">439</a>
<a href="#440" id="440">440</a>
<a href="#441" id="441">441</a>
<a href="#442" id="442">442</a>
<a href="#443" id="443">443</a>
<a href="#444" id="444">444</a>
<a href="#445" id="445">445</a>
<a href="#446" id="446">446</a>
<a href="#447" id="447">447</a>
<a href="#448" id="448">448</a>
<a href="#449" id="449">449</a>
<a href="#450" id="450">450</a>
<a href="#451" id="451">451</a>
<a href="#452" id="452">452</a>
<a href="#453" id="453">453</a>
<a href="#454" id="454">454</a>
<a href="#455" id="455">455</a>
<a href="#456" id="456">456</a>
<a href="#457" id="457">457</a>
<a href="#458" id="458">458</a>
<a href="#459" id="459">459</a>
<a href="#460" id="460">460</a>
<a href="#461" id="461">461</a>
<a href="#462" id="462">462</a>
<a href="#463" id="463">463</a>
<a href="#464" id="464">464</a>
<a href="#465" id="465">465</a>
<a href="#466" id="466">466</a>
<a href="#467" id="467">467</a>
<a href="#468" id="468">468</a>
<a href="#469" id="469">469</a>
<a href="#470" id="470">470</a>
<a href="#471" id="471">471</a>
<a href="#472" id="472">472</a>
<a href="#473" id="473">473</a>
<a href="#474" id="474">474</a>
<a href="#475" id="475">475</a>
<a href="#476" id="476">476</a>
<a href="#477" id="477">477</a>
<a href="#478" id="478">478</a>
<a href="#479" id="479">479</a>
<a href="#480" id="480">480</a>
<a href="#481" id="481">481</a>
<a href="#482" id="482">482</a>
<a href="#483" id="483">483</a>
<a href="#484" id="484">484</a>
<a href="#485" id="485">485</a>
<a href="#486" id="486">486</a>
<a href="#487" id="487">487</a>
<a href="#488" id="488">488</a>
<a href="#489" id="489">489</a>
<a href="#490" id="490">490</a>
<a href="#491" id="491">491</a>
<a href="#492" id="492">492</a>
<a href="#493" id="493">493</a>
<a href="#494" id="494">494</a>
<a href="#495" id="495">495</a>
<a href="#496" id="496">496</a>
<a href="#497" id="497">497</a>
<a href="#498" id="498">498</a>
<a href="#499" id="499">499</a>
<a href="#500" id="500">500</a>
<a href="#501" id="501">501</a>
<a href="#502" id="502">502</a>
<a href="#503" id="503">503</a>
<a href="#504" id="504">504</a>
<a href="#505" id="505">505</a>
<a href="#506" id="506">506</a>
<a href="#507" id="507">507</a>
<a href="#508" id="508">508</a>
<a href="#509" id="509">509</a>
<a href="#510" id="510">510</a>
<a href="#511" id="511">511</a>
<a href="#512" id="512">512</a>
<a href="#513" id="513">513</a>
<a href="#514" id="514">514</a>
<a href="#515" id="515">515</a>
<a href="#516" id="516">516</a>
<a href="#517" id="517">517</a>
<a href="#518" id="518">518</a>
<a href="#519" id="519">519</a>
<a href="#520" id="520">520</a>
<a href="#521" id="521">521</a>
<a href="#522" id="522">522</a>
<a href="#523" id="523">523</a>
<a href="#524" id="524">524</a>
<a href="#525" id="525">525</a>
<a href="#526" id="526">526</a>
<a href="#527" id="527">527</a>
<a href="#528" id="528">528</a>
<a href="#529" id="529">529</a>
<a href="#530" id="530">530</a>
<a href="#531" id="531">531</a>
<a href="#532" id="532">532</a>
<a href="#533" id="533">533</a>
<a href="#534" id="534">534</a>
<a href="#535" id="535">535</a>
<a href="#536" id="536">536</a>
<a href="#537" id="537">537</a>
<a href="#538" id="538">538</a>
<a href="#539" id="539">539</a>
<a href="#540" id="540">540</a>
<a href="#541" id="541">541</a>
<a href="#542" id="542">542</a>
<a href="#543" id="543">543</a>
<a href="#544" id="544">544</a>
<a href="#545" id="545">545</a>
<a href="#546" id="546">546</a>
<a href="#547" id="547">547</a>
<a href="#548" id="548">548</a>
<a href="#549" id="549">549</a>
<a href="#550" id="550">550</a>
<a href="#551" id="551">551</a>
<a href="#552" id="552">552</a>
<a href="#553" id="553">553</a>
<a href="#554" id="554">554</a>
<a href="#555" id="555">555</a>
<a href="#556" id="556">556</a>
<a href="#557" id="557">557</a>
<a href="#558" id="558">558</a>
<a href="#559" id="559">559</a>
<a href="#560" id="560">560</a>
<a href="#561" id="561">561</a>
<a href="#562" id="562">562</a>
<a href="#563" id="563">563</a>
<a href="#564" id="564">564</a>
<a href="#565" id="565">565</a>
<a href="#566" id="566">566</a>
</pre></div><pre class="rust"><code><span class="comment">// Copyright (C) 2022 Aravinth Manivannan &lt;realaravinth@batsense.net&gt; </pre></div><pre class="rust"><code><span class="comment">// Copyright (C) 2022 Aravinth Manivannan &lt;realaravinth@batsense.net&gt;
// SPDX-FileCopyrightText: 2023 Aravinth Manivannan &lt;realaravinth@batsense.net&gt; // SPDX-FileCopyrightText: 2023 Aravinth Manivannan &lt;realaravinth@batsense.net&gt;
// //
@@ -562,6 +722,33 @@
]; ];
<span class="kw">const </span>DEPRECATED_ENV_VARS: [(<span class="kw-2">&amp;</span>str, <span class="kw-2">&amp;</span>str); <span class="number">23</span>] = [
(<span class="string">&quot;debug&quot;</span>,<span class="string">&quot;MCAPTCHA_DEBUG&quot;</span>),
(<span class="string">&quot;commercial&quot;</span>,<span class="string">&quot;MCAPTCHA_COMMERCIAL&quot;</span>),
(<span class="string">&quot;source_code&quot;</span>, <span class="string">&quot;MCAPTCHA_SOURCE_CODE&quot;</span>),
(<span class="string">&quot;allow_registration&quot;</span>, <span class="string">&quot;MCAPTCHA_ALLOW_REGISTRATION&quot;</span>),
(<span class="string">&quot;allow_demo&quot;</span>, <span class="string">&quot;MCAPTCHA_ALLOW_DEMO&quot;</span>),
(<span class="string">&quot;redis.pool&quot;</span>, <span class="string">&quot;MCAPTCHA_REDIS_POOL&quot;</span>),
(<span class="string">&quot;redis.url&quot;</span>, <span class="string">&quot;MCAPTCHA_REDIS_URL&quot;</span>),
(<span class="string">&quot;server.port&quot;</span>, <span class="string">&quot;MCAPTCHA_SERVER_PORT&quot;</span>),
(<span class="string">&quot;server.ip&quot;</span>, <span class="string">&quot;MCAPTCHA_SERVER_IP&quot;</span>),
(<span class="string">&quot;server.domain&quot;</span>, <span class="string">&quot;MCAPTCHA_SERVER_DOMAIN&quot;</span>),
(<span class="string">&quot;server.cookie_secret&quot;</span>, <span class="string">&quot;MCAPTCHA_SERVER_COOKIE_SECRET&quot;</span>),
(<span class="string">&quot;server.proxy_has_tls&quot;</span>, <span class="string">&quot;MCAPTCHA_SERVER_PROXY_HAS_TLS&quot;</span>),
(<span class="string">&quot;captcha.salt&quot;</span>, <span class="string">&quot;MCAPTCHA_CAPTCHA_SALT&quot;</span>),
(<span class="string">&quot;captcha.gc&quot;</span>, <span class="string">&quot;MCAPTCHA_CAPTCHA_GC&quot;</span>),
(<span class="string">&quot;captcha.default_difficulty_strategy.avg_traffic_difficulty&quot;</span>, <span class="string">&quot;MCAPTCHA_CAPTCHA_AVG_TRAFFIC_DIFFICULTY&quot;</span>),
(<span class="string">&quot;captcha.default_difficulty_strategy.peak_sustainable_traffic_difficulty&quot;</span>, <span class="string">&quot;MCAPTCHA_CAPTCHA_PEAK_TRAFFIC_DIFFICULTY&quot;</span>),
(<span class="string">&quot;captcha.default_difficulty_strategy.broke_my_site_traffic_difficulty&quot;</span>, <span class="string">&quot;MCAPTCHA_CAPTCHA_BROKE_MY_SITE_TRAFFIC&quot;</span>),
(<span class="string">&quot;smtp.from&quot;</span>, <span class="string">&quot;MCAPTCHA_SMTP_FROM&quot;</span>),
(<span class="string">&quot;smtp.reply&quot;</span>, <span class="string">&quot;MCAPTCHA_SMTP_REPLY_TO&quot;</span>),
(<span class="string">&quot;smtp.url&quot;</span>, <span class="string">&quot;MCAPTCHA_SMTP_URL&quot;</span>),
(<span class="string">&quot;smtp.username&quot;</span>, <span class="string">&quot;MCAPTCHA_SMTP_USERNAME&quot;</span>),
(<span class="string">&quot;smtp.password&quot;</span>, <span class="string">&quot;MCAPTCHA_SMTP_PASSWORD&quot;</span>),
(<span class="string">&quot;smtp.port&quot;</span>, <span class="string">&quot;MCAPTCHA_SMTP_PORT&quot;</span>),
];
<span class="attr">#[cfg(not(tarpaulin_include))] <span class="attr">#[cfg(not(tarpaulin_include))]
</span><span class="kw">impl </span>Settings { </span><span class="kw">impl </span>Settings {
<span class="kw">pub fn </span>new() -&gt; <span class="prelude-ty">Result</span>&lt;<span class="self">Self</span>, ConfigError&gt; { <span class="kw">pub fn </span>new() -&gt; <span class="prelude-ty">Result</span>&lt;<span class="self">Self</span>, ConfigError&gt; {
@@ -616,6 +803,17 @@
} }
<span class="kw">fn </span>env_override(<span class="kw-2">mut </span>s: ConfigBuilder&lt;DefaultState&gt;) -&gt; ConfigBuilder&lt;DefaultState&gt; { <span class="kw">fn </span>env_override(<span class="kw-2">mut </span>s: ConfigBuilder&lt;DefaultState&gt;) -&gt; ConfigBuilder&lt;DefaultState&gt; {
<span class="kw">for </span>(parameter, env_var_name) <span class="kw">in </span>DEPRECATED_ENV_VARS.iter() {
<span class="kw">if let </span><span class="prelude-val">Ok</span>(val) = env::var(env_var_name) {
<span class="macro">log::warn!</span>(
<span class="string">&quot;Found {env_var_name}. {env_var_name} will be deprecated soon. Please see https://github.com/mCaptcha/mCaptcha/blob/master/docs/CONFIGURATION.md for latest environment variable names&quot;
</span>);
s = s.set_override(parameter, val).unwrap();
}
}
<span class="kw">for </span>(parameter, env_var_name) <span class="kw">in </span>ENV_VAR_CONFIG.iter() { <span class="kw">for </span>(parameter, env_var_name) <span class="kw">in </span>ENV_VAR_CONFIG.iter() {
<span class="kw">if let </span><span class="prelude-val">Ok</span>(val) = env::var(env_var_name) { <span class="kw">if let </span><span class="prelude-val">Ok</span>(val) = env::var(env_var_name) {
<span class="macro">log::debug!</span>( <span class="macro">log::debug!</span>(
@@ -645,8 +843,10 @@
<span class="kw">use super</span>::<span class="kw-2">*</span>; <span class="kw">use super</span>::<span class="kw-2">*</span>;
<span class="attr">#[test] <span class="attr">#[test]
</span><span class="kw">fn </span>env_override_works() { </span><span class="kw">fn </span>deprecated_env_override_works() {
<span class="kw">use </span><span class="kw">crate</span>::tests::get_settings; <span class="kw">use </span><span class="kw">crate</span>::tests::get_settings;
<span class="kw">let </span>init_settings = get_settings(); <span class="kw">let </span>init_settings = get_settings();
<span class="comment">// so that it can be tested outside the macro (helper) too <span class="comment">// so that it can be tested outside the macro (helper) too
@@ -655,6 +855,126 @@
<span class="macro">macro_rules! </span>helper { <span class="macro">macro_rules! </span>helper {
(<span class="macro-nonterminal">$env</span>:expr, <span class="macro-nonterminal">$val</span>:expr, <span class="macro-nonterminal">$val_typed</span>:expr, $(<span class="macro-nonterminal">$param</span>:ident).+) =&gt; {
<span class="macro">println!</span>(<span class="string">&quot;Setting env var {} to {} for test&quot;</span>, <span class="macro-nonterminal">$env</span>, <span class="macro-nonterminal">$val</span>);
env::set_var(<span class="macro-nonterminal">$env</span>, <span class="macro-nonterminal">$val</span>);
new_settings = get_settings();
<span class="macro">assert_eq!</span>(new_settings.$(<span class="macro-nonterminal">$param</span>).+, <span class="macro-nonterminal">$val_typed</span>);
<span class="macro">assert_ne!</span>(new_settings.$(<span class="macro-nonterminal">$param</span>).+, init_settings.$(<span class="macro-nonterminal">$param</span>).+);
env::remove_var(<span class="macro-nonterminal">$env</span>);
};
(<span class="macro-nonterminal">$env</span>:expr, <span class="macro-nonterminal">$val</span>:expr, $(<span class="macro-nonterminal">$param</span>:ident).+) =&gt; {
<span class="macro">helper!</span>(<span class="macro-nonterminal">$env</span>, <span class="macro-nonterminal">$val</span>.to_string(), <span class="macro-nonterminal">$val</span>, $(<span class="macro-nonterminal">$param</span>).+);
};
}
<span class="comment">/* top level */
</span><span class="macro">helper!</span>(<span class="string">&quot;MCAPTCHA_DEBUG&quot;</span>, !init_settings.debug, debug);
<span class="macro">helper!</span>(<span class="string">&quot;MCAPTCHA_COMMERCIAL&quot;</span>, !init_settings.commercial, commercial);
<span class="macro">helper!</span>(<span class="string">&quot;MCAPTCHA_ALLOW_REGISTRATION&quot;</span>, !init_settings.allow_registration, allow_registration);
<span class="macro">helper!</span>(<span class="string">&quot;MCAPTCHA_ALLOW_DEMO&quot;</span>, !init_settings.allow_demo, allow_demo);
<span class="comment">/* database_type */
/* redis.url */
</span><span class="kw">let </span>env = <span class="string">&quot;MCAPTCHA_REDIS_URL&quot;</span>;
<span class="kw">let </span>val = <span class="string">&quot;redis://redis.example.org&quot;</span>;
<span class="macro">println!</span>(<span class="string">&quot;Setting env var {} to {} for test&quot;</span>, env, val);
env::set_var(env, val);
new_settings = get_settings();
<span class="macro">assert_eq!</span>(new_settings.redis.as_ref().unwrap().url, val);
<span class="macro">assert_ne!</span>(
new_settings.redis.as_ref().unwrap().url,
init_settings.redis.as_ref().unwrap().url
);
env::remove_var(env);
<span class="comment">/* redis.pool */
</span><span class="kw">let </span>env = <span class="string">&quot;MCAPTCHA_REDIS_POOL&quot;</span>;
<span class="kw">let </span>val = <span class="number">999</span>;
<span class="macro">println!</span>(<span class="string">&quot;Setting env var {} to {} for test&quot;</span>, env, val);
env::set_var(env, val.to_string());
new_settings = get_settings();
<span class="macro">assert_eq!</span>(new_settings.redis.as_ref().unwrap().pool, val);
<span class="macro">assert_ne!</span>(
new_settings.redis.as_ref().unwrap().pool,
init_settings.redis.as_ref().unwrap().pool
);
env::remove_var(env);
<span class="macro">helper!</span>(<span class="string">&quot;PORT&quot;</span>, <span class="number">0</span>, server.port);
<span class="macro">helper!</span>(<span class="string">&quot;MCAPTCHA_SERVER_DOMAIN&quot;</span>, <span class="string">&quot;example.org&quot;</span>, server.domain);
<span class="macro">helper!</span>(
<span class="string">&quot;MCAPTCHA_SERVER_COOKIE_SECRET&quot;</span>,
<span class="string">&quot;dafasdfsdf&quot;</span>,
server.cookie_secret
);
<span class="macro">helper!</span>(<span class="string">&quot;MCAPTCHA_SERVER_IP&quot;</span>, <span class="string">&quot;9.9.9.9&quot;</span>, server.ip);
<span class="macro">helper!</span>(<span class="string">&quot;MCAPTCHA_SERVER_PROXY_HAS_TLS&quot;</span>, <span class="bool-val">true</span>, server.proxy_has_tls);
<span class="comment">/* captcha */
</span><span class="macro">helper!</span>(<span class="string">&quot;MCAPTCHA_CAPTCHA_SALT&quot;</span>, <span class="string">&quot;foobarasdfasdf&quot;</span>, captcha.salt);
<span class="macro">helper!</span>(<span class="string">&quot;MCAPTCHA_CAPTCHA_GC&quot;</span>, <span class="number">500</span>, captcha.gc);
<span class="macro">helper!</span>(
<span class="string">&quot;MCAPTCHA_captcha_RUNNERS&quot;</span>,
<span class="string">&quot;500&quot;</span>,
<span class="prelude-val">Some</span>(<span class="number">500</span>),
captcha.runners
);
<span class="macro">helper!</span>(
<span class="string">&quot;MCAPTCHA_CAPTCHA_AVG_TRAFFIC_DIFFICULTY&quot;</span>,
<span class="number">999</span>,
captcha.default_difficulty_strategy.avg_traffic_difficulty
);
<span class="macro">helper!</span>(<span class="string">&quot;MCAPTCHA_CAPTCHA_PEAK_TRAFFIC_DIFFICULTY&quot;</span>, <span class="number">999 </span>, captcha.default_difficulty_strategy.peak_sustainable_traffic_difficulty);
<span class="macro">helper!</span>(<span class="string">&quot;MCAPTCHA_CAPTCHA_BROKE_MY_SITE_TRAFFIC&quot;</span>, <span class="number">999 </span>, captcha.default_difficulty_strategy.broke_my_site_traffic_difficulty);
<span class="comment">/* SMTP */
</span><span class="kw">let </span>vals = [
<span class="string">&quot;MCAPTCHA_SMTP_FROM&quot;</span>,
<span class="string">&quot;MCAPTCHA_SMTP_REPLY_TO&quot;</span>,
<span class="string">&quot;MCAPTCHA_SMTP_URL&quot;</span>,
<span class="string">&quot;MCAPTCHA_SMTP_USERNAME&quot;</span>,
<span class="string">&quot;MCAPTCHA_SMTP_PASSWORD&quot;</span>,
<span class="string">&quot;MCAPTCHA_SMTP_PORT&quot;</span>,
];
<span class="kw">for </span>env <span class="kw">in </span>vals.iter() {
<span class="macro">println!</span>(<span class="string">&quot;Setting env var {} to {} for test&quot;</span>, env, env);
env::set_var(env, env);
}
<span class="kw">let </span>port = <span class="number">9999</span>;
env::set_var(<span class="string">&quot;MCAPTCHA_SMTP_PORT&quot;</span>, port.to_string());
new_settings = get_settings();
<span class="kw">let </span>smtp_new = new_settings.smtp.as_ref().unwrap();
<span class="kw">let </span>smtp_old = init_settings.smtp.as_ref().unwrap();
<span class="macro">assert_eq!</span>(smtp_new.from, <span class="string">&quot;MCAPTCHA_SMTP_FROM&quot;</span>);
<span class="macro">assert_eq!</span>(smtp_new.reply, <span class="string">&quot;MCAPTCHA_SMTP_REPLY_TO&quot;</span>);
<span class="macro">assert_eq!</span>(smtp_new.username, <span class="string">&quot;MCAPTCHA_SMTP_USERNAME&quot;</span>);
<span class="macro">assert_eq!</span>(smtp_new.password, <span class="string">&quot;MCAPTCHA_SMTP_PASSWORD&quot;</span>);
<span class="macro">assert_eq!</span>(smtp_new.port, port);
<span class="macro">assert_ne!</span>(smtp_new, smtp_old);
<span class="kw">for </span>env <span class="kw">in </span>vals.iter() {
env::remove_var(env);
}
}
<span class="attr">#[test]
</span><span class="kw">fn </span>env_override_works() {
<span class="kw">use </span><span class="kw">crate</span>::tests::get_settings;
<span class="kw">let </span>init_settings = get_settings();
<span class="comment">// so that it can be tested outside the macro (helper) too
</span><span class="kw">let </span><span class="kw-2">mut </span>new_settings;
<span class="macro">macro_rules! </span>helper {
(<span class="macro-nonterminal">$env</span>:expr, <span class="macro-nonterminal">$val</span>:expr, <span class="macro-nonterminal">$val_typed</span>:expr, $(<span class="macro-nonterminal">$param</span>:ident).+) =&gt; { (<span class="macro-nonterminal">$env</span>:expr, <span class="macro-nonterminal">$val</span>:expr, <span class="macro-nonterminal">$val_typed</span>:expr, $(<span class="macro-nonterminal">$param</span>:ident).+) =&gt; {