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

Function auth_with_ws_impl

src/environmentd/src/test_util.rs:1729–1758  ·  view source on GitHub ↗
(
    ws: &mut WebSocket<MaybeTlsStream<TcpStream>>,
    auth_message: Message,
)

Source from the content-addressed store, hash-verified

1727}
1728
1729pub fn auth_with_ws_impl(
1730 ws: &mut WebSocket<MaybeTlsStream<TcpStream>>,
1731 auth_message: Message,
1732) -> Result<Vec<WebSocketResponse>, anyhow::Error> {
1733 ws.send(auth_message)?;
1734
1735 // Wait for initial ready response.
1736 let mut msgs = Vec::new();
1737 loop {
1738 let resp = ws.read()?;
1739 match resp {
1740 Message::Text(msg) => {
1741 let msg: WebSocketResponse = serde_json::from_str(&msg).unwrap();
1742 match msg {
1743 WebSocketResponse::ReadyForQuery(_) => break,
1744 msg => {
1745 msgs.push(msg);
1746 }
1747 }
1748 }
1749 Message::Ping(_) => continue,
1750 Message::Close(None) => return Err(anyhow!("ws closed after auth")),
1751 Message::Close(Some(close_frame)) => {
1752 return Err(anyhow!("ws closed after auth").context(close_frame));
1753 }
1754 _ => panic!("unexpected response: {:?}", resp),
1755 }
1756 }
1757 Ok(msgs)
1758}
1759
1760pub fn make_header<H: Header>(h: H) -> HeaderMap {
1761 let mut map = HeaderMap::new();

Callers 2

auth_with_wsFunction · 0.85
test_internal_ws_authFunction · 0.85

Calls 5

unwrapMethod · 0.80
sendMethod · 0.45
readMethod · 0.45
pushMethod · 0.45
contextMethod · 0.45

Tested by

no test coverage detected