Skip to content

Commit eda311e

Browse files
apskhemMr-Leshiy
andauthored
test(cat-gateway): Prepare document submission in different types for integration test (#3713)
* initial * feat: tmp setup * feat: prepare test data * chore: minor * chore: preparing minor * feat: apply json auto generate * feat: apply json auto generate * feat: general factory * feat: campaign setup * feat: minor rework * feat: pre final * chore: fmt * chore: add jsf * chore: remove unused template * chore: once fixture * fix: factory calling * chore: update lockfile * fix: comments * chore: move metadata * fix: type * chore: reorder fixtures * chore: reorder fixtures * fix: imports * fix: proposal form template metadata * fix: proposal form template id, ver, and params * fix: proposal form template id, ver, and params * feat: admin key setup initial * feat: admin auth key * fix: cspell * chore: minor builder clean up * chore: minor format * chore: minor format * chore: role id as param * chore: minor admin * chore: admin cat-id * test(cat-gateway): Prepare document submission in different types for integration test [CI fixes] (#3781) * rename ProposalParameterType to ParameterType * cleanup * set the 3.13 python version * fix * fix * fix * fix * fix * try * try * bump mk_signed_doc to `catalyst-signed-doc/v0.0.10` * replace JSF with ranjg * fix spelling * chore: minor cleanup * wip --------- Co-authored-by: Alex Pozhylenkov <[email protected]>
1 parent d4e7ac4 commit eda311e

File tree

20 files changed

+2465
-597
lines changed

20 files changed

+2465
-597
lines changed

.config/dictionaries/project.dic

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -294,6 +294,7 @@ pyproject
294294
pyright
295295
pytest
296296
qrcode
297+
ranjg
297298
rapidoc
298299
ratelimit
299300
redoc

catalyst-gateway/bin/src/db/event/signed_docs/tests/mod.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -189,9 +189,8 @@ async fn filter_by_type(
189189
}
190190
}
191191

192-
/// Pre-seeded documents `f14.sql`, `f15.sql`, `old_format_signed_doc.sql` and
193-
/// `test_signed_documents.sql`
194-
const PRE_SEED_DATA: usize = 57;
192+
/// Pre-seeded documents `f14.sql`, `f15.sql`, `old_format_signed_doc.sql`
193+
const PRE_SEED_DATA: usize = 55;
195194

196195
async fn filter_all(docs: &[FullSignedDoc]) {
197196
let filter = DocsQueryFilter::all();

catalyst-gateway/bin/src/service/api/documents/common/mod.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -208,12 +208,13 @@ impl VerifyingKeyProvider {
208208
token: &mut CatalystRBACTokenV1,
209209
kids: &[catalyst_signed_doc::CatalystId],
210210
) -> anyhow::Result<Self> {
211-
if kids.len() > 1 {
212-
anyhow::bail!("Multi-signature document is currently unsupported");
213-
}
211+
use itertools::Itertools as _;
214212

215213
let [kid] = kids else {
216-
anyhow::bail!("Multi-signature document is currently unsupported");
214+
anyhow::bail!(
215+
"Must have only one signature. Multi-signature document is currently unsupported. kids: [{}]",
216+
kids.iter().map(ToString::to_string).join(",")
217+
);
217218
};
218219

219220
if kid != token.catalyst_id() {

catalyst-gateway/docker-compose.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,9 @@ services:
5757
- CHAIN_NETWORK=Preprod
5858
- SIGNED_DOC_SK=0x6455585b5dcc565c8975bc136e215d6d4dd96540620f37783c564da3cb3686dd
5959
- INTERNAL_API_KEY=123
60+
# cspell: disable
61+
- SIGNED_DOC_ADMIN_KEYS=admin.catalyst://preprod.cardano/0KGVpkXVe5-h1RfIb08Mnc-xMZTzSX5VVnPDaHvhrqQ/0/10
62+
# cspell: enable
6063
# - LOG_LEVEL=error
6164
# - RUST_LOG="error,cat_gateway=debug,cardano_chain_follower=debug,mithril-client=debug"
6265
ports:

catalyst-gateway/event-db/seed/test_signed_documents.sql

Lines changed: 0 additions & 32 deletions
This file was deleted.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
3.14.0rc1

catalyst-gateway/tests/api_tests/Earthfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
VERSION 0.8
22

33
IMPORT github.com/input-output-hk/catalyst-ci/earthly/python:v3.6.3 AS python-ci
4-
IMPORT github.com/input-output-hk/catalyst-libs/rust:catalyst-signed-doc/v0.0.8 AS cat-libs-rust
4+
IMPORT github.com/input-output-hk/catalyst-libs/rust:catalyst-signed-doc/v0.0.10 AS cat-libs-rust
55
IMPORT github.com/input-output-hk/catalyst-libs/rust:catalyst-signed-doc/v.0.0.4-fix-earthly-build AS dep-cat-libs-rust
66
IMPORT github.com/input-output-hk/catalyst-storage AS cat-storage
77

catalyst-gateway/tests/api_tests/integration/signed_doc/test_signed_doc.py

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,25 @@
22
from utils import uuid_v7
33
from api.v1 import document as document_v1
44
from api.v2 import document as document_v2
5-
from utils.rbac_chain import rbac_chain_factory
5+
from utils.rbac_chain import rbac_chain_factory, RoleID
6+
from utils.admin import admin_key
67
from utils.signed_doc import (
78
proposal_doc_factory,
9+
proposal_form_template_doc,
10+
category_parameters_doc,
11+
category_parameters_form_template_doc,
12+
campaign_parameters_doc,
13+
campaign_parameters_form_template_doc,
14+
brand_parameters_doc,
15+
brand_parameters_form_template_doc,
816
)
917

1018

1119
@pytest.mark.preprod_indexing
1220
def test_document_put_and_get_endpoints(proposal_doc_factory, rbac_chain_factory):
13-
(proposal_doc, role_id) = proposal_doc_factory()
1421
rbac_chain = rbac_chain_factory()
22+
role_id = RoleID.PROPOSER
23+
proposal_doc = proposal_doc_factory(role_id)
1524
(cat_id, sk_hex) = rbac_chain.cat_id_for_role(role_id)
1625
proposal_doc_id = proposal_doc.metadata["id"]
1726

@@ -55,7 +64,7 @@ def test_document_put_and_get_endpoints(proposal_doc_factory, rbac_chain_factory
5564

5665
# Put a non valid document with same ID different content
5766
invalid_doc = proposal_doc.copy()
58-
invalid_doc.content["setup"]["title"]["title"] = "another title"
67+
invalid_doc.content["setup"]["title"] = {"title": "another title"}
5968
resp = document_v1.put(
6069
data=invalid_doc.build_and_sign(cat_id, sk_hex),
6170
token=rbac_chain.auth_token(),
@@ -82,7 +91,8 @@ def test_document_index_endpoint(
8291
proposal_doc_factory,
8392
rbac_chain_factory,
8493
):
85-
(doc, role_id) = proposal_doc_factory()
94+
role_id = RoleID.PROPOSER
95+
doc = proposal_doc_factory(role_id)
8696

8797
rbac_chain = rbac_chain_factory()
8898
(cat_id, sk_hex) = rbac_chain.cat_id_for_role(role_id)

catalyst-gateway/tests/api_tests/integration/signed_doc/test_v1_signed_doc.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -272,7 +272,7 @@ def deprecated_proposal(rbac_chain):
272272
"ver": "0194d490-30bf-7473-81c8-a0eaef369619",
273273
},
274274
}
275-
with open("./test_data/signed_docs/proposal.json", "r") as json_file:
275+
with open("./test_data/signed_docs/proposal.deprecated.json", "r") as json_file:
276276
content = json.load(json_file)
277277

278278
doc = SignedDocumentV1(proposal_metadata_json, content)
@@ -300,7 +300,7 @@ def deprecated_comment(rbac_chain, proposal_id):
300300
"ver": "0194d494-4402-7e0e-b8d6-171f8fea18b0",
301301
},
302302
}
303-
with open("./test_data/signed_docs/comment.json", "r") as json_file:
303+
with open("./test_data/signed_docs/comment.deprecated.json", "r") as json_file:
304304
content = json.load(json_file)
305305

306306
doc = SignedDocumentV1(comment_metadata_json, content)
@@ -323,7 +323,7 @@ def deprecated_proposal_submission(rbac_chain, proposal_id):
323323
"ver": proposal_id,
324324
},
325325
}
326-
with open("./test_data/signed_docs/submission_action.json", "r") as json_file:
326+
with open("./test_data/signed_docs/submission_action.deprecated.json", "r") as json_file:
327327
content = json.load(json_file)
328328

329329
doc = SignedDocumentV1(sub_action_metadata_json, content)

0 commit comments

Comments
 (0)