IntersectMBO / govtool

🔩 GovTool and utilities monorepo.
https://preview.gov.tools
Apache License 2.0
10 stars 7 forks source link

Provide metadata validation to the proposal list and on the GA creation #876

Open MSzalowski opened 4 months ago

MSzalowski commented 4 months ago
  1. Provide new POST endpoint that would accept metadat url and hash and return the status of the validation. Example payload:
    {
    "url": "http://example.metadata.url",
    "hash": "some-example-blake2b-256-hash",
    }

    Example response:

If validation passes for all the cases response can be any eg.: { "valid": true }

  1. Extend existing endpoints of such validation.

Provide to: GET /proposal/list GET /proposal/get/{proposalId} GET /drep/getVotes/{drepId}

pmbinapps commented 3 months ago

Still blocked to check on dev-sancho and test-sancho env:

Blocked by: [

Image ](https://github.com/IntersectMBO/govtool/issues/1011)

https://github.com/IntersectMBO/govtool/issues/1015

pmbinapps commented 3 months ago

OK Adding proposal NOT OK - showing proposals - tracked here

pmbinapps commented 3 months ago
OK,  TBC - response ok, status ok, for case: URL ok, hash ok, expected: 200, status: None - NOT STATUS FOR CORRECT STATE 
Inputs:
 {
    "url": "https://raw.githubusercontent.com/mpawel79/testrepo/master/InfoJune03.jsonld",
    "hash": "eebfff0e2213ff0c5331e6d9d99d47a5a825dce7053671b6ed4daae4b4e0df5e"
}
Response code: 200
{
    "status": null,
    "valid": false,
    "raw": {
        "metadata": {
            "abstract": "test",
            "motivation": "test",
            "rationale": "test",
            "references": [
                "https://test.com/"
            ],
            "title": "test"
        },
        "valid": true
    }
}
--------------------

OK - response ok, status ok, for case: URL ok, corrupted hash aa: expected: INCORRECT_HASH 
Inputs:
 {
    "url": "https://raw.githubusercontent.com/mpawel79/testrepo/master/InfoJune03.jsonld",
    "hash": "aabfff0e2213ff0c5331e6d9d99d47a5a825dce7053671b6ed4daae4b4e0df5e"
}
Response code: 200
{
    "status": null,
    "valid": false,
    "raw": {
        "metadata": {
            "abstract": "test",
            "motivation": "test",
            "rationale": "test",
            "references": [
                "https://test.com/"
            ],
            "title": "test"
        },
        "status": "INVALID_HASH",
        "valid": false
    }
}
--------------------

OK - response ok, status ok, for case: URL ok, empty hash, expected: INCORRECT_HASH
Inputs:
 {
    "url": "https://raw.githubusercontent.com/mpawel79/testrepo/master/InfoJune03.jsonld",
    "hash": ""
}
Response code: 200
{
    "status": null,
    "valid": false,
    "raw": {
        "metadata": {
            "abstract": "test",
            "motivation": "test",
            "rationale": "test",
            "references": [
                "https://test.com/"
            ],
            "title": "test"
        },
        "status": "INVALID_HASH",
        "valid": false
    }
}
--------------------

OK - response ok, status ok, for case: URL to not existing file, hash ok: expected: URL_NOT_FOUND
Inputs:
 {
    "url": "https://raw.githubusercontent.com/mpawel79/testrepo/master/NOT_EXISTS.jsonld",
    "hash": "eebfff0e2213ff0c5331e6d9d99d47a5a825dce7053671b6ed4daae4b4e0df5e"
}
Response code: 200
{
    "status": null,
    "valid": false,
    "raw": {
        "status": "URL_NOT_FOUND",
        "valid": false
    }
}
--------------------

OK - response not ok, status ok, for case: Empty URL, empty hash, expected: response - an error code
Inputs:
 {
    "url": "",
    "hash": ""
}
Response code: 200
{
    "status": null,
    "valid": false,
    "raw": {
        "status": "URL_NOT_FOUND",
        "valid": false
    }
}
--------------------

Below tracked in issue https://github.com/IntersectMBO/govtool/issues/1150:

NOT OK, TBC - response is 200, status is null but hash is not for provied json, for case: URL to other json (drep format), hash ok - expected: INCORRECT_JSONLD
Inputs:
 {
    "url": "https://github.com/mpawel79/testrepo/blob/master/PawelDrep.jsonld",
    "hash": "eebfff0e2213ff0c5331e6d9d99d47a5a825dce7053671b6ed4daae4b4e0df5e"
}
Response code: 200
{
    "status": null,
    "valid": false,
    "raw": {
        "valid": true
    }
}
--------------------

NOT OK - response not ok, status not ok, for case: valid URL to corrupted json, hash ok - expected: INCORRECT_JSONLD
Inputs:
 {
    "url": "https://raw.githubusercontent.com/mpawel79/testrepo/master/test_INVALID_JSON_FORMAT.jsonld",
    "hash": "eebfff0e2213ff0c5331e6d9d99d47a5a825dce7053671b6ed4daae4b4e0df5e"
}
Response code: 200
{
    "status": null,
    "valid": false,
    "raw": {
        "valid": true
    }
}
--------------------

NOT OK - response ok, status not given - some other error msg, for INCORRECT_HASH not resturned,  URL ok, corrupted hash to long: expected: INCORRECT_HASH
Inputs:
 {
    "url": "https://raw.githubusercontent.com/mpawel79/testrepo/master/InfoJune03.jsonld",
    "hash": "CORRUPTED_eebfff0e2213ff0c5331e6d9d99d47a5a825dce7053671b6ed4daae4b4e0df5e"
}
Response code: 400
{
    "combinator": "ReqBody'",
    "error": "Error in $.hash: mzero"
}
--------------------

Click to add a cell.

OK - no error 500 was returned

TBC - status - for postive case - nothing returned when all is fine