From 44cfd59c9a1c2df4c8569ec623ca186c4fe2cbac Mon Sep 17 00:00:00 2001 From: simonredfern Date: Sun, 21 Dec 2025 22:49:55 +0100 Subject: [PATCH] test h2 db file clear at run_all_tests 2 --- CONTRIBUTING.md | 46 +++++++++++++++++++++++++++++++++++----------- run_all_tests.sh | 4 ++-- 2 files changed, 37 insertions(+), 13 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 6ff9234e4..c21d8c5ac 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -1,19 +1,32 @@ # Contributing - ## Hello! -Thank you for your interest in contributing to the Open Bank Project! +## Coding Standards + +### Character Encoding + +- **Use UTF-8 encoding** for all source files +- **DO NOT use emojis** in source code (scripts, Scala, Java, config files, etc.) +- **Emojis are only allowed in Markdown (.md) files** - use them if you must. +- **Avoid non-ASCII characters** in code unless absolutely necessary (e.g., comments in non-English languages) +- Use plain ASCII alternatives in source code: + - Instead of checkmark use [OK] or PASS + - Instead of X mark use [FAIL] or ERROR + - Instead of multiply use x + - Instead of arrow use -> or <- + Thank you for your interest in contributing to the Open Bank Project! ## Pull requests -If submitting a pull request please read and sign our [CLA](http://github.com/OpenBankProject/OBP-API/blob/develop/Harmony_Individual_Contributor_Assignment_Agreement.txt) first. +If submitting a pull request please read and sign our [CLA](http://github.com/OpenBankProject/OBP-API/blob/develop/Harmony_Individual_Contributor_Assignment_Agreement.txt) first. In the first instance it is sufficient if you create a text file of the CLA with your name and include that in a git commit description. -If you end up making large changes to the source code, we might ask for a paper signed copy of your CLA sent by email to contact@tesobe.com +If you end up making large changes to the source code, we might ask for a paper signed copy of your CLA sent by email to contact@tesobe.com ## Git commit messages Please structure git commit messages in a way as shown below: + 1. bugfix/Something 2. feature/Something 3. docfix/Something @@ -89,6 +102,7 @@ When naming variables use strict camel case e.g. use myUrl not myURL. This is so } } ``` + ### Recommended order of checks at an endpoint ```scala @@ -98,30 +112,34 @@ When naming variables use strict camel case e.g. use myUrl not myURL. This is so for { // 1. makes sure the user which attempts to use the endpoint is authorized (Full(u), callContext) <- authorizedAccess(cc) - // 2. makes sure the user which attempts to use the endpoint is allowed to consume it + // 2. makes sure the user which attempts to use the endpoint is allowed to consume it _ <- NewStyle.function.hasAtLeastOneEntitlement(failMsg = createProductEntitlementsRequiredText)(bankId.value, u.userId, createProductEntitlements, callContext) // 3. checks the endpoint constraints (_, callContext) <- NewStyle.function.getBank(bankId, callContext) failMsg = s"$InvalidJsonFormat The Json body should be the $PostPutProductJsonV310 " ... ``` + Please note that that checks at an endpoint should be applied only in case an user is authorized and has privilege to consume the endpoint. Otherwise we can reveal sensitive data to the user. For instace if we reorder the checks in next way: + ```scala // 1. makes sure the user which attempts to use the endpoint is authorized (Full(u), callContext) <- authorizedAccess(cc) // 3. checks the endpoint constraints (_, callContext) <- NewStyle.function.getBank(bankId, callContext) - failMsg = s"$InvalidJsonFormat The Json body should be the $PostPutProductJsonV310 " + failMsg = s"$InvalidJsonFormat The Json body should be the $PostPutProductJsonV310 " (Full(u), callContext) <- authorizedAccess(cc) - // 2. makes sure the user which attempts to use the endpoint is allowed to consume it - _ <- NewStyle.function.hasAtLeastOneEntitlement(failMsg = createProductEntitlementsRequiredText)(bankId.value, u.userId, createProductEntitlements, callContext) + // 2. makes sure the user which attempts to use the endpoint is allowed to consume it + _ <- NewStyle.function.hasAtLeastOneEntitlement(failMsg = createProductEntitlementsRequiredText)(bankId.value, u.userId, createProductEntitlements, callContext) ``` + the user which cannot consume the endpoint still can check does some bank exist or not at that instance. It's not the issue if banks are public data at the instance but it wouldn't be the only business case all the time. ## Writing tests When you write a test for an endpoint please tag it with a version and the endpoint. An example of how to tag tests: + ```scala class FundsAvailableTest extends V310ServerSetup { @@ -152,10 +170,11 @@ class FundsAvailableTest extends V310ServerSetup { } } -``` +``` ## Code Generation -We support to generate the OBP-API code from the following three types of json. You can choose one of them as your own requirements. + +We support to generate the OBP-API code from the following three types of json. You can choose one of them as your own requirements. 1 Choose one of the following types: type1 or type2 or type3 2 Modify the json file your selected, for now, we only support these three types: String, Double, Int. other types may throw the exceptions @@ -163,19 +182,24 @@ We support to generate the OBP-API code from the following three types of json. 4 Run/Restart OBP-API project. 5 Run API_Exploer project to test your new APIs. (click the Tag `APIBuilder B1) -Here are the three types: +Here are the three types: Type1: If you use `modelSource.json`, please run `APIBuilderModel.scala` main method + ``` /OBP-API/obp-api/src/main/resources/apiBuilder/APIModelSource.json /OBP-API/obp-api/src/main/scala/code/api/APIBuilder/APIBuilderModel.scala ``` + Type2: If you use `apisResource.json`, please run `APIBuilder.scala` main method + ``` /OBP-API/obp-api/src/main/resources/apiBuilder/apisResource.json OBP-API/src/main/scala/code/api/APIBuilder/APIBuilder.scala ``` + Type3: If you use `swaggerResource.json`, please run `APIBuilderSwagger.scala` main method + ``` /OBP-API/obp-api/src/main/resources/apiBuilder/swaggerResource.json OBP-API/src/main/scala/code/api/APIBuilder/APIBuilderSwagger.scala diff --git a/run_all_tests.sh b/run_all_tests.sh index 481d591ab..958b9d33f 100755 --- a/run_all_tests.sh +++ b/run_all_tests.sh @@ -178,7 +178,7 @@ display_warning_factors() { fi # Format with count prominence - printf " ${YELLOW}%4d ×${NC} %s\n" "$count" "$message" | tee -a "${SUMMARY_LOG}" > /dev/tty + printf " ${YELLOW}%4d x${NC} %s\n" "$count" "$message" | tee -a "${SUMMARY_LOG}" > /dev/tty displayed=$((displayed + 1)) done < "${analysis_file}" @@ -252,7 +252,7 @@ for dbfile in "${TEST_DB_PATTERNS[@]}"; do if [ -f "$dbfile" ]; then FOUND_FILES=true rm -f "$dbfile" - log_message " ${GREEN}✓${NC} Deleted: $dbfile" + log_message " ${GREEN}[OK]${NC} Deleted: $dbfile" fi done