Skip to content

Commit

Permalink
Make vin numbers to be VIN regex complaint (#261)
Browse files Browse the repository at this point in the history
* Fix VIN

* add permissions pull request write

---------

Co-authored-by: Roshan Piyush <piyush.roshan@gmail.com>
  • Loading branch information
soujanyanmbri and piyushroshan authored Aug 20, 2024
1 parent ea1ec87 commit d52e1d4
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 10 deletions.
10 changes: 5 additions & 5 deletions .github/workflows/pr-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -147,10 +147,10 @@ jobs:
- name: Cleanup docker before running
if: always()
continue-on-error: true
run: docker-compose -f deploy/docker/docker-compose.yml down --volumes --remove-orphans
run: docker compose -f deploy/docker/docker-compose.yml down --volumes --remove-orphans

- name: Run crAPI using built images
run: VERSION=${{ env.TAG_NAME }} docker-compose -f deploy/docker/docker-compose.yml --compatibility up -d
run: VERSION=${{ env.TAG_NAME }} docker compose -f deploy/docker/docker-compose.yml --compatibility up -d

- name: Install Node
uses: actions/setup-node@v3
Expand All @@ -169,7 +169,7 @@ jobs:

- name: Cleanup docker
if: always()
run: docker-compose -f deploy/docker/docker-compose.yml down --volumes --remove-orphans
run: docker compose -f deploy/docker/docker-compose.yml down --volumes --remove-orphans


tests:
Expand All @@ -196,7 +196,7 @@ jobs:
go-version: '1.21'

- name: Start the database
run: docker-compose -f services/docker-database.yml up -d
run: docker compose -f services/docker-database.yml up -d

- name: Run identity tests
run: |
Expand Down Expand Up @@ -250,7 +250,7 @@ jobs:
coverage xml -o coverage.xml
- name: Publish Coverage for workshop
uses: orgoro/coverage@v3.1
uses: orgoro/coverage@v3.2
with:
coverageFile: services/workshop/coverage.xml
token: ${{ secrets.GITHUB_TOKEN }}
Expand Down
15 changes: 11 additions & 4 deletions services/identity/src/main/java/com/crapi/utils/GenerateVIN.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

public class GenerateVIN {

static String charsequence = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
static String charsequence = "ABCDEFGHJKLMNPRSTUVWXYZ"; // I, O, Q are excluded
static String num = "0123456789";
String vin = "";
String pincode = "";
Expand All @@ -38,10 +38,17 @@ public String generatePincode() {
return pincode;
}

/** @return rendom generate VIN for vehicle */
/** @return randomly generated VIN */
public String generateVIN() {
vin += getNum(0) + getChar(3) + getNum(1) + getChar(3) + getNum(5);
return vin;
StringBuilder vin = new StringBuilder();
for (int i = 0; i < 17; i++) {
if (random.nextBoolean()) {
vin.append(randomCharacter());
} else {
vin.append(randomNumber());
}
}
return vin.toString();
}

public String getChar(int num) {
Expand Down
2 changes: 1 addition & 1 deletion services/web/src/constants/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,4 @@ export const PASSWORD_VALIDATION =
/^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[#$@!%&*?])[A-Za-z\d#$@!%&*?]{8,16}$/;
export const NAME_VALIDATION = /^[a-zA-Z ]+$/;
export const PIN_CODE_VALIDATION = /^[0-9]{4}$/;
export const VIN_VALIDATION = /^[0-9][A-Z]{4}[0-9]{2}[A-Z]{4}[0-9]{6}$/;
export const VIN_VALIDATION = /^[A-HJ-NPR-Z0-9]{17}$/;

0 comments on commit d52e1d4

Please sign in to comment.