()
| 1040 | #[mz_ore::test] |
| 1041 | #[allow(clippy::disallowed_methods)] |
| 1042 | fn test_http_sql() { |
| 1043 | // Datadriven directives for WebSocket are "ws-text" and "ws-binary" to send |
| 1044 | // text or binary websocket messages that are the input. Output is |
| 1045 | // everything until and including the next ReadyForQuery message. An |
| 1046 | // optional "rows=N" argument can be given in the directive to produce |
| 1047 | // datadriven output after N rows. Any directive with rows=N should be the |
| 1048 | // final directive in a file, since it leaves the websocket in a |
| 1049 | // mid-statement state. |
| 1050 | // A "fixtimestamp=true" argument can be given to replace timestamps with "<TIMESTAMP>". |
| 1051 | // A "fixid=true" argument can be given to replace IDs with "<ID>". |
| 1052 | // |
| 1053 | // Datadriven directive for HTTP POST is "http". Input and output are the |
| 1054 | // documented JSON formats. |
| 1055 | |
| 1056 | let fixtimestamp_replacements = [(Regex::new(r#"\d{13}(\.0)?"#).unwrap(), "<TIMESTAMP>")]; |
| 1057 | let fixid_replacements = [ |
| 1058 | ( |
| 1059 | Regex::new(r#"\\"(User|System|Transient)\\": \d+"#).unwrap(), |
| 1060 | "<ID>", |
| 1061 | ), |
| 1062 | (Regex::new(r#"\b[ust]\d+\b"#).unwrap(), "<ID>"), |
| 1063 | (Regex::new(r#"\\n[ust]\d+\b"#).unwrap(), "\\n<ID>"), |
| 1064 | ]; |
| 1065 | |
| 1066 | datadriven::walk("tests/testdata/http", |f| { |
| 1067 | let server = test_util::TestHarness::default().start_blocking(); |
| 1068 | |
| 1069 | // Grant all privileges to default http user. |
| 1070 | // TODO(jkosh44) The HTTP endpoint has a special default user while the WS endpoint just |
| 1071 | // uses the "materialize" role. This is probably wrong. They should either both user |
| 1072 | // materialize, both use the same special default user, each have their own special |
| 1073 | // default user. |
| 1074 | { |
| 1075 | let mut super_user = server |
| 1076 | .pg_config_internal() |
| 1077 | .user(&SYSTEM_USER.name) |
| 1078 | .connect(postgres::NoTls) |
| 1079 | .unwrap(); |
| 1080 | super_user |
| 1081 | .batch_execute(&format!("CREATE ROLE {}", &HTTP_DEFAULT_USER.name)) |
| 1082 | .unwrap(); |
| 1083 | super_user |
| 1084 | .batch_execute(&format!( |
| 1085 | "GRANT ALL PRIVILEGES ON SYSTEM TO {}", |
| 1086 | &HTTP_DEFAULT_USER.name |
| 1087 | )) |
| 1088 | .unwrap(); |
| 1089 | super_user |
| 1090 | .batch_execute(&format!( |
| 1091 | "GRANT ALL PRIVILEGES ON CLUSTER quickstart TO {}", |
| 1092 | &HTTP_DEFAULT_USER.name |
| 1093 | )) |
| 1094 | .unwrap(); |
| 1095 | super_user |
| 1096 | .batch_execute(&format!( |
| 1097 | "GRANT ALL PRIVILEGES ON DATABASE materialize TO {}", |
| 1098 | &HTTP_DEFAULT_USER.name |
| 1099 | )) |
nothing calls this directly
no test coverage detected