MCPcopy Create free account
hub / github.com/MaterializeInc/materialize / test_internal_http_auth

Function test_internal_http_auth

src/environmentd/tests/server.rs:2769–2853  ·  view source on GitHub ↗

too slow

()

Source from the content-addressed store, hash-verified

2767#[mz_ore::test]
2768#[cfg_attr(miri, ignore)] // too slow
2769fn test_internal_http_auth() {
2770 let server = test_util::TestHarness::default().start_blocking();
2771 let json = serde_json::json!({"query": "SELECT current_user;"});
2772 let url = Url::parse(&format!(
2773 "http://{}/api/sql",
2774 server.internal_http_local_addr()
2775 ))
2776 .unwrap();
2777
2778 let res = Client::new()
2779 .post(url.clone())
2780 .header("x-materialize-user", "mz_system")
2781 .json(&json)
2782 .send()
2783 .unwrap();
2784
2785 tracing::info!("response: {res:?}");
2786 assert_eq!(
2787 res.status(),
2788 StatusCode::OK,
2789 "{:?}",
2790 res.json::<serde_json::Value>()
2791 );
2792 // can be explicitly set to mz_system
2793 assert!(res.text().unwrap().to_string().contains("mz_system"));
2794
2795 // Check that mz_system is a superuser
2796 let json_superuser = serde_json::json!({"query": "SHOW is_superuser;"});
2797 let res = Client::new()
2798 .post(url.clone())
2799 .header("x-materialize-user", "mz_system")
2800 .json(&json_superuser)
2801 .send()
2802 .unwrap();
2803
2804 assert_eq!(
2805 res.status(),
2806 StatusCode::OK,
2807 "{:?}",
2808 res.json::<serde_json::Value>()
2809 );
2810 assert!(res.text().unwrap().to_string().contains("on"));
2811
2812 let res = Client::new()
2813 .post(url.clone())
2814 .header("x-materialize-user", "mz_support")
2815 .json(&json)
2816 .send()
2817 .unwrap();
2818
2819 assert_eq!(
2820 res.status(),
2821 StatusCode::OK,
2822 "{:?}",
2823 res.json::<serde_json::Value>()
2824 );
2825 // can be explicitly set to mz_support
2826 assert!(res.text().unwrap().to_string().contains("mz_support"));

Callers

nothing calls this directly

Calls 7

start_blockingMethod · 0.80
unwrapMethod · 0.80
parseFunction · 0.50
sendMethod · 0.45
jsonMethod · 0.45
headerMethod · 0.45
cloneMethod · 0.45

Tested by

no test coverage detected