Returning the previous signed request when updating the digest is neither necessary nor useful (#1840)

This commit is contained in:
Amaury Chamayou 2020-10-30 14:59:08 +00:00 коммит произвёл GitHub
Родитель c8271d6d5b
Коммит b1976321e8
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
4 изменённых файлов: 13 добавлений и 59 удалений

Просмотреть файл

@ -284,21 +284,6 @@
],
"type": "object"
},
"MemberAck": {
"properties": {
"signed_req": {
"$ref": "#/components/schemas/SignedReq"
},
"state_digest": {
"$ref": "#/components/schemas/uint8_array"
}
},
"required": [
"state_digest",
"signed_req"
],
"type": "object"
},
"NodeStatus": {
"enum": [
"PENDING",
@ -389,29 +374,6 @@
},
"type": "object"
},
"SignedReq": {
"properties": {
"md": {
"$ref": "#/components/schemas/mbedtls_md_type_t"
},
"req": {
"$ref": "#/components/schemas/uint8_array"
},
"request_body": {
"$ref": "#/components/schemas/uint8_array"
},
"sig": {
"$ref": "#/components/schemas/uint8_array"
}
},
"required": [
"sig",
"req",
"request_body",
"md"
],
"type": "object"
},
"StateDigest": {
"properties": {
"state_digest": {
@ -478,15 +440,6 @@
"type": "integer"
},
"json": {},
"mbedtls_md_type_t": {
"enum": [
"MBEDTLS_MD_NONE",
"MBEDTLS_MD_SHA1",
"MBEDTLS_MD_SHA256",
"MBEDTLS_MD_SHA384",
"MBEDTLS_MD_SHA512"
]
},
"named_EndpointMetrics__Metric": {
"additionalProperties": {
"$ref": "#/components/schemas/EndpointMetrics__Metric"
@ -578,7 +531,7 @@
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/MemberAck"
"$ref": "#/components/schemas/StateDigest"
}
}
},

Просмотреть файл

@ -1345,11 +1345,11 @@ namespace ccf
ma_view->put(caller_id, ma.value());
}
return make_success(ma.value());
return make_success(ma->state_digest);
};
make_endpoint(
"ack/update_state_digest", HTTP_POST, json_adapter(update_state_digest))
.set_auto_schema<void, MemberAck>()
.set_auto_schema<void, StateDigest>()
.install();
auto get_encrypted_recovery_share = [this](

Просмотреть файл

@ -627,15 +627,16 @@ DOCTEST_TEST_CASE("Add new members until there are 7 then reject")
// (2) ask for a fresher digest of state
const auto freshen_state_digest_req =
create_request(nullptr, "ack/update_state_digest");
const auto freshen_state_digest = parse_response_body<StateDigest>(
frontend_process(frontend, freshen_state_digest_req, new_member->cert));
DOCTEST_CHECK(freshen_state_digest.state_digest != ack0.state_digest);
const auto freshen_state_digest =
parse_response_body<std::vector<uint8_t>>(frontend_process(
frontend, freshen_state_digest_req, new_member->cert));
DOCTEST_CHECK(freshen_state_digest != ack0.state_digest);
// (3) read ack entry again and check that the state digest has changed
const auto ack1 = parse_response_body<StateDigest>(
frontend_process(frontend, read_state_digest_req, new_member->cert));
DOCTEST_CHECK(ack0.state_digest != ack1.state_digest);
DOCTEST_CHECK(freshen_state_digest.state_digest == ack1.state_digest);
DOCTEST_CHECK(freshen_state_digest == ack1.state_digest);
// (4) sign stale state and send it
StateDigest params;
@ -1518,11 +1519,11 @@ DOCTEST_TEST_CASE("Passing operator vote" * doctest::test_suite("operator"))
DOCTEST_INFO("New operator acks to become active");
const auto state_digest_req =
create_request(nullptr, "ack/update_state_digest");
const auto ack = parse_response_body<StateDigest>(
const auto ack = parse_response_body<std::vector<uint8_t>>(
frontend_process(frontend, state_digest_req, new_operator_cert));
StateDigest params;
params.state_digest = ack.state_digest;
params.state_digest = ack;
const auto ack_req =
create_signed_request(params, "ack", new_operator_kp);
const auto resp = frontend_process(frontend, ack_req, new_operator_cert);
@ -1991,11 +1992,11 @@ DOCTEST_TEST_CASE("Maximum number of active members")
{
const auto state_digest_req =
create_request(nullptr, "ack/update_state_digest");
const auto ack = parse_response_body<StateDigest>(
const auto ack = parse_response_body<std::vector<uint8_t>>(
frontend_process(frontend, state_digest_req, m.second));
StateDigest params;
params.state_digest = ack.state_digest;
params.state_digest = ack;
const auto ack_req = create_signed_request(params, "ack", kp);
const auto resp = frontend_process(frontend, ack_req, m.second);

Просмотреть файл

@ -129,7 +129,7 @@ class Member:
with remote_node.client(f"member{self.member_id}") as mc:
r = mc.post("/gov/ack/update_state_digest")
assert r.status_code == 200, f"Error ack/update_state_digest: {r}"
return bytearray(r.body.json()["state_digest"])
return bytearray(r.body.json())
def ack(self, remote_node):
state_digest = self.update_ack_state_digest(remote_node)