upleb.uk

Public git repos — served from a NIP-34 GRASP relay at git.upleb.uk

summaryrefslogtreecommitdiff
path: root/grasp-audit/src/specs/grasp01/cors.rs
diff options
context:
space:
mode:
Diffstat (limited to 'grasp-audit/src/specs/grasp01/cors.rs')
-rw-r--r--grasp-audit/src/specs/grasp01/cors.rs43
1 files changed, 22 insertions, 21 deletions
diff --git a/grasp-audit/src/specs/grasp01/cors.rs b/grasp-audit/src/specs/grasp01/cors.rs
index f8b5f3b..eba9e42 100644
--- a/grasp-audit/src/specs/grasp01/cors.rs
+++ b/grasp-audit/src/specs/grasp01/cors.rs
@@ -14,6 +14,7 @@
14//! cd grasp-audit && nix develop -c bash test-ngit-relay.sh --mode test 14//! cd grasp-audit && nix develop -c bash test-ngit-relay.sh --mode test
15//! ``` 15//! ```
16 16
17use crate::specs::grasp01::SpecRef;
17use crate::{AuditClient, AuditResult, FixtureKind, TestContext, TestResult}; 18use crate::{AuditClient, AuditResult, FixtureKind, TestContext, TestResult};
18use nostr_sdk::prelude::*; 19use nostr_sdk::prelude::*;
19 20
@@ -44,7 +45,7 @@ impl CorsTests {
44 pub async fn test_cors_allow_origin(_client: &AuditClient, relay_domain: &str) -> TestResult { 45 pub async fn test_cors_allow_origin(_client: &AuditClient, relay_domain: &str) -> TestResult {
45 TestResult::new( 46 TestResult::new(
46 "cors_allow_origin", 47 "cors_allow_origin",
47 "GRASP-01:git-http:cors:50", 48 SpecRef::CorsAllowOrigin,
48 "Access-Control-Allow-Origin: * on all responses", 49 "Access-Control-Allow-Origin: * on all responses",
49 ) 50 )
50 .run(|| { 51 .run(|| {
@@ -90,7 +91,7 @@ impl CorsTests {
90 pub async fn test_cors_allow_methods(_client: &AuditClient, relay_domain: &str) -> TestResult { 91 pub async fn test_cors_allow_methods(_client: &AuditClient, relay_domain: &str) -> TestResult {
91 TestResult::new( 92 TestResult::new(
92 "cors_allow_methods", 93 "cors_allow_methods",
93 "GRASP-01:git-http:cors:51", 94 SpecRef::CorsAllowMethods,
94 "Access-Control-Allow-Methods: GET, POST on all responses", 95 "Access-Control-Allow-Methods: GET, POST on all responses",
95 ) 96 )
96 .run(|| { 97 .run(|| {
@@ -134,7 +135,7 @@ impl CorsTests {
134 pub async fn test_cors_allow_headers(_client: &AuditClient, relay_domain: &str) -> TestResult { 135 pub async fn test_cors_allow_headers(_client: &AuditClient, relay_domain: &str) -> TestResult {
135 TestResult::new( 136 TestResult::new(
136 "cors_allow_headers", 137 "cors_allow_headers",
137 "GRASP-01:git-http:cors:52", 138 SpecRef::CorsAllowHeaders,
138 "Access-Control-Allow-Headers: Content-Type on all responses", 139 "Access-Control-Allow-Headers: Content-Type on all responses",
139 ) 140 )
140 .run(|| { 141 .run(|| {
@@ -181,8 +182,8 @@ impl CorsTests {
181 ) -> TestResult { 182 ) -> TestResult {
182 TestResult::new( 183 TestResult::new(
183 "cors_options_preflight", 184 "cors_options_preflight",
184 "GRASP-01:git-http:cors:53", 185 SpecRef::CorsOptionsResponse,
185 "OPTIONS requests return 204 No Content", 186 "OPTIONS requests return 204 No Content with CORS headers",
186 ) 187 )
187 .run(|| { 188 .run(|| {
188 let relay_domain = relay_domain.to_string(); 189 let relay_domain = relay_domain.to_string();
@@ -250,8 +251,8 @@ impl CorsTests {
250 Err(e) => { 251 Err(e) => {
251 return TestResult::new( 252 return TestResult::new(
252 test_name, 253 test_name,
253 "GRASP-01", 254 SpecRef::CorsAllowOrigin,
254 "CORS headers on real repository endpoint", 255 "CORS headers on real repository endpoints",
255 ) 256 )
256 .fail(format!("Failed to create repo fixture: {}", e)) 257 .fail(format!("Failed to create repo fixture: {}", e))
257 } 258 }
@@ -271,8 +272,8 @@ impl CorsTests {
271 None => { 272 None => {
272 return TestResult::new( 273 return TestResult::new(
273 test_name, 274 test_name,
274 "GRASP-01", 275 SpecRef::CorsAllowOrigin,
275 "CORS headers on real repository endpoint", 276 "CORS headers on real repository endpoints",
276 ) 277 )
277 .fail("Repository announcement missing d tag") 278 .fail("Repository announcement missing d tag")
278 } 279 }
@@ -283,8 +284,8 @@ impl CorsTests {
283 Err(e) => { 284 Err(e) => {
284 return TestResult::new( 285 return TestResult::new(
285 test_name, 286 test_name,
286 "GRASP-01", 287 SpecRef::CorsAllowOrigin,
287 "CORS headers on real repository endpoint", 288 "CORS headers on real repository endpoints",
288 ) 289 )
289 .fail(format!("Failed to convert pubkey to npub: {}", e)) 290 .fail(format!("Failed to convert pubkey to npub: {}", e))
290 } 291 }
@@ -302,8 +303,8 @@ impl CorsTests {
302 Err(e) => { 303 Err(e) => {
303 return TestResult::new( 304 return TestResult::new(
304 test_name, 305 test_name,
305 "GRASP-01", 306 SpecRef::CorsAllowOrigin,
306 "CORS headers on real repository endpoint", 307 "CORS headers on real repository endpoints",
307 ) 308 )
308 .fail(format!("Failed to GET info/refs: {}", e)) 309 .fail(format!("Failed to GET info/refs: {}", e))
309 } 310 }
@@ -313,8 +314,8 @@ impl CorsTests {
313 if let Err(e) = check_cors_allow_origin(&response, "info/refs") { 314 if let Err(e) = check_cors_allow_origin(&response, "info/refs") {
314 return TestResult::new( 315 return TestResult::new(
315 test_name, 316 test_name,
316 "GRASP-01", 317 SpecRef::CorsAllowOrigin,
317 "CORS headers on real repository endpoint", 318 "CORS headers on real repository endpoints",
318 ) 319 )
319 .fail(&e); 320 .fail(&e);
320 } 321 }
@@ -322,8 +323,8 @@ impl CorsTests {
322 if let Err(e) = check_cors_allow_methods(&response, "info/refs") { 323 if let Err(e) = check_cors_allow_methods(&response, "info/refs") {
323 return TestResult::new( 324 return TestResult::new(
324 test_name, 325 test_name,
325 "GRASP-01", 326 SpecRef::CorsAllowMethods,
326 "CORS headers on real repository endpoint", 327 "CORS headers on real repository endpoints",
327 ) 328 )
328 .fail(&e); 329 .fail(&e);
329 } 330 }
@@ -331,16 +332,16 @@ impl CorsTests {
331 if let Err(e) = check_cors_allow_headers(&response, "info/refs") { 332 if let Err(e) = check_cors_allow_headers(&response, "info/refs") {
332 return TestResult::new( 333 return TestResult::new(
333 test_name, 334 test_name,
334 "GRASP-01", 335 SpecRef::CorsAllowHeaders,
335 "CORS headers on real repository endpoint", 336 "CORS headers on real repository endpoints",
336 ) 337 )
337 .fail(&e); 338 .fail(&e);
338 } 339 }
339 340
340 TestResult::new( 341 TestResult::new(
341 test_name, 342 test_name,
342 "GRASP-01", 343 SpecRef::CorsAllowOrigin,
343 "CORS headers on real repository endpoint", 344 "CORS headers on real repository endpoints",
344 ) 345 )
345 .pass() 346 .pass()
346 } 347 }