Commit
+29 -23 +/-10 browse
1 | diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml |
2 | index 7739fab..387b9c4 100644 |
3 | --- a/.github/workflows/rust.yml |
4 | +++ b/.github/workflows/rust.yml |
5 | @@ -30,4 +30,4 @@ jobs: |
6 | - name: Build |
7 | run: cargo build --verbose |
8 | - name: Run tests |
9 | - run: cargo test --features test --verbose |
10 | + run: cargo test --verbose |
11 | diff --git a/README.md b/README.md |
12 | index 8e9ff73..59cf45f 100644 |
13 | --- a/README.md |
14 | +++ b/README.md |
15 | @@ -187,7 +187,7 @@ More examples available under the [examples](examples) directory. |
16 | To run the testsuite: |
17 | |
18 | ```bash |
19 | - $ cargo test --features test |
20 | + $ cargo test |
21 | ``` |
22 | |
23 | To fuzz the library with `cargo-fuzz`: |
24 | diff --git a/src/arc/seal.rs b/src/arc/seal.rs |
25 | index 9ab8d54..0ba3101 100644 |
26 | --- a/src/arc/seal.rs |
27 | +++ b/src/arc/seal.rs |
28 | @@ -236,7 +236,7 @@ GMot/L2x0IYyMLAz6oLWh2hm7zwtb0CgOrPo1ke44hFYnfc= |
29 | |
30 | // Crate resolver |
31 | let resolver = Resolver::new_system_conf().unwrap(); |
32 | - #[cfg(feature = "test")] |
33 | + #[cfg(any(test, feature = "test"))] |
34 | { |
35 | resolver.txt_add( |
36 | "rsa._domainkey.manchego.org.".to_string(), |
37 | diff --git a/src/arc/verify.rs b/src/arc/verify.rs |
38 | index ef44a3c..7ee20c6 100644 |
39 | --- a/src/arc/verify.rs |
40 | +++ b/src/arc/verify.rs |
41 | @@ -221,7 +221,7 @@ mod test { |
42 | .split('\n') |
43 | .filter_map(|r| r.split_once(' ').map(|(a, b)| (a, b.as_bytes()))) |
44 | { |
45 | - #[cfg(feature = "test")] |
46 | + #[cfg(any(test, feature = "test"))] |
47 | resolver.txt_add( |
48 | format!("{}.", key), |
49 | DomainKey::parse(value).unwrap(), |
50 | diff --git a/src/common/resolver.rs b/src/common/resolver.rs |
51 | index 7cb4a61..246de77 100644 |
52 | --- a/src/common/resolver.rs |
53 | +++ b/src/common/resolver.rs |
54 | @@ -109,7 +109,7 @@ impl Resolver { |
55 | return T::unwrap_txt(value); |
56 | } |
57 | |
58 | - #[cfg(feature = "test")] |
59 | + #[cfg(any(test, feature = "test"))] |
60 | if true { |
61 | return mock_resolve(key.as_ref()); |
62 | } |
63 | @@ -150,7 +150,7 @@ impl Resolver { |
64 | return Ok(value); |
65 | } |
66 | |
67 | - #[cfg(feature = "test")] |
68 | + #[cfg(any(test, feature = "test"))] |
69 | if true { |
70 | return mock_resolve(key.as_ref()); |
71 | } |
72 | @@ -190,7 +190,7 @@ impl Resolver { |
73 | return Ok(value); |
74 | } |
75 | |
76 | - #[cfg(feature = "test")] |
77 | + #[cfg(any(test, feature = "test"))] |
78 | if true { |
79 | return mock_resolve(key.as_ref()); |
80 | } |
81 | @@ -216,7 +216,7 @@ impl Resolver { |
82 | return Ok(value); |
83 | } |
84 | |
85 | - #[cfg(feature = "test")] |
86 | + #[cfg(any(test, feature = "test"))] |
87 | if true { |
88 | return mock_resolve(key.as_ref()); |
89 | } |
90 | @@ -246,7 +246,7 @@ impl Resolver { |
91 | return Ok(value); |
92 | } |
93 | |
94 | - #[cfg(feature = "test")] |
95 | + #[cfg(any(test, feature = "test"))] |
96 | if true { |
97 | return mock_resolve(&addr.to_string()); |
98 | } |
99 | @@ -271,7 +271,7 @@ impl Resolver { |
100 | } |
101 | |
102 | pub async fn exists<'x>(&self, key: impl IntoFqdn<'x>) -> crate::Result<bool> { |
103 | - #[cfg(feature = "test")] |
104 | + #[cfg(any(test, feature = "test"))] |
105 | if true { |
106 | let key = key.into_fqdn().into_owned(); |
107 | return match self.ipv4_lookup(key.as_str()).await { |
108 | @@ -302,7 +302,7 @@ impl Resolver { |
109 | } |
110 | } |
111 | |
112 | - #[cfg(feature = "test")] |
113 | + #[cfg(any(test, feature = "test"))] |
114 | pub fn txt_add<'x>( |
115 | &self, |
116 | name: impl IntoFqdn<'x>, |
117 | @@ -313,7 +313,7 @@ impl Resolver { |
118 | .insert(name.into_fqdn().into_owned(), value.into(), valid_until); |
119 | } |
120 | |
121 | - #[cfg(feature = "test")] |
122 | + #[cfg(any(test, feature = "test"))] |
123 | pub fn ipv4_add<'x>( |
124 | &self, |
125 | name: impl IntoFqdn<'x>, |
126 | @@ -324,7 +324,7 @@ impl Resolver { |
127 | .insert(name.into_fqdn().into_owned(), Arc::new(value), valid_until); |
128 | } |
129 | |
130 | - #[cfg(feature = "test")] |
131 | + #[cfg(any(test, feature = "test"))] |
132 | pub fn ipv6_add<'x>( |
133 | &self, |
134 | name: impl IntoFqdn<'x>, |
135 | @@ -335,12 +335,12 @@ impl Resolver { |
136 | .insert(name.into_fqdn().into_owned(), Arc::new(value), valid_until); |
137 | } |
138 | |
139 | - #[cfg(feature = "test")] |
140 | + #[cfg(any(test, feature = "test"))] |
141 | pub fn ptr_add(&self, name: IpAddr, value: Vec<String>, valid_until: std::time::Instant) { |
142 | self.cache_ptr.insert(name, Arc::new(value), valid_until); |
143 | } |
144 | |
145 | - #[cfg(feature = "test")] |
146 | + #[cfg(any(test, feature = "test"))] |
147 | pub fn mx_add<'x>( |
148 | &self, |
149 | name: impl IntoFqdn<'x>, |
150 | @@ -538,7 +538,7 @@ impl<'x> IntoFqdn<'x> for &String { |
151 | } |
152 | } |
153 | |
154 | - #[cfg(feature = "test")] |
155 | + #[cfg(any(test, feature = "test"))] |
156 | pub fn mock_resolve<T>(domain: &str) -> crate::Result<T> { |
157 | Err(if domain.contains("_parse_error.") { |
158 | Error::ParseError |
159 | diff --git a/src/common/verify.rs b/src/common/verify.rs |
160 | index c1b6857..af4d9a9 100644 |
161 | --- a/src/common/verify.rs |
162 | +++ b/src/common/verify.rs |
163 | @@ -72,6 +72,12 @@ impl Resolver { |
164 | } |
165 | } |
166 | |
167 | + impl IprevOutput { |
168 | + pub fn result(&self) -> &IprevResult { |
169 | + &self.result |
170 | + } |
171 | + } |
172 | + |
173 | impl DomainKey { |
174 | pub(crate) fn verify<'a>( |
175 | &self, |
176 | diff --git a/src/dkim/sign.rs b/src/dkim/sign.rs |
177 | index 819af62..5b47db7 100644 |
178 | --- a/src/dkim/sign.rs |
179 | +++ b/src/dkim/sign.rs |
180 | @@ -207,7 +207,7 @@ GMot/L2x0IYyMLAz6oLWh2hm7zwtb0CgOrPo1ke44hFYnfc= |
181 | |
182 | // Create resolver |
183 | let resolver = Resolver::new_system_conf().unwrap(); |
184 | - #[cfg(feature = "test")] |
185 | + #[cfg(any(test, feature = "test"))] |
186 | { |
187 | resolver.txt_add( |
188 | "default._domainkey.example.com.".to_string(), |
189 | @@ -352,7 +352,7 @@ GMot/L2x0IYyMLAz6oLWh2hm7zwtb0CgOrPo1ke44hFYnfc= |
190 | |
191 | // Verify ATPS (success) |
192 | let pk_rsa = RsaKey::<Sha256>::from_pkcs1_pem(RSA_PRIVATE_KEY).unwrap(); |
193 | - #[cfg(feature = "test")] |
194 | + #[cfg(any(test, feature = "test"))] |
195 | resolver.txt_add( |
196 | "UN42N5XOV642KXRXRQIYANHCOUPGQL5LT4WTBKYT2IJFLBWODFDQ._atps.example.com.".to_string(), |
197 | Atps::parse(b"v=ATPS1;").unwrap(), |
198 | @@ -375,7 +375,7 @@ GMot/L2x0IYyMLAz6oLWh2hm7zwtb0CgOrPo1ke44hFYnfc= |
199 | |
200 | // Verify ATPS (success - no hash) |
201 | let pk_rsa = RsaKey::<Sha256>::from_pkcs1_pem(RSA_PRIVATE_KEY).unwrap(); |
202 | - #[cfg(feature = "test")] |
203 | + #[cfg(any(test, feature = "test"))] |
204 | resolver.txt_add( |
205 | "example.com._atps.example.com.".to_string(), |
206 | Atps::parse(b"v=ATPS1;").unwrap(), |
207 | diff --git a/src/dkim/verify.rs b/src/dkim/verify.rs |
208 | index 1e80d44..381160b 100644 |
209 | --- a/src/dkim/verify.rs |
210 | +++ b/src/dkim/verify.rs |
211 | @@ -413,7 +413,7 @@ mod test { |
212 | .split('\n') |
213 | .filter_map(|r| r.split_once(' ').map(|(a, b)| (a, b.as_bytes()))) |
214 | { |
215 | - #[cfg(feature = "test")] |
216 | + #[cfg(any(test, feature = "test"))] |
217 | resolver.txt_add( |
218 | format!("{}.", key), |
219 | DomainKey::parse(value).unwrap(), |
220 | diff --git a/src/dmarc/verify.rs b/src/dmarc/verify.rs |
221 | index 21a3287..1101a0d 100644 |
222 | --- a/src/dmarc/verify.rs |
223 | +++ b/src/dmarc/verify.rs |
224 | @@ -313,7 +313,7 @@ mod test { |
225 | Policy::Reject, |
226 | ), |
227 | ] { |
228 | - #[cfg(feature = "test")] |
229 | + #[cfg(any(test, feature = "test"))] |
230 | resolver.txt_add( |
231 | dmarc_dns, |
232 | Dmarc::parse(dmarc.as_bytes()).unwrap(), |
233 | @@ -349,7 +349,7 @@ mod test { |
234 | #[tokio::test] |
235 | async fn dmarc_verify_report_address() { |
236 | let resolver = Resolver::new_system_conf().unwrap(); |
237 | - #[cfg(feature = "test")] |
238 | + #[cfg(any(test, feature = "test"))] |
239 | resolver.txt_add( |
240 | "example.org.report.dmarc.external.org.", |
241 | Dmarc::parse(b"v=DMARC1").unwrap(), |
242 | diff --git a/src/spf/verify.rs b/src/spf/verify.rs |
243 | index 7337fe9..24a338c 100644 |
244 | --- a/src/spf/verify.rs |
245 | +++ b/src/spf/verify.rs |
246 | @@ -558,7 +558,7 @@ mod test { |
247 | line |
248 | }; |
249 | |
250 | - #[cfg(feature = "test")] |
251 | + #[cfg(any(test, feature = "test"))] |
252 | { |
253 | if let Some(name) = line.strip_prefix("name:") { |
254 | test_name = name.trim(); |