Add M10.3b session login over QUIC
Foundation / checks (deploy) (push) Successful in 5s
Foundation / checks (ecs) (push) Successful in 3m13s
Foundation / checks (client) (push) Successful in 12m12s
Foundation / checks (network) (push) Successful in 8m56s
Foundation / checks (tsan) (push) Successful in 7m42s
Foundation / postgres-tools (push) Canceled after 0s
Foundation / server-image (push) Canceled after 0s
Foundation / image (push) Canceled after 0s
Foundation / checks (postgres) (push) Canceled after 19m14s
Foundation / checks (checks) (push) Canceled after 31m28s
Foundation / checks (deploy) (push) Successful in 5s
Foundation / checks (ecs) (push) Successful in 3m13s
Foundation / checks (client) (push) Successful in 12m12s
Foundation / checks (network) (push) Successful in 8m56s
Foundation / checks (tsan) (push) Successful in 7m42s
Foundation / postgres-tools (push) Canceled after 0s
Foundation / server-image (push) Canceled after 0s
Foundation / image (push) Canceled after 0s
Foundation / checks (postgres) (push) Canceled after 19m14s
Foundation / checks (checks) (push) Canceled after 31m28s
Session protocol v1 session messages (Hello with grant, Welcome, Refresh, RefreshResult, Close with reasons) on the QUIC reliable stream. RegionSessions verifies grants with the issuer public keys and admits them through SessionControl: a newer grant closes the account's old connection as superseded, expiry and epoch advances close sessions, every close is announced and flushed. RegionSessionClient logs in, refreshes in place and reports why a session ended. ADR-0091. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
#include "evo/network/dev_grant.hpp"
|
||||
#include "evo/network/session_control.hpp"
|
||||
#include "evo/network/session_grant.hpp"
|
||||
#include "evo/network/session_protocol.hpp"
|
||||
#include "network_test.hpp"
|
||||
#include <algorithm>
|
||||
#include <array>
|
||||
@@ -321,11 +322,74 @@ void control_rules() {
|
||||
labelled.bytes.at(i) = static_cast<std::uint8_t>(0xA0 + i);
|
||||
CHECK(log_label(labelled) == "acct-a0a1a2a3");
|
||||
}
|
||||
void session_codec() {
|
||||
WireGrant grant{};
|
||||
for (std::size_t i = 0; i < grant.size(); ++i)
|
||||
grant.at(i) = static_cast<std::uint8_t>(i * 7);
|
||||
SessionWelcome welcome{1, 2, 3, 4, 5, 6, 7};
|
||||
const std::vector<SessionMessage> messages{
|
||||
SessionHello{0, grant},
|
||||
welcome,
|
||||
SessionRefresh{grant},
|
||||
SessionRefreshResult{0, 99},
|
||||
SessionRefreshResult{static_cast<std::uint8_t>(SessionCloseReason::stale_grant), 0},
|
||||
SessionClose{SessionCloseReason::superseded},
|
||||
SessionClose{SessionCloseReason::shutdown}};
|
||||
for (const auto& m : messages) {
|
||||
const auto bytes = encode_session(m);
|
||||
CHECK(bytes.at(0) == 'E' && bytes.at(1) == 'V' && bytes.at(2) == 'S' && bytes.at(3) == 'N');
|
||||
const auto back = decode_session(bytes);
|
||||
CHECK(back && back->index() == m.index());
|
||||
CHECK(encode_session(*back) == bytes);
|
||||
// Every truncation and any extension is refused.
|
||||
for (std::size_t n = 0; n < bytes.size(); ++n) {
|
||||
const auto r = decode_session(std::span{bytes}.first(n));
|
||||
CHECK(!r && r.error() == (n < session_header_bytes ? SessionCodecError::truncated
|
||||
: SessionCodecError::wrong_length));
|
||||
}
|
||||
auto longer = bytes;
|
||||
longer.push_back(0);
|
||||
CHECK(refused(decode_session(longer), SessionCodecError::wrong_length));
|
||||
auto mutated = bytes;
|
||||
mutated.at(0) ^= 1;
|
||||
CHECK(refused(decode_session(mutated), SessionCodecError::bad_magic));
|
||||
mutated = bytes;
|
||||
mutated.at(4) = 2;
|
||||
CHECK(refused(decode_session(mutated), SessionCodecError::unsupported_version));
|
||||
mutated = bytes;
|
||||
mutated.at(7) = 1;
|
||||
CHECK(refused(decode_session(mutated), SessionCodecError::reserved_flags));
|
||||
for (const auto type : std::array<std::uint8_t, 3>{0, 6, 255}) {
|
||||
mutated = bytes;
|
||||
mutated.at(6) = type;
|
||||
CHECK(refused(decode_session(mutated), SessionCodecError::unknown_type));
|
||||
}
|
||||
}
|
||||
CHECK(std::get<SessionWelcome>(*decode_session(encode_session(welcome))) == welcome);
|
||||
CHECK(std::get<SessionHello>(*decode_session(encode_session(SessionHello{0, grant}))).grant ==
|
||||
grant);
|
||||
for (const auto reason : std::array<std::uint8_t, 4>{0, 14, 200, 255}) {
|
||||
auto close = encode_session(SessionClose{SessionCloseReason::protocol});
|
||||
close.back() = reason;
|
||||
CHECK(refused(decode_session(close), SessionCodecError::invalid_value));
|
||||
if (reason != 0) {
|
||||
auto result = encode_session(SessionRefreshResult{0, 0});
|
||||
result.at(session_header_bytes) = reason;
|
||||
CHECK(refused(decode_session(result), SessionCodecError::invalid_value));
|
||||
}
|
||||
}
|
||||
for (const auto zero : {0, 1}) {
|
||||
auto w = welcome;
|
||||
(zero == 0 ? w.session : w.epoch) = 0;
|
||||
CHECK(refused(decode_session(encode_session(w)), SessionCodecError::invalid_value));
|
||||
}
|
||||
}
|
||||
} // namespace
|
||||
|
||||
void control_tests() {
|
||||
grants();
|
||||
identity_adapter();
|
||||
control_rules();
|
||||
session_codec();
|
||||
}
|
||||
} // namespace evo::network_test
|
||||
|
||||
Reference in New Issue
Block a user