diff --git a/.github/vva-be-config.json b/.github/backend-config.json similarity index 92% rename from .github/vva-be-config.json rename to .github/backend-config.json index 9b3329863..d2ffd89d9 100644 --- a/.github/vva-be-config.json +++ b/.github/backend-config.json @@ -8,7 +8,7 @@ }, "fakedbsyncconfig" : { "host" : "localhost", - "dbname" : "vva", + "dbname" : "govtool", "user" : "postgres", "password" : "MTnk8lsuMM41RgAh1y2WTAUdObsb", "port" : 5432 diff --git a/.github/workflows/build-and-deploy.yml b/.github/workflows/build-and-deploy.yml index d8bb9a60a..7fef12726 100644 --- a/.github/workflows/build-and-deploy.yml +++ b/.github/workflows/build-and-deploy.yml @@ -117,7 +117,7 @@ jobs: DBSYNC_POSTGRES_DB: "cexplorer" DBSYNC_POSTGRES_USER: "postgres" DBSYNC_POSTGRES_PASSWORD: "pSa8JCpQOACMUdGb" - FAKEDBSYNC_POSTGRES_DB: "vva" + FAKEDBSYNC_POSTGRES_DB: "govtool" FAKEDBSYNC_POSTGRES_USER: "test" FAKEDBSYNC_POSTGRES_PASSWORD: "test" GRAFANA_ADMIN_PASSWORD: ${{ secrets.GRAFANA_ADMIN_PASSWORD }} @@ -125,7 +125,7 @@ jobs: GRAFANA_SLACK_OAUTH_TOKEN: ${{ secrets.GRAFANA_SLACK_OAUTH_TOKEN }} NGINX_BASIC_AUTH: ${{ secrets.NGINX_BASIC_AUTH }} SENTRY_DSN_BACKEND: ${{ secrets.SENTRY_DSN_BACKEND }} - TRAEFIK_LE_EMAIL: "admin+vva@binarapps.com" + TRAEFIK_LE_EMAIL: "admin+govtool@binarapps.com" steps: - name: Checkout code uses: actions/checkout@v3 @@ -191,7 +191,7 @@ jobs: DBSYNC_POSTGRES_DB: "cexplorer" DBSYNC_POSTGRES_USER: "postgres" DBSYNC_POSTGRES_PASSWORD: "pSa8JCpQOACMUdGb" - FAKEDBSYNC_POSTGRES_DB: "vva" + FAKEDBSYNC_POSTGRES_DB: "govtool" FAKEDBSYNC_POSTGRES_USER: "test" FAKEDBSYNC_POSTGRES_PASSWORD: "test" GRAFANA_ADMIN_PASSWORD: ${{ secrets.GRAFANA_ADMIN_PASSWORD }} @@ -199,7 +199,7 @@ jobs: GRAFANA_SLACK_OAUTH_TOKEN: ${{ secrets.GRAFANA_SLACK_OAUTH_TOKEN }} NGINX_BASIC_AUTH: ${{ secrets.NGINX_BASIC_AUTH }} SENTRY_DSN_BACKEND: ${{ secrets.SENTRY_DSN_BACKEND }} - TRAEFIK_LE_EMAIL: "admin+vva@binarapps.com" + TRAEFIK_LE_EMAIL: "admin+govtool@binarapps.com" steps: - name: Checkout code uses: actions/checkout@v3 diff --git a/.github/workflows/frontend_sonar_scan.yml b/.github/workflows/frontend_sonar_scan.yml index b69841c63..8a4df29ab 100644 --- a/.github/workflows/frontend_sonar_scan.yml +++ b/.github/workflows/frontend_sonar_scan.yml @@ -8,7 +8,7 @@ on: jobs: execute_sonar_scanner: - name: Execute sonar-scanner on vva-fe + name: Execute sonar-scanner on govtool frontend runs-on: ubuntu-latest permissions: read-all steps: @@ -26,4 +26,4 @@ jobs: # - uses: sonarsource/sonarqube-quality-gate-action@master # timeout-minutes: 5 # env: - # SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} \ No newline at end of file + # SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} diff --git a/.github/workflows/lighthouse.yml b/.github/workflows/lighthouse.yml index 9d39d1707..19c0047e4 100644 --- a/.github/workflows/lighthouse.yml +++ b/.github/workflows/lighthouse.yml @@ -16,7 +16,7 @@ jobs: - uses: actions/setup-node@v3 with: node-version: 16 - + - name: Install dependencies run: npm install working-directory: ./govtool/frontend @@ -27,7 +27,7 @@ jobs: with: path: | ~/.npm - key: ${{ runner.os }}-npm-${{ hashFiles('govtool/frontend/package-lock.json', 'tests/vva-fe/package-lock.json') }} + key: ${{ runner.os }}-npm-${{ hashFiles('govtool/frontend/package-lock.json', 'tests/govtool-frontend/package-lock.json') }} restore-keys: | ${{ runner.os }}-npm- @@ -45,7 +45,6 @@ jobs: run: | lhci assert --preset "lighthouse:recommended" - - name: Publish reports working-directory: ./govtool/frontend if: github.repository_owner == 'IntersectMBO' @@ -56,4 +55,4 @@ jobs: -d "@./lighthouseci/$(ls ./.lighthouseci |grep 'lhr.*\.json' | head -n 1)" \ -H "commit-hash: $(git rev-parse HEAD)" \ -H "secret-token: ${{ secrets.METRICS_SERVER_SECRET_TOKEN }}" \ - -H 'Content-Type: application/json' || echo "Metric Upload error ignored ..." \ No newline at end of file + -H 'Content-Type: application/json' || echo "Metric Upload error ignored ..." diff --git a/.github/workflows/test_backend.yml b/.github/workflows/test_backend.yml index 1a3a198d3..125666f2a 100644 --- a/.github/workflows/test_backend.yml +++ b/.github/workflows/test_backend.yml @@ -4,8 +4,8 @@ on: push: paths: - .github/workflows/test_backend.yml - # - src/vva-be - # - tests/vva-be + # - govtool/backend + # - tests/govtool-backend schedule: - cron: '0 0 * * *' @@ -18,7 +18,7 @@ on: options: - "sanchogov.tools/api" - "staging.govtool.byron.network/api" - - "vva-sanchonet.cardanoapi.io/api" + - "govtool-sanchonet.cardanoapi.io/api" jobs: build: @@ -26,7 +26,7 @@ jobs: steps: - name: Checkout code uses: actions/checkout@v4 - + - name: Set up Python uses: actions/setup-python@v4 with: @@ -34,7 +34,7 @@ jobs: cache: 'pip' - name: Run Backend Test - working-directory: tests/vva-be + working-directory: tests/govtool-backend run: | python -m pip install --upgrade pip pip install -r requirements.txt diff --git a/.github/workflows/test_integration_cypress.yml b/.github/workflows/test_integration_cypress.yml index d2c0b8cfc..a0fbf9011 100644 --- a/.github/workflows/test_integration_cypress.yml +++ b/.github/workflows/test_integration_cypress.yml @@ -22,13 +22,13 @@ on: options: - "sanchogov.tools" - "staging.govtool.byron.network" - - "vva-sanchonet.cardanoapi.io" + - "govtool-sanchonet.cardanoapi.io" jobs: cypress-tests: defaults: run: - working-directory: ./tests/vva-fe + working-directory: ./tests/govtool-frontend runs-on: ubuntu-latest env: NODE_OPTIONS: --max_old_space_size=4096 @@ -50,7 +50,7 @@ jobs: path: | ${{ steps.yarn-cache-dir-path.outputs.dir }} key: - ${{ runner.os }}-yarn-${{hashFiles('tests/vva-fe/yarn.lock') }} + ${{ runner.os }}-yarn-${{hashFiles('tests/govtool-frontend/yarn.lock') }} restore-keys: | ${{ runner.os }}-yarn- @@ -58,7 +58,7 @@ jobs: uses: cypress-io/github-action@v6 with: record: true - working-directory: ./tests/vva-fe + working-directory: ./tests/govtool-frontend env: CYPRESS_RECORD_KEY: ${{ secrets.CYPRESS_RECORD_KEY }} # pass GitHub token to allow accurately detecting a build vs a re-run build @@ -69,4 +69,3 @@ jobs: CYPRESS_kuberApiKey: ${{secrets.KUBER_API_KEY}} CYPRESS_faucetApiUrl: https://faucet.${{inputs.network || 'sanchonet'}}.world.dev.cardano.org CYPRESS_faucetApiKey: ${{ secrets.FAUCET_API_KEY }} - \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md index 6c21fa0e8..ac8e9ea7f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,6 +13,7 @@ changes. - i18next library added to FE [Issue 80](https://github.com/IntersectMBO/govtool/issues/80) ### Fixed +- Fix misleading metadata hash text [Issue 90](https://github.com/IntersectMBO/govtool/issues/90) - Fixed vote calculation problems related to NoConfidence DRep [Issue 59](https://github.com/IntersectMBO/govtool/issues/59) - Fixed ada-holder/get-current-delegation error when delegated to NoConfidence or AlwaysAbstain dreps. [Issue 82](https://github.com/IntersectMBO/govtool/issues/82) diff --git a/README.md b/README.md index 02baca95e..ab338a3f3 100644 --- a/README.md +++ b/README.md @@ -21,8 +21,8 @@ The SanchoNet GovTool is currently open for beta testing and can be accessed at Learn more; [docs.sanchogov.tools](https://docs.sanchogov.tools/). ## 📍 Navigation -- [GovTool Backend](./src/vva-be/README.md) -- [GovTool Frontend](./src/vva-fe/README.md) +- [GovTool Backend](./govtool/backend/README.md) +- [GovTool Frontend](./govtool/frontend/README.md) - [Documentation](./docs/) - [Tests](./tests/) @@ -45,4 +45,4 @@ Frontend is able to connect to Cardano wallets over the [CIP-30](https://github. ## 🤝 Contributing Thanks for considering contributing and helping us on creating GovTool! 😎 -Please checkout our [Contributing Documentation](./CONTRIBUTING.md). \ No newline at end of file +Please checkout our [Contributing Documentation](./CONTRIBUTING.md). diff --git a/docs/operations/DEPLOY.md b/docs/operations/DEPLOY.md index 3270ecb19..2f75566f3 100644 --- a/docs/operations/DEPLOY.md +++ b/docs/operations/DEPLOY.md @@ -20,7 +20,7 @@ AWS is configured with Terraform, but the account needs to be bootstrapped befor This has to be done only once per AWS account. 1. Configure AWS CLI with `aws configure` (if you are using a configuration profile, use `aws --profile MYPROFILE configure` and then `export AWS_PROFILE=MYPROFILE`). -1. Execute `./src/terraform/bootstrap-aws-account.sh` script. +1. Execute `./infra/terraform/bootstrap-aws-account.sh` script. ### Infrastructure setup @@ -29,7 +29,7 @@ This has to be done only once per AWS account. 1. Run `terraform plan` to view changes that would be performed to infrastructure. 1. Take note of the outputs - they contain ECR repo URLs and app domains. -Note: the Terraform code configures the EC2 instance using `src/terraform/modules/vva-ec2/user_data.sh`. This script is only executed on instance creation. +Note: the Terraform code configures the EC2 instance using `infra/terraform/modules/govtool-ec2/user_data.sh`. This script is only executed on instance creation. ## Application deployment @@ -52,3 +52,19 @@ Alternatively you can type `make all instance=$INSTANCE cardano_network=$CARDANO View the app at `https://${ENVIRONMENT}-${INSTANCE}.govtool.byron.network`. Keep in mind that after initial deployment on a new environment, it will take some time for the Cardano node to get in sync. + +## Aftermatch + +After performing a deploy from a local machine, it is crucial to carefully track +the application's accessibility and functionality to ensure no unintended +changes, such as the accidental activation of BasicAuth[^1], have occurred. + +Additionally, verifying that all configuration files and environment variables, +particularly those related to environment-specific settings like database +connections or external service endpoints, are correctly generated and applied +is essential for maintaining the intended behavior of the application across +different environments. This includes a thorough check of environment variables +to confirm they are correctly set and aligned with the specific needs of the +deployed environment. + +[^1]: https://github.com/IntersectMBO/govtool/discussions/174 diff --git a/govtool/backend/README.md b/govtool/backend/README.md index ae36a75b9..4f6211a41 100644 --- a/govtool/backend/README.md +++ b/govtool/backend/README.md @@ -3,7 +3,7 @@ This is a backend application of GovTool project. ## Prerequisites -In order to run `vva-be` your host machine will need access to the `cardano-db-sync` postgres database. To have this database running locally you'll need: +In order to run `backend` your host machine will need access to the `cardano-db-sync` postgres database. To have this database running locally you'll need: * `cardano-node` * `cardano-db-sync` * PostgreSQL database @@ -24,10 +24,10 @@ Due to problems with openapi3 package it's hard to build this project with plain 1. Get [Nix](https://nixos.org/download). -2. Enter `src/vva-be` directory: +2. Enter `govtool/backend` directory: ```sh - cd src/vva-be + cd govtool/backend ``` 3. Allow broken nix packages @@ -54,3 +54,5 @@ Due to problems with openapi3 package it's hard to build this project with plain ```sh cabal run vva-be -- --config start-app ``` +> [!WARNING] +> In the context of our ongoing project enhancements, it is assumed that the executable previously known as 'vva-be' should be now officially renamed to 'govtool-backend'. This change is necessary for aligning with the updated branding and functional scope of the application and it has to be implemented in the near future as a chore and refactoring ticket. Make sure that the documentation matches the actual name of the executable. diff --git a/govtool/frontend/README.md b/govtool/frontend/README.md index 5d30306e4..d8ace9d3b 100644 --- a/govtool/frontend/README.md +++ b/govtool/frontend/README.md @@ -1,4 +1,4 @@ -# Voltaire GovTool Frontend +# GovTool Frontend Installed on your machine: @@ -16,7 +16,7 @@ Fill .env based on env.example file Go to the project directory ```bash - cd voltaire-era/src/vva-fe + cd voltaire-era/govtool/frontend ``` Install dependencies @@ -47,10 +47,10 @@ yarn dev 1. Get [Nix](https://nixos.org/download). -2. Enter `src/vva-fe` directory: +2. Enter `govtool/frontend` directory: ```sh -cd src/vva-fe +cd govtool/frontend ``` 3. Run `nix-shell` @@ -75,13 +75,13 @@ Install [`direnv`](https://direnv.net/): nix-env -i direnv ``` -Allow direnv configuration in `src/vva-fe`: +Allow direnv configuration in `govtool/frontend`: ```sh -direnv allow src/vva-fe +direnv allow govtool/frontend ``` -From now on, once you enter the `src/vva-fe` the `nix-shell` with proper +From now on, once you enter the `govtool/frontend` the `nix-shell` with proper configuration will be propagated. ## Developing @@ -128,9 +128,9 @@ npm run dev 1. Get [Nix](https://nixos.org/download). -2. Enter `src/vva-fe` directory: +2. Enter `govtool/frontend` directory: ```sh -cd src/vva-fe +cd govtool/frontend ``` 3. Run `nix-shell` @@ -152,12 +152,12 @@ Install [`direnv`](https://direnv.net/): nix-env -i direnv ``` -Allow direnv configuration in `src/vva-fe`: +Allow direnv configuration in `govtool/frontend`: ```sh -direnv allow src/vva-fe +direnv allow govtool/frontend ``` -From now on, once you enter the `src/vva-fe` the `nix-shell` with proper +From now on, once you enter the `govtool/frontend` the `nix-shell` with proper configuration will be propagated. ### Users diff --git a/govtool/frontend/src/components/atoms/Button.tsx b/govtool/frontend/src/components/atoms/Button.tsx index 49773dd63..97b9f100e 100644 --- a/govtool/frontend/src/components/atoms/Button.tsx +++ b/govtool/frontend/src/components/atoms/Button.tsx @@ -1,14 +1,5 @@ -import { - Button as MUIButton, - ButtonProps as MUIButtonProps, - SxProps, -} from "@mui/material"; - -interface ButtonProps extends Omit { - size?: "small" | "medium" | "large" | "extraLarge"; - variant?: "contained" | "outlined" | "text"; - sx?: SxProps; -} +import { Button as MUIButton } from "@mui/material"; +import { ButtonProps } from "."; export const Button = ({ size = "large", diff --git a/govtool/frontend/src/components/atoms/Input.tsx b/govtool/frontend/src/components/atoms/Input.tsx index f45ea20bd..e5261a112 100644 --- a/govtool/frontend/src/components/atoms/Input.tsx +++ b/govtool/frontend/src/components/atoms/Input.tsx @@ -1,90 +1,30 @@ import { useId } from "react"; -import { Control, Controller } from "react-hook-form"; -import { Box, InputBase, InputBaseProps } from "@mui/material"; +import { InputBase } from "@mui/material"; -import { Typography } from "."; - -interface Props extends InputBaseProps { - control: Control; - formFieldName: string; - label?: string; - errorMessage?: string; - dataTestId?: string; - placeholder?: string; - width?: string; - marginTop?: string; - marginBottom?: string; -} +import { InputProps } from "./types"; export const Input = ({ - control, - formFieldName, errorMessage, - label, - placeholder, - disabled, - type = "text", - width, - marginTop, - marginBottom, dataTestId, + sx, ...rest -}: Props) => { +}: InputProps) => { const id = useId(); return ( - ( - - {label && ( - - {label} - - )} - - - {errorMessage && ( - - {errorMessage} - - )} - - - )} + ); }; diff --git a/govtool/frontend/src/components/atoms/LoadingButton.tsx b/govtool/frontend/src/components/atoms/LoadingButton.tsx index cc89562b8..11a22d56f 100644 --- a/govtool/frontend/src/components/atoms/LoadingButton.tsx +++ b/govtool/frontend/src/components/atoms/LoadingButton.tsx @@ -1,11 +1,6 @@ import { Button, CircularProgress } from "@mui/material"; -import type { ButtonProps, SxProps } from "@mui/material"; -interface Props extends Omit { - isLoading?: boolean; - size?: "small" | "medium" | "large" | "extraLarge"; - sx?: SxProps; -} +import { LoadingButtonProps } from "./types"; export const LoadingButton = ({ isLoading, @@ -14,7 +9,7 @@ export const LoadingButton = ({ size = "large", sx, ...rest -}: Props) => { +}: LoadingButtonProps) => { const buttonHeight = { extraLarge: 48, large: 40, diff --git a/govtool/frontend/src/components/atoms/Spacer.tsx b/govtool/frontend/src/components/atoms/Spacer.tsx new file mode 100644 index 000000000..0c63ad847 --- /dev/null +++ b/govtool/frontend/src/components/atoms/Spacer.tsx @@ -0,0 +1,6 @@ +import { Box } from "@mui/material"; +import { SpacerProps } from "."; + +export const Spacer = ({ x, y }: SpacerProps) => { + return ; +}; diff --git a/govtool/frontend/src/components/atoms/Typography.tsx b/govtool/frontend/src/components/atoms/Typography.tsx index b4ea2b86f..1bcaf6131 100644 --- a/govtool/frontend/src/components/atoms/Typography.tsx +++ b/govtool/frontend/src/components/atoms/Typography.tsx @@ -1,27 +1,5 @@ -import { - Typography as MUITypography, - SxProps, - TypographyProps as MUITypographyProps, -} from "@mui/material"; - -interface TypographyProps - extends Pick { - children?: React.ReactNode; - fontSize?: number; - fontWeight?: 100 | 200 | 300 | 400 | 500 | 600 | 700 | 800 | 900; - variant?: - | "headline1" - | "headline2" - | "headline3" - | "headline4" - | "headline5" - | "title1" - | "title2" - | "body1" - | "body2" - | "caption"; - sx?: SxProps; -} +import { Typography as MUITypography } from "@mui/material"; +import { TypographyProps } from "./types"; export const Typography = ({ color, diff --git a/govtool/frontend/src/components/atoms/index.ts b/govtool/frontend/src/components/atoms/index.ts index 2b3428352..5d03b0752 100644 --- a/govtool/frontend/src/components/atoms/index.ts +++ b/govtool/frontend/src/components/atoms/index.ts @@ -13,12 +13,13 @@ export * from "./modal/ModalWrapper"; export * from "./Radio"; export * from "./ScrollToManage"; export * from "./ScrollToTop"; -export * from "./snackbar/Snackbar"; -export * from "./snackbar/SnackbarMessage"; export * from "./StakeRadio"; export * from "./Tooltip"; export * from "./Typography"; export * from "./VotePill"; export * from "./VotingPowerChips"; export * from "./Input"; +export * from "./Spacer"; export * from "./HighlightedText"; + +export * from "./types"; diff --git a/govtool/frontend/src/components/atoms/snackbar/Snackbar.tsx b/govtool/frontend/src/components/atoms/snackbar/Snackbar.tsx deleted file mode 100644 index b1234c0a8..000000000 --- a/govtool/frontend/src/components/atoms/snackbar/Snackbar.tsx +++ /dev/null @@ -1,39 +0,0 @@ -import type { GrowProps } from "@mui/material/Grow"; -import Grow from "@mui/material/Grow"; -import type { SnackbarProps } from "@mui/material/Snackbar"; -import MuiSnackbar from "@mui/material/Snackbar"; - -import { theme } from "@/theme"; -import type { SnackbarSeverity } from "@models"; - -function GrowTransition(props: GrowProps) { - return ; -} - -interface Props extends SnackbarProps { - severity: SnackbarSeverity; -} - -export function Snackbar({ severity, ...props }: Props) { - return ( - - ); -} diff --git a/govtool/frontend/src/components/atoms/snackbar/SnackbarMessage.tsx b/govtool/frontend/src/components/atoms/snackbar/SnackbarMessage.tsx deleted file mode 100644 index 8c4c34dd9..000000000 --- a/govtool/frontend/src/components/atoms/snackbar/SnackbarMessage.tsx +++ /dev/null @@ -1,49 +0,0 @@ -import { styled } from "@mui/material/styles"; - -import { ICONS } from "@consts"; -import type { SnackbarSeverity } from "@models"; - -interface Props { - message: string; - onClose?: (_event: React.SyntheticEvent | Event, reason?: string) => void; - severity: SnackbarSeverity; -} - -export function SnackbarMessage({ message, severity, onClose }: Props) { - return ( - - {severity === "success" ? ( - - ) : ( - - )} -
{message}
- {onClose && ( - close icon - )} -
- ); -} - -const SnackContainer = styled("span")` - align-items: center; - display: flex; - gap: 8px; - justify-content: space-between; - color: white; - font-weight: 500; - font-size: 14px; - line-height: 24px; - width: 100%; -`; diff --git a/govtool/frontend/src/components/atoms/types.ts b/govtool/frontend/src/components/atoms/types.ts new file mode 100644 index 000000000..4784ad44e --- /dev/null +++ b/govtool/frontend/src/components/atoms/types.ts @@ -0,0 +1,43 @@ +import { + ButtonProps as MUIButtonProps, + InputBaseProps, + TypographyProps as MUITypographyProps, +} from "@mui/material"; + +export type ButtonProps = Omit & { + size?: "small" | "medium" | "large" | "extraLarge"; +}; + +export type LoadingButtonProps = ButtonProps & { + isLoading?: boolean; +}; + +export type TypographyProps = Pick< + MUITypographyProps, + "color" | "lineHeight" | "sx" +> & { + children?: React.ReactNode; + fontSize?: number; + fontWeight?: 100 | 200 | 300 | 400 | 500 | 600 | 700 | 800 | 900; + variant?: + | "headline1" + | "headline2" + | "headline3" + | "headline4" + | "headline5" + | "title1" + | "title2" + | "body1" + | "body2" + | "caption"; +}; + +export type InputProps = InputBaseProps & { + dataTestId?: string; + errorMessage?: string; +}; + +export type SpacerProps = { + x?: number; + y?: number; +}; diff --git a/govtool/frontend/src/components/molecules/Field/Input.tsx b/govtool/frontend/src/components/molecules/Field/Input.tsx new file mode 100644 index 000000000..a99508c3c --- /dev/null +++ b/govtool/frontend/src/components/molecules/Field/Input.tsx @@ -0,0 +1,38 @@ +import { Box } from "@mui/material"; + +import { Input as InputBase, Typography } from "@atoms"; + +import { InputFieldProps } from "./types"; + +export const Input = ({ + errorMessage, + errorStyle, + label, + labelStyle, + layoutStyle, + ...rest +}: InputFieldProps) => { + return ( + + {label && ( + + {label} + + )} + + {errorMessage && ( + + {errorMessage} + + )} + + ); +}; diff --git a/govtool/frontend/src/components/molecules/Field/index.tsx b/govtool/frontend/src/components/molecules/Field/index.tsx new file mode 100644 index 000000000..3589cd9c9 --- /dev/null +++ b/govtool/frontend/src/components/molecules/Field/index.tsx @@ -0,0 +1,17 @@ +import React, { PropsWithChildren } from "react"; + +import { Input } from "./Input"; + +type FieldComposition = React.FC & { + Input: typeof Input; +}; + +const Field: FieldComposition = ({ children }) => { + return {children}; +}; + +Field.Input = Input; + +export { Field }; + +export * from "./types"; diff --git a/govtool/frontend/src/components/molecules/Field/types.ts b/govtool/frontend/src/components/molecules/Field/types.ts new file mode 100644 index 000000000..878f6800f --- /dev/null +++ b/govtool/frontend/src/components/molecules/Field/types.ts @@ -0,0 +1,11 @@ +import { BoxProps } from "@mui/material"; + +import { InputProps, TypographyProps } from "@atoms"; + +export type InputFieldProps = InputProps & { + errorMessage?: string; + errorStyle?: TypographyProps; + label?: string; + labelStyle?: TypographyProps; + layoutStyle?: BoxProps; +}; diff --git a/govtool/frontend/src/components/molecules/VoteActionForm.tsx b/govtool/frontend/src/components/molecules/VoteActionForm.tsx index 446acc9aa..3c1645bd2 100644 --- a/govtool/frontend/src/components/molecules/VoteActionForm.tsx +++ b/govtool/frontend/src/components/molecules/VoteActionForm.tsx @@ -2,12 +2,14 @@ import { useState, useEffect, useMemo, useCallback } from "react"; import { useLocation } from "react-router-dom"; import { Box, Link } from "@mui/material"; -import { Button, Input, LoadingButton, Radio, Typography } from "@atoms"; +import { Button, LoadingButton, Radio, Spacer, Typography } from "@atoms"; import { ICONS } from "@consts"; import { useCardano, useModal } from "@context"; import { useScreenDimension, useVoteActionForm, useTranslation } from "@hooks"; import { openInNewTab } from "@utils"; +import { ControlledField } from "../organisms"; + export const VoteActionForm = ({ voteFromEP, yesVotes, @@ -27,16 +29,16 @@ export const VoteActionForm = ({ const { t } = useTranslation(); const { - setValue, - control, + areFormErrors, + clearErrors, confirmVote, - vote, - registerInput, + control, errors, isDirty, - clearErrors, - areFormErrors, isVoteLoading, + registerInput, + setValue, + vote, } = useVoteActionForm(); useEffect(() => { @@ -199,22 +201,20 @@ export const VoteActionForm = ({
{isContext && ( - - + + diff --git a/govtool/frontend/src/components/molecules/index.ts b/govtool/frontend/src/components/molecules/index.ts index 61171332c..4fc87340a 100644 --- a/govtool/frontend/src/components/molecules/index.ts +++ b/govtool/frontend/src/components/molecules/index.ts @@ -2,6 +2,7 @@ export * from "./ActionCard"; export * from "./DashboardActionCard"; export * from "./DataActionsBar"; export * from "./DRepInfoCard"; +export * from "./Field"; export * from "./GovActionDetails"; export * from "./GovernanceActionCard"; export * from "./GovernanceActionsFilters"; diff --git a/govtool/frontend/src/components/organisms/ControlledField/Input.tsx b/govtool/frontend/src/components/organisms/ControlledField/Input.tsx new file mode 100644 index 000000000..a58d4c91d --- /dev/null +++ b/govtool/frontend/src/components/organisms/ControlledField/Input.tsx @@ -0,0 +1,32 @@ +import { useCallback } from "react"; +import { Controller, get } from "react-hook-form"; + +import { Field } from "@molecules"; + +import { ControlledInputProps, RenderInputProps } from "./types"; + +export const Input = ({ + control, + name, + errors, + rules, + ...props +}: ControlledInputProps) => { + const errorMessage = get(errors, name)?.message as string; + + const renderInput = useCallback( + ({ field }: RenderInputProps) => ( + + ), + [errorMessage, props] + ); + + return ( + + ); +}; diff --git a/govtool/frontend/src/components/organisms/ControlledField/index.tsx b/govtool/frontend/src/components/organisms/ControlledField/index.tsx new file mode 100644 index 000000000..f3b8bbd83 --- /dev/null +++ b/govtool/frontend/src/components/organisms/ControlledField/index.tsx @@ -0,0 +1,15 @@ +import React, { PropsWithChildren } from "react"; + +import { Input } from "./Input"; + +type ControlledFieldComposition = React.FC & { + Input: typeof Input; +}; + +const ControlledField: ControlledFieldComposition = ({ children }) => { + return <>{children}; +}; + +ControlledField.Input = Input; + +export { ControlledField }; diff --git a/govtool/frontend/src/components/organisms/ControlledField/types.ts b/govtool/frontend/src/components/organisms/ControlledField/types.ts new file mode 100644 index 000000000..9f539b279 --- /dev/null +++ b/govtool/frontend/src/components/organisms/ControlledField/types.ts @@ -0,0 +1,20 @@ +import { InputFieldProps } from "@molecules"; +import { + Control, + ControllerRenderProps, + FieldErrors, + FieldValues, + Path, + RegisterOptions, +} from "react-hook-form"; + +export type ControlledInputProps = InputFieldProps & { + name: Path; + control: Control; + errors: FieldErrors; + rules?: Omit; +}; + +export type RenderInputProps = { + field: ControllerRenderProps; +}; diff --git a/govtool/frontend/src/components/organisms/DelegateTodRepStepTwo.tsx b/govtool/frontend/src/components/organisms/DelegateTodRepStepTwo.tsx index 1dcf7caae..f75a3c83d 100644 --- a/govtool/frontend/src/components/organisms/DelegateTodRepStepTwo.tsx +++ b/govtool/frontend/src/components/organisms/DelegateTodRepStepTwo.tsx @@ -1,7 +1,7 @@ import { useMemo } from "react"; import { Box, Link } from "@mui/material"; -import { Button, Input, LoadingButton, Typography } from "../atoms"; +import { Button, LoadingButton, Typography } from "../atoms"; import { useScreenDimension, useDelegateTodRepForm, @@ -9,6 +9,7 @@ import { } from "@hooks"; import { theme } from "@/theme"; import { openInNewTab } from "@utils"; +import { ControlledField } from "."; interface DelegateProps { setStep: (newStep: number) => void; @@ -22,8 +23,13 @@ export const DelegateTodRepStepTwo = ({ setStep }: DelegateProps) => { palette: { boxShadow2 }, } = theme; - const { control, delegate, isDelegateButtonDisabled, isDelegationLoading } = - useDelegateTodRepForm(); + const { + control, + delegate, + errors, + isDelegateButtonDisabled, + isDelegationLoading, + } = useDelegateTodRepForm(); const renderDelegateButton = useMemo(() => { return ( @@ -85,12 +91,11 @@ export const DelegateTodRepStepTwo = ({ setStep }: DelegateProps) => { {t("delegation.dRepIdDescription")} - >; } @@ -91,22 +93,20 @@ export const RegisterAsdRepStepOne = ({ setStep }: Props) => { > {t("registration.descriptionStepOne")} - - + { const navigate = useNavigate(); const { t } = useTranslation(); - const { control, handleSubmit } = useForm(); + const { + control, + formState: { errors }, + handleSubmit, + } = useForm(); const watch = useWatch({ control, @@ -89,9 +93,10 @@ export const useDelegateTodRepForm = () => { return { control, - isDelegateButtonDisabled, delegate: handleSubmit(delegate), - modal, + errors, + isDelegateButtonDisabled, isDelegationLoading: isLoading, + modal, }; }; diff --git a/govtool/frontend/src/i18n/locales/en.ts b/govtool/frontend/src/i18n/locales/en.ts index 876dd71b0..aa6a71f3e 100644 --- a/govtool/frontend/src/i18n/locales/en.ts +++ b/govtool/frontend/src/i18n/locales/en.ts @@ -156,7 +156,7 @@ export const en = { privacyPolicy: "Privacy policy", }, forms: { - hashPlaceholder: "The hash of your URL", + hashPlaceholder: "The hash of metadata at URL", howCreateUrlAndHash: "How to create URL and hash?", urlWithContextPlaceholder: "Your URL with with your context", urlWithInfoPlaceholder: "Your URL with extra info about you", diff --git a/govtool/frontend/src/pages/UpdatedRepMetadata.tsx b/govtool/frontend/src/pages/UpdatedRepMetadata.tsx index 4e45a426b..73df93b0c 100644 --- a/govtool/frontend/src/pages/UpdatedRepMetadata.tsx +++ b/govtool/frontend/src/pages/UpdatedRepMetadata.tsx @@ -2,7 +2,7 @@ import { useMemo, useEffect } from "react"; import { Box, Link } from "@mui/material"; import { useNavigate } from "react-router-dom"; -import { Background, Input, LoadingButton, Button, Typography } from "@atoms"; +import { Background, Button, LoadingButton, Spacer, Typography } from "@atoms"; import { ICONS, PATHS } from "@consts"; import { useCardano } from "@context"; import { @@ -10,7 +10,7 @@ import { useUpdatedRepMetadataForm, useTranslation, } from "@hooks"; -import { DashboardTopNav, Footer } from "@organisms"; +import { ControlledField, DashboardTopNav, Footer } from "@organisms"; import { theme } from "@/theme"; import { WALLET_LS_KEY, getItemFromLocalStorage, openInNewTab } from "@utils"; @@ -117,22 +117,21 @@ export const UpdatedRepMetadata = () => { > {t("metadataUpdate.description")} - - + diff --git a/govtool/frontend/src/stories/Input.stories.tsx b/govtool/frontend/src/stories/Input.stories.tsx index ec9fc4620..cbe95a400 100644 --- a/govtool/frontend/src/stories/Input.stories.tsx +++ b/govtool/frontend/src/stories/Input.stories.tsx @@ -1,38 +1,30 @@ import type { Meta, StoryFn } from "@storybook/react"; -import { Input } from "@atoms"; +import { Field } from "@molecules"; import { ComponentProps } from "react"; import { userEvent, within } from "@storybook/testing-library"; import { expect } from "@storybook/jest"; -import { useUrlAndHashFormController } from "@hooks"; const meta = { title: "Example/Input", - component: Input, + component: Field.Input, parameters: { layout: "centered", }, tags: ["autodocs"], -} satisfies Meta; +} satisfies Meta; export default meta; -const Template: StoryFn> = (args) => { - const { control } = useUrlAndHashFormController(); - - return ; +const Template: StoryFn> = (args) => { + return ; }; export const Default = Template.bind({}); -Default.args = { - placeholder: "Enter URL", - width: "400px", - formFieldName: "url", -}; Default.play = async ({ canvasElement }) => { const canvas = within(canvasElement); - const inputElement = canvas.getByPlaceholderText("Enter URL"); + const inputElement = canvas.getByPlaceholderText("Placeholder"); await userEvent.type(inputElement, "test"); expect(inputElement).toHaveValue("test"); }; @@ -40,9 +32,6 @@ Default.play = async ({ canvasElement }) => { export const WithLabel = Template.bind({}); WithLabel.args = { label: "Label", - placeholder: "Enter URL", - width: "400px", - formFieldName: "url", }; WithLabel.play = async ({ canvasElement }) => { @@ -52,13 +41,22 @@ WithLabel.play = async ({ canvasElement }) => { export const Error = Template.bind({}); Error.args = { - placeholder: "Enter URL", - errorMessage: "Invalid URL format", - width: "400px", - formFieldName: "url", + errorMessage: "Error message", }; Error.play = async ({ canvasElement }) => { const canvas = within(canvasElement); - expect(canvas.getByTestId("invalid-url-format-error")).toBeInTheDocument(); + expect(canvas.getByTestId("error-message-error")).toBeInTheDocument(); +}; + +export const ErrorAndLabel = Template.bind({}); +ErrorAndLabel.args = { + errorMessage: "Error message", + label: "Label", +}; + +ErrorAndLabel.play = async ({ canvasElement }) => { + const canvas = within(canvasElement); + expect(canvas.getByText("Label")).toBeInTheDocument(); + expect(canvas.getByTestId("error-message-error")).toBeInTheDocument(); }; diff --git a/infra/terraform/.env.example b/infra/terraform/.env.example new file mode 100644 index 000000000..57b5b564e --- /dev/null +++ b/infra/terraform/.env.example @@ -0,0 +1,5 @@ +export export AWS_PROFILE= +export NIXPKGS_ALLOW_UNFREE=1 + +use nix + diff --git a/infra/terraform/main.tf b/infra/terraform/main.tf index 291e66a89..6d46cc5a7 100644 --- a/infra/terraform/main.tf +++ b/infra/terraform/main.tf @@ -11,12 +11,12 @@ resource "aws_route53_zone" "govtool" { name = "govtool.byron.network." } -module "vva-ecr-be" { +module "govtool-ecr-backend" { source = "./modules/ecr" repo_name = "backend" } -module "vva-ecr-fe" { +module "govtool-ecr-frontend" { source = "./modules/ecr" repo_name = "frontend" } @@ -32,8 +32,8 @@ resource "aws_iam_policy" "cicd_ecr" { ] Effect = "Allow" Resource = [ - module.vva-ecr-be.repo_arn, - module.vva-ecr-fe.repo_arn + module.govtool-ecr-backend.repo_arn, + module.govtool-ecr-frontend.repo_arn ] }, { @@ -55,24 +55,24 @@ resource "aws_iam_group_policy_attachment" "cicd" { # duplicate the following block in order to prepare a new environment # make sure that app_env/cardano_network variable pair is unique -module "vva-dev-sanchonet" { - source = "./modules/vva-ec2" +module "govtool-dev-sanchonet" { + source = "./modules/govtool-ec2" app_env = "dev" cardano_network = "sanchonet" instance_type = "t3.large" dns_zone_id = aws_route53_zone.govtool.id } -module "vva-test-sanchonet" { - source = "./modules/vva-ec2" +module "govtool-test-sanchonet" { + source = "./modules/govtool-ec2" app_env = "test" cardano_network = "sanchonet" instance_type = "t3.large" dns_zone_id = aws_route53_zone.govtool.id } -module "vva-staging-sanchonet" { - source = "./modules/vva-ec2" +module "govtool-staging-sanchonet" { + source = "./modules/govtool-ec2" app_env = "staging" cardano_network = "sanchonet" instance_type = "t3.large" @@ -80,33 +80,33 @@ module "vva-staging-sanchonet" { custom_subdomain = "staging" } -module "vva-beta-sanchonet" { - source = "./modules/vva-ec2" +module "govtool-beta-sanchonet" { + source = "./modules/govtool-ec2" app_env = "beta" cardano_network = "sanchonet" instance_type = "t3.large" } -output "vva-ecr-be-url" { - value = module.vva-ecr-be.repo_url +output "govtool-ecr-backend-url" { + value = module.govtool-ecr-backend.repo_url } -output "vva-ecr-fe-url" { - value = module.vva-ecr-fe.repo_url +output "govtool-ecr-frontend-url" { + value = module.govtool-ecr-frontend.repo_url } -output "vva-dev-sanchonet-frontend-domain" { - value = module.vva-dev-sanchonet.frontend_domain +output "govtool-dev-sanchonet-frontend-domain" { + value = module.govtool-dev-sanchonet.frontend_domain } -output "vva-test-sanchonet-frontend-domain" { - value = module.vva-test-sanchonet.frontend_domain +output "govtool-test-sanchonet-frontend-domain" { + value = module.govtool-test-sanchonet.frontend_domain } -output "vva-staging-sanchonet-frontend-domain" { - value = module.vva-staging-sanchonet.frontend_domain +output "govtool-staging-sanchonet-frontend-domain" { + value = module.govtool-staging-sanchonet.frontend_domain } -output "vva-beta-sanchonet-frontend-domain" { - value = module.vva-beta-sanchonet.frontend_domain +output "govtool-beta-sanchonet-frontend-domain" { + value = module.govtool-beta-sanchonet.frontend_domain } diff --git a/infra/terraform/modules/ecr/variables.tf b/infra/terraform/modules/ecr/variables.tf index 4f29a09de..33fcb170f 100644 --- a/infra/terraform/modules/ecr/variables.tf +++ b/infra/terraform/modules/ecr/variables.tf @@ -1,4 +1,4 @@ variable "app_name" { - default = "vva" + default = "govtool" } variable "repo_name" {} diff --git a/infra/terraform/modules/vva-ec2/main.tf b/infra/terraform/modules/govtool-ec2/main.tf similarity index 96% rename from infra/terraform/modules/vva-ec2/main.tf rename to infra/terraform/modules/govtool-ec2/main.tf index e5a5522aa..f71417f05 100644 --- a/infra/terraform/modules/vva-ec2/main.tf +++ b/infra/terraform/modules/govtool-ec2/main.tf @@ -143,7 +143,7 @@ resource "aws_security_group" "web_sg" { } } -resource "aws_instance" "vva" { +resource "aws_instance" "govtool" { ami = var.ami instance_type = var.instance_type @@ -174,8 +174,8 @@ resource "aws_instance" "vva" { } } -resource "aws_eip" "vva" { - instance = aws_instance.vva.id +resource "aws_eip" "govtool" { + instance = aws_instance.govtool.id tags = { Name = "${var.app_name}_${var.app_env}_${var.cardano_network}" @@ -191,5 +191,5 @@ resource "aws_route53_record" "frontend" { name = "${var.custom_subdomain != "" ? "${var.custom_subdomain}" : "${var.app_env}-${var.cardano_network}"}" type = "A" ttl = 180 - records = [aws_eip.vva.public_ip] + records = [aws_eip.govtool.public_ip] } diff --git a/infra/terraform/modules/govtool-ec2/outputs.tf b/infra/terraform/modules/govtool-ec2/outputs.tf new file mode 100644 index 000000000..99a2f8920 --- /dev/null +++ b/infra/terraform/modules/govtool-ec2/outputs.tf @@ -0,0 +1,7 @@ +output "govtool_eip" { + value = aws_eip.govtool.public_ip +} + +output "frontend_domain" { + value = var.app_env == "beta" ? aws_eip.govtool.public_ip : aws_route53_record.frontend[0].fqdn +} diff --git a/infra/terraform/modules/vva-ec2/user_data.sh b/infra/terraform/modules/govtool-ec2/user_data.sh similarity index 100% rename from infra/terraform/modules/vva-ec2/user_data.sh rename to infra/terraform/modules/govtool-ec2/user_data.sh diff --git a/infra/terraform/modules/vva-ec2/variables.tf b/infra/terraform/modules/govtool-ec2/variables.tf similarity index 94% rename from infra/terraform/modules/vva-ec2/variables.tf rename to infra/terraform/modules/govtool-ec2/variables.tf index 7a230a530..0f58d46b4 100644 --- a/infra/terraform/modules/vva-ec2/variables.tf +++ b/infra/terraform/modules/govtool-ec2/variables.tf @@ -3,7 +3,7 @@ variable "ami" { } variable "app_env" {} variable "app_name" { - default = "vva" + default = "govtool" } variable "cardano_network" {} variable "custom_subdomain" { diff --git a/infra/terraform/modules/govtool-ec2/vva_to_govtool_migration_20240212.tf b/infra/terraform/modules/govtool-ec2/vva_to_govtool_migration_20240212.tf new file mode 100644 index 000000000..27673a071 --- /dev/null +++ b/infra/terraform/modules/govtool-ec2/vva_to_govtool_migration_20240212.tf @@ -0,0 +1,15 @@ +# FIXME This Terraform file in question is designed to migrate resource and +# module names, serving as a transitional tool to ensure consistent naming +# conventions across the infrastructure. Once it is confirmed that all users +# have applied this migration, the file can be safely removed in the future to +# maintain clarity and efficiency in the codebase. + +moved { + from = aws_instance.vva + to = aws_instance.govtool +} + +moved { + from = aws_eip.vva + to = aws_eip.govtool +} diff --git a/infra/terraform/modules/vva-ec2/outputs.tf b/infra/terraform/modules/vva-ec2/outputs.tf deleted file mode 100644 index 821684c05..000000000 --- a/infra/terraform/modules/vva-ec2/outputs.tf +++ /dev/null @@ -1,7 +0,0 @@ -output "vva_eip" { - value = aws_eip.vva.public_ip -} - -output "frontend_domain" { - value = var.app_env == "beta" ? aws_eip.vva.public_ip : aws_route53_record.frontend[0].fqdn -} diff --git a/infra/terraform/shell.nix b/infra/terraform/shell.nix new file mode 100644 index 000000000..de8446216 --- /dev/null +++ b/infra/terraform/shell.nix @@ -0,0 +1,4 @@ +{ pkgs ? import {} }: +pkgs.mkShell { + packages = with pkgs; [ awscli2 terraform ]; +} diff --git a/infra/terraform/vva_to_govtool_migration_20240212.tf b/infra/terraform/vva_to_govtool_migration_20240212.tf new file mode 100644 index 000000000..067ea4d77 --- /dev/null +++ b/infra/terraform/vva_to_govtool_migration_20240212.tf @@ -0,0 +1,35 @@ +# FIXME This Terraform file in question is designed to migrate resource and +# module names, serving as a transitional tool to ensure consistent naming +# conventions across the infrastructure. Once it is confirmed that all users +# have applied this migration, the file can be safely removed in the future to +# maintain clarity and efficiency in the codebase. + +moved { + from = module.vva-ecr-be + to = module.govtool-ecr-backend +} + +moved { + from = module.vva-ecr-fe + to = module.govtool-ecr-frontend +} + +moved { + from = module.vva-dev-sanchonet + to = module.govtool-dev-sanchonet +} + +moved { + from = module.vva-test-sanchonet + to = module.govtool-test-sanchonet +} + +moved { + from = module.vva-staging-sanchonet + to = module.govtool-staging-sanchonet +} + +moved { + from = module.vva-beta-sanchonet + to = module.govtool-beta-sanchonet +} diff --git a/scripts/govtool/.env.example b/scripts/govtool/.env.example index 71adc0bf6..47fb60653 100644 --- a/scripts/govtool/.env.example +++ b/scripts/govtool/.env.example @@ -1,15 +1,29 @@ use nix shell.nix -export AWS_PROFILE=vva +export AWS_PROFILE=govtool export ENVIRONMENT="dev" export CARDANO_NETWORK="sanchonet" -export SLACK_WEBHOOK_URL= +export SLACK_WEBHOOK_URL= export DBSYNC_POSTGRES_USER="postgres" -export DBSYNC_POSTGRES_PASSWORD="" +export DBSYNC_POSTGRES_PASSWORD= export DBSYNC_POSTGRES_DB="cexplorer" -export FAKEDBSYNC_POSTGRES_DB="vva" + +export FAKEDBSYNC_POSTGRES_DB="govtool" export FAKEDBSYNC_POSTGRES_USER="test" -export FAKEDBSYNC_POSTGRES_PASSWORD="test" -export TRAEFIK_LE_EMAIL="" +export FAKEDBSYNC_POSTGRES_PASSWORD= + +export TRAEFIK_LE_EMAIL= + +export GTM_ID=blank + +export SENTRY_DSN_BACKEND=blank +export SENTRY_DSN=blank + +export NGINX_BASIC_AUTH= + +export GRAFANA_ADMIN_PASSWORD= +export GRAFANA_SLACK_RECIPIENT= +export GRAFANA_SLACK_WEBHOOK= +export GRAFANA_SLACK_OAUTH_TOKEN= diff --git a/scripts/govtool/Makefile b/scripts/govtool/Makefile index f382cf803..d1840c7cb 100644 --- a/scripts/govtool/Makefile +++ b/scripts/govtool/Makefile @@ -10,11 +10,12 @@ grafana_slack_oauth_token := $(shell echo $${GRAFANA_SLACK_OAUTH_TOKEN}) gtm_id := $(shell echo $${GTM_ID}) sentry_dsn := $(shell echo $${SENTRY_DSN}) +commit := $(shell git rev-parse HEAD) branch := $(shell git rev-parse --abbrev-ref HEAD) docker ?= docker domain := $(shell echo $${DOMAIN:-$(env)-$(cardano_network).govtool.byron.network}) repo_url ?= 733019650473.dkr.ecr.eu-west-1.amazonaws.com -tag := $(branch)-$(env)-$(cardano_network) +tag := $(commit)-$(env)-$(cardano_network) docker_host := $(domain) docker_user := ubuntu @@ -35,7 +36,7 @@ all: docker-login prepare-config upload-config build-backend push-backend build- check-env-defined: @:$(call check_defined, cardano_network) @:$(call check_defined, env) - @grep -q "module \"vva-$(env)-$(cardano_network)\"" ../../infra/terraform/main.tf && \ + @grep -q "module \"govtool-$(env)-$(cardano_network)\"" ../../infra/terraform/main.tf && \ echo "Environment $(env) for network $(cardano_network) is defined in Terraform" || \ { echo "Environment $(env) for network $(cardano_network) is NOT defined in Terraform, cannot deploy there"; exit 1; } @@ -64,7 +65,7 @@ upload-config: prepare-config build-backend: @:$(call check_defined, cardano_network) @:$(call check_defined, env) - $(docker) build --tag $(repo_url)/backend:$(tag) ../../govtool/backend + $(docker) build --tag "$(repo_url)/backend:$(tag)" ../../govtool/backend .PHONY: push-backend push-backend: @@ -79,7 +80,7 @@ build-frontend: @:$(call check_defined, gtm_id) @:$(call check_defined, sentry_dsn) if [[ "$(cardano_network)" = "mainnet" ]]; then NETWORK_FLAG=1; else NETWORK_FLAG=0; fi; \ - $(docker) build --tag $(repo_url)/frontend:$(tag) \ + $(docker) build --tag "$(repo_url)/frontend:$(tag)" \ --build-arg VITE_BASE_URL="https://$(domain)/api" \ --build-arg VITE_GTM_ID="$(gtm_id)" \ --build-arg VITE_NETWORK_FLAG="$$NETWORK_FLAG" \ @@ -103,8 +104,8 @@ deploy-stack: export GRAFANA_ADMIN_PASSWORD=$(grafana_admin_password); \ export TAG=$(tag); \ ssh-keyscan $(docker_host) 2>/dev/null >> ~/.ssh/known_hosts; \ - docker compose -f docker-compose.$(cardano_network).yml -p vva-$(env)-$(cardano_network) pull; \ - docker compose -f docker-compose.$(cardano_network).yml -p vva-$(env)-$(cardano_network) up -d + docker compose -f docker-compose.$(cardano_network).yml -p govtool-$(env)-$(cardano_network) pull; \ + docker compose -f docker-compose.$(cardano_network).yml -p govtool-$(env)-$(cardano_network) up -d .PHONY: destroy-cardano-node-and-dbsync destroy-cardano-node-and-dbsync: @@ -131,8 +132,8 @@ toggle-maintenance: export DOCKER_HOST=ssh://$(ssh_url); \ export TAG=$(tag); \ ssh-keyscan $(docker_host) 2>/dev/null >> ~/.ssh/known_hosts; \ - if [[ "$(maintenance)" = "enable" ]]; then docker compose -f docker-compose.$(cardano_network).yml -p vva-$(env)-$(cardano_network) exec vva-fe touch /var/run/maintenance_enabled; \ - else docker compose -f docker-compose.$(cardano_network).yml -p vva-$(env)-$(cardano_network) exec vva-fe rm /var/run/maintenance_enabled; fi + if [[ "$(maintenance)" = "enable" ]]; then docker compose -f docker-compose.$(cardano_network).yml -p govtool-$(env)-$(cardano_network) exec frontend touch /var/run/maintenance_enabled; \ + else docker compose -f docker-compose.$(cardano_network).yml -p govtool-$(env)-$(cardano_network) exec frontend rm /var/run/maintenance_enabled; fi .DEFAULT_GOAL := info .PHONY: info @@ -155,3 +156,24 @@ notify: @:$(call check_defined, cardano_network) @:$(call check_defined, env) curl -X POST -H 'Content-type: application/json' --data '{"host":"$(docker_host)","branch":"$(branch)","env":"$(env)","commit":"$(shell git rev-parse HEAD)"}' $$SLACK_WEBHOOK_URL + +.PHONY: ssh +ssh: + @:$(call check_defined, cardano_network) + @:$(call check_defined, env) + export TERM=xterm-256color; \ + ssh $(ssh_url) + +.PHONY: docker +docker: + @:$(call check_defined, cardano_network) + @:$(call check_defined, env) + @:$(call check_defined, grafana_admin_password) + @:$(call check_defined, cmd) + export CARDANO_NETWORK=$(cardano_network); \ + export DOCKER_HOST=ssh://$(ssh_url); \ + export ENVIRONMENT=$(env); \ + export GRAFANA_ADMIN_PASSWORD=$(grafana_admin_password); \ + export TAG=$(tag); \ + ssh-keyscan $(docker_host) 2>/dev/null >> ~/.ssh/known_hosts; \ + docker compose -f docker-compose.$(cardano_network).yml -p govtool-$(env)-$(cardano_network) $(cmd) diff --git a/scripts/govtool/config/grafana-provisioning/alerting/alerting.yml b/scripts/govtool/config/grafana-provisioning/alerting/alerting.yml index f5f6249ca..e50e4b6e0 100644 --- a/scripts/govtool/config/grafana-provisioning/alerting/alerting.yml +++ b/scripts/govtool/config/grafana-provisioning/alerting/alerting.yml @@ -299,7 +299,7 @@ groups: type: prometheus uid: PBFA97CFB590B2093 editorMode: builder - expr: sum by(code) (rate(traefik_service_requests_total{service="vva-be@docker", code="502"}[$__rate_interval])) + expr: sum by(code) (rate(traefik_service_requests_total{service="backend@docker", code="502"}[$__rate_interval])) hide: false instant: false interval: "" diff --git a/scripts/govtool/config/grafana-provisioning/dashboards/vva.json b/scripts/govtool/config/grafana-provisioning/dashboards/govtool.json similarity index 98% rename from scripts/govtool/config/grafana-provisioning/dashboards/vva.json rename to scripts/govtool/config/grafana-provisioning/dashboards/govtool.json index 2ac493158..348b8e6c6 100644 --- a/scripts/govtool/config/grafana-provisioning/dashboards/vva.json +++ b/scripts/govtool/config/grafana-provisioning/dashboards/govtool.json @@ -18,7 +18,7 @@ "editable": true, "fiscalYearStartMonth": 0, "graphTooltip": 0, - "id": 2, + "id": 3, "links": [], "liveNow": false, "panels": [ @@ -81,7 +81,7 @@ }, "editorMode": "builder", "exemplar": true, - "expr": "traefik_service_requests_total{service=\"vva-fe@docker\"}", + "expr": "traefik_service_requests_total{service=\"frontend@docker\"}", "instant": false, "legendFormat": "{{method}} : {{code}}", "range": true, @@ -174,7 +174,7 @@ "uid": "PBFA97CFB590B2093" }, "editorMode": "builder", - "expr": "sum by(code) (rate(traefik_service_requests_total{service=\"vva-fe@docker\"}[$__rate_interval]))", + "expr": "sum by(code) (rate(traefik_service_requests_total{service=\"frontend@docker\"}[$__rate_interval]))", "hide": false, "instant": false, "legendFormat": "{{code}}", @@ -310,7 +310,7 @@ }, "editorMode": "builder", "exemplar": true, - "expr": "traefik_service_requests_total{service=\"vva-be@docker\"}", + "expr": "traefik_service_requests_total{service=\"backend@docker\"}", "instant": false, "legendFormat": "{{method}} : {{code}}", "range": true, @@ -403,7 +403,7 @@ "uid": "PBFA97CFB590B2093" }, "editorMode": "builder", - "expr": "sum by(code) (rate(traefik_service_requests_total{service=\"vva-be@docker\"}[$__rate_interval]))", + "expr": "sum by(code) (rate(traefik_service_requests_total{service=\"backend@docker\"}[$__rate_interval]))", "hide": false, "instant": false, "legendFormat": "{{code}}", diff --git a/scripts/govtool/config/secrets/vva-be-config.json b/scripts/govtool/config/secrets/backend-config.json similarity index 92% rename from scripts/govtool/config/secrets/vva-be-config.json rename to scripts/govtool/config/secrets/backend-config.json index 068a9613f..d60da33f1 100644 --- a/scripts/govtool/config/secrets/vva-be-config.json +++ b/scripts/govtool/config/secrets/backend-config.json @@ -8,7 +8,7 @@ }, "fakedbsyncconfig" : { "host" : "postgres-fakedbsync", - "dbname" : "vva", + "dbname" : "govtool", "user" : "test", "password" : "test", "port" : 5432 diff --git a/scripts/govtool/config/secrets/vva-be-config.json.tpl b/scripts/govtool/config/secrets/backend-config.json.tpl similarity index 100% rename from scripts/govtool/config/secrets/vva-be-config.json.tpl rename to scripts/govtool/config/secrets/backend-config.json.tpl diff --git a/scripts/govtool/docker-compose.sanchonet.yml b/scripts/govtool/docker-compose.sanchonet.yml index b7f4a4054..5c052a02d 100644 --- a/scripts/govtool/docker-compose.sanchonet.yml +++ b/scripts/govtool/docker-compose.sanchonet.yml @@ -104,7 +104,7 @@ services: logging: *logging cardano-node: - image: ghcr.io/intersectmbo/cardano-node:8.7.2 + image: ghcr.io/intersectmbo/cardano-node:8.8.0-pre entrypoint: - "cardano-node" - "run" @@ -143,7 +143,7 @@ services: logging: *logging cardano-db-sync: - image: ghcr.io/intersectmbo/cardano-db-sync:sancho-3-0-0 + image: ghcr.io/intersectmbo/cardano-db-sync:sancho-4-0-0-fix-config environment: - NETWORK=${CARDANO_NETWORK:-sanchonet} - POSTGRES_HOST=postgres @@ -166,31 +166,31 @@ services: restart: always logging: *logging - vva-be: + backend: image: ${VVA_BE_REPO:-733019650473.dkr.ecr.eu-west-1.amazonaws.com/backend}:${TAG:-main-dev-sanchonet} - command: /usr/local/bin/vva-be -c /run/secrets/vva-be-config.json start-app + command: /usr/local/bin/vva-be -c /run/secrets/backend-config.json start-app depends_on: cardano-node: condition: service_healthy postgres: condition: service_healthy secrets: - - vva-be-config.json + - backend-config.json restart: always logging: *logging labels: - "traefik.enable=true" - - "traefik.http.routers.vva-be.rule=Host(`${DOMAIN:-$ENVIRONMENT-$CARDANO_NETWORK.govtool.byron.network}`) && PathPrefix(`/api`)" - - "traefik.http.middlewares.vva-be-stripprefix.stripprefix.prefixes=/api" - - "traefik.http.middlewares.vva-be-cors.headers.customresponseheaders.Access-Control-Allow-Origin=https://${DOMAIN:-$ENVIRONMENT-$CARDANO_NETWORK.govtool.byron.network}" - - "traefik.http.middlewares.vva-be-cors.headers.customresponseheaders.Access-Control-Allow-Methods=GET,HEAD,OPTIONS" - - "traefik.http.middlewares.vva-be-cors.headers.addvaryheader=true" - - "traefik.http.routers.vva-be.middlewares=vva-be-stripprefix@docker,vva-be-cors@docker" - - "traefik.http.routers.vva-be.entrypoints=websecure" - - "traefik.http.routers.vva-be.tls.certresolver=myresolver" - - "traefik.http.services.vva-be.loadbalancer.server.port=9876" + - "traefik.http.routers.backend.rule=Host(`${DOMAIN:-$ENVIRONMENT-$CARDANO_NETWORK.govtool.byron.network}`) && PathPrefix(`/api`)" + - "traefik.http.middlewares.backend-stripprefix.stripprefix.prefixes=/api" + - "traefik.http.middlewares.backend-cors.headers.customresponseheaders.Access-Control-Allow-Origin=https://${DOMAIN:-$ENVIRONMENT-$CARDANO_NETWORK.govtool.byron.network}" + - "traefik.http.middlewares.backend-cors.headers.customresponseheaders.Access-Control-Allow-Methods=GET,HEAD,OPTIONS" + - "traefik.http.middlewares.backend-cors.headers.addvaryheader=true" + - "traefik.http.routers.backend.middlewares=backend-stripprefix@docker,backend-cors@docker" + - "traefik.http.routers.backend.entrypoints=websecure" + - "traefik.http.routers.backend.tls.certresolver=myresolver" + - "traefik.http.services.backend.loadbalancer.server.port=9876" - vva-fe: + frontend: image: ${VVA_FE_REPO:-733019650473.dkr.ecr.eu-west-1.amazonaws.com/frontend}:${TAG:-main-dev-sanchonet} volumes: - /home/ubuntu/config/nginx/auth.conf:/etc/nginx/conf.d/auth.conf @@ -204,10 +204,12 @@ services: logging: *logging labels: - "traefik.enable=true" - - "traefik.http.routers.vva-fe.rule=Host(`${DOMAIN:-$ENVIRONMENT-$CARDANO_NETWORK.govtool.byron.network}`)" - - "traefik.http.routers.vva-fe.entrypoints=websecure" - - "traefik.http.routers.vva-fe.tls.certresolver=myresolver" - - "traefik.http.services.vva-fe.loadbalancer.server.port=80" + - "traefik.http.routers.frontend.rule=Host(`${DOMAIN:-$ENVIRONMENT-$CARDANO_NETWORK.govtool.byron.network}`)" + - "traefik.http.routers.frontend.entrypoints=websecure" + - "traefik.http.routers.frontend.tls.certresolver=myresolver" + - "traefik.http.middlewares.frontend-csp.headers.contentSecurityPolicy=default-src 'self'; img-src *.usersnap.com 'self' data:; script-src *.usersnap.com 'self' 'unsafe-inline' https://www.googletagmanager.com https://browser.sentry-cdn.com; style-src *.usersnap.com *.googleapis.com 'self' 'unsafe-inline' https://fonts.googleapis.com; connect-src *.usersnap.com https://s3.eu-central-1.amazonaws.com/upload.usersnap.com 'self' https://o4506155985141760.ingest.sentry.io/api/4506156032196608/envelope/ *.google-analytics.com; font-src *.usersnap.com *.gstatic.com 'self' 'unsafe-inline' https://fonts.gstatic.com; worker-src blob:" + - "traefik.http.routers.frontend.middlewares=frontend-csp@docker" + - "traefik.http.services.frontend.loadbalancer.server.port=80" secrets: postgres_db: @@ -216,8 +218,8 @@ secrets: file: /home/ubuntu/config/dbsync-secrets/postgres_password postgres_user: file: /home/ubuntu/config/dbsync-secrets/postgres_user - vva-be-config.json: - file: /home/ubuntu/config/vva-be-config.json + backend-config.json: + file: /home/ubuntu/config/backend-config.json volumes: letsencrypt: diff --git a/scripts/govtool/docker-compose.yml b/scripts/govtool/docker-compose.yml index 417e036d2..c0daa4671 100644 --- a/scripts/govtool/docker-compose.yml +++ b/scripts/govtool/docker-compose.yml @@ -51,7 +51,7 @@ services: max-file: "10" cardano-node: - image: inputoutput/cardano-node:8.0.0 + image: inputoutput/cardano-node:8.7.3 environment: - NETWORK=${NETWORK:-mainnet} volumes: @@ -96,13 +96,13 @@ services: image: postgres:15-alpine environment: - POSTGRES_LOGGING=true - - POSTGRES_DB=vva + - POSTGRES_DB=govtool - POSTGRES_PASSWORD=test - POSTGRES_USER=postgres volumes: - postgres-fakedbsync:/var/lib/postgresql/data - - ./vva-be/misc/fakedbsync_users.sql:/docker-entrypoint-initdb.d/00_fakedbsync_users.sql - - ./vva-be/misc/schema6.sql:/docker-entrypoint-initdb.d/10_schema6.sql + - ../../govtool/backend/misc/fakedbsync_users.sql:/docker-entrypoint-initdb.d/00_fakedbsync_users.sql + - ../../govtool/backend/misc/schema6.sql:/docker-entrypoint-initdb.d/10_schema6.sql restart: on-failure healthcheck: # Use pg_isready to check postgres is running. Substitute different @@ -114,10 +114,10 @@ services: command: ${POSTGRES_ARGS:--c maintenance_work_mem=1GB -c max_parallel_maintenance_workers=4} logging: *logging - vva-be: + backend: build: - context: vva-be - command: /usr/local/bin/vva-be -c /run/secrets/vva-be-config.json start-app + context: ../../govtool/backend + command: /usr/local/bin/vva-be -c /run/secrets/backend-config.json start-app depends_on: # Depend on both services to be healthy before starting. cardano-node: @@ -130,20 +130,20 @@ services: # ports: # - ${VVA_BE_PORT:-9876}:9876 secrets: - - vva-be-config.json + - backend-config.json restart: on-failure logging: *logging labels: - "traefik.enable=true" - - "traefik.http.routers.vva-be.rule=Host(`${VVA_BE_DOMAIN:-vva-be.localhost}`)" - - "traefik.http.routers.vva-be.entrypoints=web" - - "traefik.http.services.vva-be.loadbalancer.server.port=9876" + - "traefik.http.routers.backend.rule=Host(`${GOVTOOL_BE_DOMAIN:-backend-govtool.localhost}`)" + - "traefik.http.routers.backend.entrypoints=web" + - "traefik.http.services.backend.loadbalancer.server.port=9876" - vva-fe: + frontend: build: - context: vva-fe + context: ../../govtool/frontend args: - - VITE_BASE_URL="https://${VA_BE_DOMAIN:-vva-be.localhost}" + - VITE_BASE_URL="https://${GOVTOOL_BE_DOMAIN:-backend-govtool.localhost}" depends_on: # Depend on both services to be healthy before starting. cardano-node: @@ -157,9 +157,9 @@ services: logging: *logging labels: - "traefik.enable=true" - - "traefik.http.routers.vva-fe.rule=Host(`${VVA_FE_DOMAIN:-vva-fe.localhost}`)" - - "traefik.http.routers.vva-fe.entrypoints=web" - - "traefik.http.services.vva-fe.loadbalancer.server.port=80" + - "traefik.http.routers.frontend.rule=Host(`${GOVTOOL_FE_DOMAIN:-frontend-govtool.localhost}`)" + - "traefik.http.routers.frontend.entrypoints=web" + - "traefik.http.services.frontend.loadbalancer.server.port=80" secrets: postgres_db: @@ -168,8 +168,8 @@ secrets: file: ./config/secrets/postgres_password postgres_user: file: ./config/secrets/postgres_user - vva-be-config.json: - file: ./config/secrets/vva-be-config.json + backend-config.json: + file: ./config/secrets/backend-config.json volumes: # letsencrypt: diff --git a/scripts/govtool/prepare-config.sh b/scripts/govtool/prepare-config.sh index ac271a837..062a1ecaf 100755 --- a/scripts/govtool/prepare-config.sh +++ b/scripts/govtool/prepare-config.sh @@ -39,8 +39,8 @@ sed -e "s/FAKEDBSYNC_POSTGRES_DB/$FAKEDBSYNC_POSTGRES_DB/" \ -e "s/DBSYNC_POSTGRES_USER/$DBSYNC_POSTGRES_USER/" \ -e "s/DBSYNC_POSTGRES_PASSWORD/$DBSYNC_POSTGRES_PASSWORD/" \ -e "s|SENTRY_DSN|$SENTRY_DSN_BACKEND|" \ - "$config_dir/secrets/vva-be-config.json.tpl" \ - > "$target_config_dir/vva-be-config.json" + "$config_dir/secrets/backend-config.json.tpl" \ + > "$target_config_dir/backend-config.json" # prometheus config file cat >"$target_config_dir/prometheus.yml" <<_EOF_ @@ -48,7 +48,7 @@ global: scrape_interval: 15s evaluation_interval: 15s external_labels: - monitor: 'vva' + monitor: 'govtool' scrape_configs: - job_name: 'traefik' scrape_interval: 5s @@ -79,6 +79,7 @@ sed -e "s/GRAFANA_SLACK_RECIPIENT/$GRAFANA_SLACK_RECIPIENT/" \ # nginx config for frontend optional basic auth nginx_config_dir="$target_config_dir/nginx" +rm -rf "$nginx_config_dir" mkdir -p "$nginx_config_dir" if [[ "$DOMAIN" == *"sanchonet.govtool.byron.network"* ]]; then cat >"$nginx_config_dir/auth.conf" <<_EOF_ diff --git a/tests/vva-be/.env.example b/tests/govtool-backend/.env.example similarity index 100% rename from tests/vva-be/.env.example rename to tests/govtool-backend/.env.example diff --git a/tests/vva-be/.gitignore b/tests/govtool-backend/.gitignore similarity index 100% rename from tests/vva-be/.gitignore rename to tests/govtool-backend/.gitignore diff --git a/tests/vva-be/README.md b/tests/govtool-backend/README.md similarity index 86% rename from tests/vva-be/README.md rename to tests/govtool-backend/README.md index bb066b240..33c6f211e 100644 --- a/tests/vva-be/README.md +++ b/tests/govtool-backend/README.md @@ -1,8 +1,8 @@ -VVA-BE PyTest +GovTool backend PyTest ================= This test is responsible for following -- Perform basic tests on VVA backend endpoints. +- Perform basic tests on GovTool backend endpoints. - Publish the reports to metrics server for visualization. ## Installation @@ -31,7 +31,7 @@ This will generate test_data.json that will be used to run tests. ## Run tests -In the root directory of tests/vva-be run the following command +In the root directory of tests/govtool-backend run the following command ```shell export BASE_URL="url" # server's url e.g. https://staging.govtool.byron.network/api" export METRICS_URL="url" # metrics server Url diff --git a/tests/vva-be/config.py b/tests/govtool-backend/config.py similarity index 100% rename from tests/vva-be/config.py rename to tests/govtool-backend/config.py diff --git a/tests/vva-be/models/TestData.py b/tests/govtool-backend/models/TestData.py similarity index 100% rename from tests/vva-be/models/TestData.py rename to tests/govtool-backend/models/TestData.py diff --git a/tests/vva-be/models/TestResult.py b/tests/govtool-backend/models/TestResult.py similarity index 100% rename from tests/vva-be/models/TestResult.py rename to tests/govtool-backend/models/TestResult.py diff --git a/tests/vva-be/models/__init__.py b/tests/govtool-backend/models/__init__.py similarity index 100% rename from tests/vva-be/models/__init__.py rename to tests/govtool-backend/models/__init__.py diff --git a/tests/vva-be/requirements.txt b/tests/govtool-backend/requirements.txt similarity index 100% rename from tests/vva-be/requirements.txt rename to tests/govtool-backend/requirements.txt diff --git a/tests/vva-be/setup.py b/tests/govtool-backend/setup.py similarity index 100% rename from tests/vva-be/setup.py rename to tests/govtool-backend/setup.py diff --git a/tests/vva-be/test_cases/__init__.py b/tests/govtool-backend/test_cases/__init__.py similarity index 100% rename from tests/vva-be/test_cases/__init__.py rename to tests/govtool-backend/test_cases/__init__.py diff --git a/tests/vva-be/test_cases/conftest.py b/tests/govtool-backend/test_cases/conftest.py similarity index 93% rename from tests/vva-be/test_cases/conftest.py rename to tests/govtool-backend/test_cases/conftest.py index 24184f2aa..fe20b385e 100644 --- a/tests/vva-be/test_cases/conftest.py +++ b/tests/govtool-backend/test_cases/conftest.py @@ -8,7 +8,7 @@ from models.TestResult import Metrics -from test_cases.vva_api import VVAApi +from test_cases.govtool_api import GovToolApi from config import CURRENT_GIT_HASH from config import BUILD_ID @@ -18,7 +18,7 @@ @pytest.fixture(scope="session") -def vva_api(): +def govtool_api(): base_url: str = os.environ.get('BASE_URL') metrics_url: str = os.environ.get('METRICS_URL') @@ -36,7 +36,7 @@ def vva_api(): print("METRICS_URL environment variable is not set.", file=sys.stderr) print("Proceeding without METRICS_URL: Metrics will not be posted") - api = VVAApi(base_url) + api = GovToolApi(base_url) yield api if metrics_url: @@ -64,13 +64,13 @@ def vva_api(): @pytest.hookimpl(wrapper=True, tryfirst=True) def pytest_runtest_makereport(item): rep = yield - vva_api_object = item.funcargs.get("vva_api") + govtool_api_object = item.funcargs.get("govtool_api") if rep.when == "call": test_func_name = re.search(r'(?<=::)(.*?)*(?=\[|$)', rep.nodeid).group() - vva_api_object.add_test_metrics( + govtool_api_object.add_test_metrics( Metrics( outcome=rep.outcome, test_name=test_func_name, diff --git a/tests/vva-be/test_cases/fixtures/ada_holder.py b/tests/govtool-backend/test_cases/fixtures/ada_holder.py similarity index 80% rename from tests/vva-be/test_cases/fixtures/ada_holder.py rename to tests/govtool-backend/test_cases/fixtures/ada_holder.py index 083599011..57343cd2e 100644 --- a/tests/vva-be/test_cases/fixtures/ada_holder.py +++ b/tests/govtool-backend/test_cases/fixtures/ada_holder.py @@ -4,7 +4,7 @@ @pytest.fixture(scope="module", params=ada_holders) -def ada_holder_delegate_to_drep(request, vva_api): +def ada_holder_delegate_to_drep(request, govtool_api): ada_holder: AdaHolder = request.param delegation_data = Delegation( @@ -12,4 +12,4 @@ def ada_holder_delegate_to_drep(request, vva_api): dRepId=ada_holder["drepId"] ) - yield delegation_data \ No newline at end of file + yield delegation_data diff --git a/tests/vva-be/test_cases/fixtures/drep.py b/tests/govtool-backend/test_cases/fixtures/drep.py similarity index 100% rename from tests/vva-be/test_cases/fixtures/drep.py rename to tests/govtool-backend/test_cases/fixtures/drep.py diff --git a/tests/vva-be/test_cases/vva_api.py b/tests/govtool-backend/test_cases/govtool_api.py similarity index 99% rename from tests/vva-be/test_cases/vva_api.py rename to tests/govtool-backend/test_cases/govtool_api.py index 8dd5a2ecc..604c15459 100644 --- a/tests/vva-be/test_cases/vva_api.py +++ b/tests/govtool-backend/test_cases/govtool_api.py @@ -9,7 +9,7 @@ from config import BUILD_ID -class VVAApi(): +class GovToolApi(): def __init__(self, base_url: str): self._base_url = base_url diff --git a/tests/govtool-backend/test_cases/test_ada_holder.py b/tests/govtool-backend/test_cases/test_ada_holder.py new file mode 100644 index 000000000..651a31218 --- /dev/null +++ b/tests/govtool-backend/test_cases/test_ada_holder.py @@ -0,0 +1,14 @@ +from models.TestData import AdaHolder, Delegation + +def test_ada_delegation(govtool_api, ada_holder_delegate_to_drep): + print(ada_holder_delegate_to_drep) + response = govtool_api.ada_holder_get_current_delegation(ada_holder_delegate_to_drep["stakeKey"]) + resp = response.json() + if resp: + assert ada_holder_delegate_to_drep["drepId"] in resp + + +def test_check_voting_power(govtool_api, ada_holder_delegate_to_drep): + response = govtool_api.ada_holder_get_voting_power(ada_holder_delegate_to_drep["stakeKey"]) + ada_holder_voting_power = response.json() + assert isinstance(ada_holder_voting_power, int) diff --git a/tests/vva-be/test_cases/test_drep.py b/tests/govtool-backend/test_cases/test_drep.py similarity index 81% rename from tests/vva-be/test_cases/test_drep.py rename to tests/govtool-backend/test_cases/test_drep.py index 2766af21e..c077e9169 100644 --- a/tests/vva-be/test_cases/test_drep.py +++ b/tests/govtool-backend/test_cases/test_drep.py @@ -34,14 +34,14 @@ def validate_voteonproposal_list(voteonproposal_list: [VoteonProposal]) -> bool: return True -def test_list_drep(vva_api): - response = vva_api.drep_list() +def test_list_drep(govtool_api): + response = govtool_api.drep_list() drep_list = response.json() validate_drep_list(drep_list) -def test_initialized_getVotes( vva_api, registered_drep): - response = vva_api.drep_getVotes(registered_drep["drepId"]) +def test_initialized_getVotes( govtool_api, registered_drep): + response = govtool_api.drep_getVotes(registered_drep["drepId"]) validate_voteonproposal_list(response.json()) votes = response.json() proposals = map(lambda x: x["vote"]["proposalId"], votes) @@ -49,6 +49,6 @@ def test_initialized_getVotes( vva_api, registered_drep): assert len(proposals)==0 -def test_initialized_getVotingPower(vva_api, registered_drep): - response = vva_api.drep_get_voting_power(registered_drep["drepId"]) - assert isinstance(response.json(), int) \ No newline at end of file +def test_initialized_getVotingPower(govtool_api, registered_drep): + response = govtool_api.drep_get_voting_power(registered_drep["drepId"]) + assert isinstance(response.json(), int) diff --git a/tests/vva-be/test_cases/test_proposal.py b/tests/govtool-backend/test_cases/test_proposal.py similarity index 89% rename from tests/vva-be/test_cases/test_proposal.py rename to tests/govtool-backend/test_cases/test_proposal.py index 931390c6e..7533d56ac 100644 --- a/tests/vva-be/test_cases/test_proposal.py +++ b/tests/govtool-backend/test_cases/test_proposal.py @@ -13,7 +13,7 @@ def validate_proposal_list(proposal_list: [Proposal]) -> bool: return True -def test_list_proposal(vva_api): - response = vva_api.proposal_list() +def test_list_proposal(govtool_api): + response = govtool_api.proposal_list() proposal_list = response.json() assert validate_proposal_list(proposal_list) diff --git a/tests/vva-be/test_data.json b/tests/govtool-backend/test_data.json similarity index 100% rename from tests/vva-be/test_data.json rename to tests/govtool-backend/test_data.json diff --git a/tests/vva-be/test_data.py b/tests/govtool-backend/test_data.py similarity index 100% rename from tests/vva-be/test_data.py rename to tests/govtool-backend/test_data.py diff --git a/tests/vva-fe/.gitignore b/tests/govtool-frontend/.gitignore similarity index 100% rename from tests/vva-fe/.gitignore rename to tests/govtool-frontend/.gitignore diff --git a/tests/vva-fe/README.md b/tests/govtool-frontend/README.md similarity index 78% rename from tests/vva-fe/README.md rename to tests/govtool-frontend/README.md index 2c7720148..94ca1fab3 100644 --- a/tests/vva-fe/README.md +++ b/tests/govtool-frontend/README.md @@ -1,4 +1,4 @@ -VVA Frontend Integration Test +GovTool frontend Integration Test ============================= ## Run tests @@ -14,5 +14,5 @@ yarn cypress run ## Run tests in dev environment ``` -yarn cypress run --env baseUrl=http://localhost:5173,apiUrl=https://vva.dev.byron.network +yarn cypress run --env baseUrl=http://localhost:5173,apiUrl=https://govtool.dev.byron.network ``` diff --git a/tests/vva-fe/currents.config.js b/tests/govtool-frontend/currents.config.js similarity index 84% rename from tests/vva-fe/currents.config.js rename to tests/govtool-frontend/currents.config.js index 956b34edf..4ce504e77 100644 --- a/tests/vva-fe/currents.config.js +++ b/tests/govtool-frontend/currents.config.js @@ -1,6 +1,6 @@ module.exports = { - projectId: "vva-fe", + projectId: "govtool-frontend", recordKey: "2a3f6b8c-7d4e-5f1a-9b0c-6d2e3f4a5b6c", // Sorry Cypress users - set the director service URL cloudServiceUrl: "https://cypress-director.cardanoapi.io", -}; \ No newline at end of file +}; diff --git a/tests/vva-fe/cypress.config.ts b/tests/govtool-frontend/cypress.config.ts similarity index 89% rename from tests/vva-fe/cypress.config.ts rename to tests/govtool-frontend/cypress.config.ts index f8728974d..9d6301054 100644 --- a/tests/vva-fe/cypress.config.ts +++ b/tests/govtool-frontend/cypress.config.ts @@ -5,8 +5,8 @@ module.exports = { chromeWebSecurity: false, // experimentalModifyObstructiveThirdPartyCode: true, env: { - baseUrl: "https://vva-sanchonet.cardanoapi.io", - apiUrl: "http://vva-sanchonet.cardanoapi.io/api", + baseUrl: "https://govtool-sanchonet.cardanoapi.io", + apiUrl: "http://govtool-sanchonet.cardanoapi.io/api", disableSecurityTest: false, // set to true for github-ci networkId: "testnet", mobileViewportWidthBreakpoint: 414, @@ -29,4 +29,4 @@ module.exports = { //return cloudPlugin(on, config); }, }, -}; \ No newline at end of file +}; diff --git a/tests/vva-fe/cypress/constants/governanceActions.ts b/tests/govtool-frontend/cypress/constants/governanceActions.ts similarity index 100% rename from tests/vva-fe/cypress/constants/governanceActions.ts rename to tests/govtool-frontend/cypress/constants/governanceActions.ts diff --git a/tests/vva-fe/cypress/constants/wallet.ts b/tests/govtool-frontend/cypress/constants/wallet.ts similarity index 100% rename from tests/vva-fe/cypress/constants/wallet.ts rename to tests/govtool-frontend/cypress/constants/wallet.ts diff --git a/tests/vva-fe/cypress/e2e/0_bootstrap.cy.ts b/tests/govtool-frontend/cypress/e2e/0_bootstrap.cy.ts similarity index 100% rename from tests/vva-fe/cypress/e2e/0_bootstrap.cy.ts rename to tests/govtool-frontend/cypress/e2e/0_bootstrap.cy.ts diff --git a/tests/vva-fe/cypress/e2e/1_user_story_wallet_connect.cy.ts b/tests/govtool-frontend/cypress/e2e/1_user_story_wallet_connect.cy.ts similarity index 100% rename from tests/vva-fe/cypress/e2e/1_user_story_wallet_connect.cy.ts rename to tests/govtool-frontend/cypress/e2e/1_user_story_wallet_connect.cy.ts diff --git a/tests/vva-fe/cypress/e2e/2_user_story_delegate_to_drep.cy.ts b/tests/govtool-frontend/cypress/e2e/2_user_story_delegate_to_drep.cy.ts similarity index 100% rename from tests/vva-fe/cypress/e2e/2_user_story_delegate_to_drep.cy.ts rename to tests/govtool-frontend/cypress/e2e/2_user_story_delegate_to_drep.cy.ts diff --git a/tests/vva-fe/cypress/e2e/3_user_story_drep_registration.cy.ts b/tests/govtool-frontend/cypress/e2e/3_user_story_drep_registration.cy.ts similarity index 100% rename from tests/vva-fe/cypress/e2e/3_user_story_drep_registration.cy.ts rename to tests/govtool-frontend/cypress/e2e/3_user_story_drep_registration.cy.ts diff --git a/tests/vva-fe/cypress/e2e/4_user_story_governance_action_visibility.cy.ts b/tests/govtool-frontend/cypress/e2e/4_user_story_governance_action_visibility.cy.ts similarity index 100% rename from tests/vva-fe/cypress/e2e/4_user_story_governance_action_visibility.cy.ts rename to tests/govtool-frontend/cypress/e2e/4_user_story_governance_action_visibility.cy.ts diff --git a/tests/vva-fe/cypress/e2e/5_user_story_governance_action_functionality.cy.ts b/tests/govtool-frontend/cypress/e2e/5_user_story_governance_action_functionality.cy.ts similarity index 100% rename from tests/vva-fe/cypress/e2e/5_user_story_governance_action_functionality.cy.ts rename to tests/govtool-frontend/cypress/e2e/5_user_story_governance_action_functionality.cy.ts diff --git a/tests/vva-fe/cypress/e2e/6_user_story_miscellaneous.cy.ts b/tests/govtool-frontend/cypress/e2e/6_user_story_miscellaneous.cy.ts similarity index 100% rename from tests/vva-fe/cypress/e2e/6_user_story_miscellaneous.cy.ts rename to tests/govtool-frontend/cypress/e2e/6_user_story_miscellaneous.cy.ts diff --git a/tests/vva-fe/cypress/e2e/actions/cleanUpActions.ts b/tests/govtool-frontend/cypress/e2e/actions/cleanUpActions.ts similarity index 100% rename from tests/vva-fe/cypress/e2e/actions/cleanUpActions.ts rename to tests/govtool-frontend/cypress/e2e/actions/cleanUpActions.ts diff --git a/tests/vva-fe/cypress/e2e/actions/commonActions.ts b/tests/govtool-frontend/cypress/e2e/actions/commonActions.ts similarity index 100% rename from tests/vva-fe/cypress/e2e/actions/commonActions.ts rename to tests/govtool-frontend/cypress/e2e/actions/commonActions.ts diff --git a/tests/vva-fe/cypress/e2e/actions/dRepActions.ts b/tests/govtool-frontend/cypress/e2e/actions/dRepActions.ts similarity index 100% rename from tests/vva-fe/cypress/e2e/actions/dRepActions.ts rename to tests/govtool-frontend/cypress/e2e/actions/dRepActions.ts diff --git a/tests/vva-fe/cypress/e2e/actions/delegateActions.ts b/tests/govtool-frontend/cypress/e2e/actions/delegateActions.ts similarity index 100% rename from tests/vva-fe/cypress/e2e/actions/delegateActions.ts rename to tests/govtool-frontend/cypress/e2e/actions/delegateActions.ts diff --git a/tests/vva-fe/cypress/e2e/actions/governanceActions.ts b/tests/govtool-frontend/cypress/e2e/actions/governanceActions.ts similarity index 100% rename from tests/vva-fe/cypress/e2e/actions/governanceActions.ts rename to tests/govtool-frontend/cypress/e2e/actions/governanceActions.ts diff --git a/tests/vva-fe/cypress/e2e/security/7.1_security_overflow_data_headers.cy.ts b/tests/govtool-frontend/cypress/e2e/security/7.1_security_overflow_data_headers.cy.ts similarity index 100% rename from tests/vva-fe/cypress/e2e/security/7.1_security_overflow_data_headers.cy.ts rename to tests/govtool-frontend/cypress/e2e/security/7.1_security_overflow_data_headers.cy.ts diff --git a/tests/vva-fe/cypress/e2e/security/7.3_security_xss.cy.ts b/tests/govtool-frontend/cypress/e2e/security/7.3_security_xss.cy.ts similarity index 100% rename from tests/vva-fe/cypress/e2e/security/7.3_security_xss.cy.ts rename to tests/govtool-frontend/cypress/e2e/security/7.3_security_xss.cy.ts diff --git a/tests/vva-fe/cypress/e2e/security/7.4_sql_injection.cy.ts b/tests/govtool-frontend/cypress/e2e/security/7.4_sql_injection.cy.ts similarity index 100% rename from tests/vva-fe/cypress/e2e/security/7.4_sql_injection.cy.ts rename to tests/govtool-frontend/cypress/e2e/security/7.4_sql_injection.cy.ts diff --git a/tests/vva-fe/cypress/lib/logger/logger.ts b/tests/govtool-frontend/cypress/lib/logger/logger.ts similarity index 100% rename from tests/vva-fe/cypress/lib/logger/logger.ts rename to tests/govtool-frontend/cypress/lib/logger/logger.ts diff --git a/tests/vva-fe/cypress/lib/wallet/blockfrost.ts b/tests/govtool-frontend/cypress/lib/wallet/blockfrost.ts similarity index 100% rename from tests/vva-fe/cypress/lib/wallet/blockfrost.ts rename to tests/govtool-frontend/cypress/lib/wallet/blockfrost.ts diff --git a/tests/vva-fe/cypress/lib/wallet/cardanoWallet.ts b/tests/govtool-frontend/cypress/lib/wallet/cardanoWallet.ts similarity index 100% rename from tests/vva-fe/cypress/lib/wallet/cardanoWallet.ts rename to tests/govtool-frontend/cypress/lib/wallet/cardanoWallet.ts diff --git a/tests/vva-fe/cypress/lib/wallet/crypto.ts b/tests/govtool-frontend/cypress/lib/wallet/crypto.ts similarity index 100% rename from tests/vva-fe/cypress/lib/wallet/crypto.ts rename to tests/govtool-frontend/cypress/lib/wallet/crypto.ts diff --git a/tests/vva-fe/cypress/lib/wallet/mockWallet.ts b/tests/govtool-frontend/cypress/lib/wallet/mockWallet.ts similarity index 100% rename from tests/vva-fe/cypress/lib/wallet/mockWallet.ts rename to tests/govtool-frontend/cypress/lib/wallet/mockWallet.ts diff --git a/tests/vva-fe/cypress/lib/wallet/setupWallet.ts b/tests/govtool-frontend/cypress/lib/wallet/setupWallet.ts similarity index 100% rename from tests/vva-fe/cypress/lib/wallet/setupWallet.ts rename to tests/govtool-frontend/cypress/lib/wallet/setupWallet.ts diff --git a/tests/vva-fe/cypress/lib/wallet/types.ts b/tests/govtool-frontend/cypress/lib/wallet/types.ts similarity index 100% rename from tests/vva-fe/cypress/lib/wallet/types.ts rename to tests/govtool-frontend/cypress/lib/wallet/types.ts diff --git a/tests/vva-fe/cypress/models/types.ts b/tests/govtool-frontend/cypress/models/types.ts similarity index 100% rename from tests/vva-fe/cypress/models/types.ts rename to tests/govtool-frontend/cypress/models/types.ts diff --git a/tests/vva-fe/cypress/services/apiService.ts b/tests/govtool-frontend/cypress/services/apiService.ts similarity index 100% rename from tests/vva-fe/cypress/services/apiService.ts rename to tests/govtool-frontend/cypress/services/apiService.ts diff --git a/tests/vva-fe/cypress/services/blockfrostService.ts b/tests/govtool-frontend/cypress/services/blockfrostService.ts similarity index 100% rename from tests/vva-fe/cypress/services/blockfrostService.ts rename to tests/govtool-frontend/cypress/services/blockfrostService.ts diff --git a/tests/vva-fe/cypress/services/faucetService.ts b/tests/govtool-frontend/cypress/services/faucetService.ts similarity index 100% rename from tests/vva-fe/cypress/services/faucetService.ts rename to tests/govtool-frontend/cypress/services/faucetService.ts diff --git a/tests/vva-fe/cypress/services/kuberService.ts b/tests/govtool-frontend/cypress/services/kuberService.ts similarity index 100% rename from tests/vva-fe/cypress/services/kuberService.ts rename to tests/govtool-frontend/cypress/services/kuberService.ts diff --git a/tests/vva-fe/cypress/services/types.ts b/tests/govtool-frontend/cypress/services/types.ts similarity index 100% rename from tests/vva-fe/cypress/services/types.ts rename to tests/govtool-frontend/cypress/services/types.ts diff --git a/tests/vva-fe/cypress/state/store.ts b/tests/govtool-frontend/cypress/state/store.ts similarity index 100% rename from tests/vva-fe/cypress/state/store.ts rename to tests/govtool-frontend/cypress/state/store.ts diff --git a/tests/vva-fe/cypress/state/type.ts b/tests/govtool-frontend/cypress/state/type.ts similarity index 100% rename from tests/vva-fe/cypress/state/type.ts rename to tests/govtool-frontend/cypress/state/type.ts diff --git a/tests/vva-fe/cypress/state/walletState.ts b/tests/govtool-frontend/cypress/state/walletState.ts similarity index 100% rename from tests/vva-fe/cypress/state/walletState.ts rename to tests/govtool-frontend/cypress/state/walletState.ts diff --git a/tests/vva-fe/cypress/support/command.d.ts b/tests/govtool-frontend/cypress/support/command.d.ts similarity index 100% rename from tests/vva-fe/cypress/support/command.d.ts rename to tests/govtool-frontend/cypress/support/command.d.ts diff --git a/tests/vva-fe/cypress/support/commands.ts b/tests/govtool-frontend/cypress/support/commands.ts similarity index 100% rename from tests/vva-fe/cypress/support/commands.ts rename to tests/govtool-frontend/cypress/support/commands.ts diff --git a/tests/vva-fe/cypress/support/e2e.ts b/tests/govtool-frontend/cypress/support/e2e.ts similarity index 100% rename from tests/vva-fe/cypress/support/e2e.ts rename to tests/govtool-frontend/cypress/support/e2e.ts diff --git a/tests/vva-fe/cypress/support/utils.ts b/tests/govtool-frontend/cypress/support/utils.ts similarity index 100% rename from tests/vva-fe/cypress/support/utils.ts rename to tests/govtool-frontend/cypress/support/utils.ts diff --git a/tests/vva-fe/cypress/support/validations.ts b/tests/govtool-frontend/cypress/support/validations.ts similarity index 100% rename from tests/vva-fe/cypress/support/validations.ts rename to tests/govtool-frontend/cypress/support/validations.ts diff --git a/tests/vva-fe/package.json b/tests/govtool-frontend/package.json similarity index 95% rename from tests/vva-fe/package.json rename to tests/govtool-frontend/package.json index cdfc3ca38..89136b905 100644 --- a/tests/vva-fe/package.json +++ b/tests/govtool-frontend/package.json @@ -1,5 +1,5 @@ { - "name": "vva-fe-test", + "name": "govtool-frontend-test", "version": "1.0.0", "main": "index.js", "license": "MIT", diff --git a/tests/vva-fe/tsconfig.json b/tests/govtool-frontend/tsconfig.json similarity index 100% rename from tests/vva-fe/tsconfig.json rename to tests/govtool-frontend/tsconfig.json diff --git a/tests/vva-fe/yarn.lock b/tests/govtool-frontend/yarn.lock similarity index 100% rename from tests/vva-fe/yarn.lock rename to tests/govtool-frontend/yarn.lock diff --git a/tests/load-testing/pom.xml b/tests/load-testing/pom.xml index 27cf38a59..f79842b88 100644 --- a/tests/load-testing/pom.xml +++ b/tests/load-testing/pom.xml @@ -2,8 +2,8 @@ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 - io.gatling.vva - vva-be + io.gatling.govtool + govtool-backend 0.0.1 @@ -86,7 +86,7 @@ - + diff --git a/tests/load-testing/src/test/java/org/cardano/vva/ApiService.java b/tests/load-testing/src/test/java/org/cardano/govtool/ApiService.java similarity index 98% rename from tests/load-testing/src/test/java/org/cardano/vva/ApiService.java rename to tests/load-testing/src/test/java/org/cardano/govtool/ApiService.java index a32b3cd86..20fed22a4 100644 --- a/tests/load-testing/src/test/java/org/cardano/vva/ApiService.java +++ b/tests/load-testing/src/test/java/org/cardano/govtool/ApiService.java @@ -1,4 +1,4 @@ -package org.cardano.vva; +package org.cardano.govtool; import io.gatling.javaapi.core.ChainBuilder; diff --git a/tests/load-testing/src/test/java/org/cardano/vva/Engine.java b/tests/load-testing/src/test/java/org/cardano/govtool/Engine.java similarity index 94% rename from tests/load-testing/src/test/java/org/cardano/vva/Engine.java rename to tests/load-testing/src/test/java/org/cardano/govtool/Engine.java index 36f40d19b..3139c4f92 100644 --- a/tests/load-testing/src/test/java/org/cardano/vva/Engine.java +++ b/tests/load-testing/src/test/java/org/cardano/govtool/Engine.java @@ -1,4 +1,4 @@ -package org.cardano.vva; +package org.cardano.govtool; import io.gatling.app.Gatling; import io.gatling.core.config.GatlingPropertiesBuilder; diff --git a/tests/load-testing/src/test/java/org/cardano/vva/IDEPathHelper.java b/tests/load-testing/src/test/java/org/cardano/govtool/IDEPathHelper.java similarity index 95% rename from tests/load-testing/src/test/java/org/cardano/vva/IDEPathHelper.java rename to tests/load-testing/src/test/java/org/cardano/govtool/IDEPathHelper.java index e5ba43868..785768d8a 100644 --- a/tests/load-testing/src/test/java/org/cardano/vva/IDEPathHelper.java +++ b/tests/load-testing/src/test/java/org/cardano/govtool/IDEPathHelper.java @@ -1,4 +1,4 @@ -package org.cardano.vva; +package org.cardano.govtool; import java.net.URISyntaxException; import java.nio.file.Path; @@ -19,7 +19,7 @@ public class IDEPathHelper { Path mavenTargetDirectory = projectRootDir.resolve("target"); Path mavenSrcTestDirectory = projectRootDir.resolve("src").resolve("test"); - mavenSourcesDirectory = mavenSrcTestDirectory.resolve("java/org/cardano/vva"); + mavenSourcesDirectory = mavenSrcTestDirectory.resolve("java/org/cardano/govtool"); mavenResourcesDirectory = mavenSrcTestDirectory.resolve("resources"); mavenBinariesDirectory = mavenTargetDirectory.resolve("test-classes"); resultsDirectory = mavenTargetDirectory.resolve("gatling"); diff --git a/tests/load-testing/src/test/java/org/cardano/vva/Recorder.java b/tests/load-testing/src/test/java/org/cardano/govtool/Recorder.java similarity index 95% rename from tests/load-testing/src/test/java/org/cardano/vva/Recorder.java rename to tests/load-testing/src/test/java/org/cardano/govtool/Recorder.java index 777413128..36807523e 100644 --- a/tests/load-testing/src/test/java/org/cardano/vva/Recorder.java +++ b/tests/load-testing/src/test/java/org/cardano/govtool/Recorder.java @@ -1,4 +1,4 @@ -package org.cardano.vva; +package org.cardano.govtool; import io.gatling.recorder.GatlingRecorder; import io.gatling.recorder.config.RecorderPropertiesBuilder; diff --git a/tests/load-testing/src/test/java/org/cardano/vva/Scenario.java b/tests/load-testing/src/test/java/org/cardano/govtool/Scenario.java similarity index 88% rename from tests/load-testing/src/test/java/org/cardano/vva/Scenario.java rename to tests/load-testing/src/test/java/org/cardano/govtool/Scenario.java index f8640ab67..32fc360ab 100644 --- a/tests/load-testing/src/test/java/org/cardano/vva/Scenario.java +++ b/tests/load-testing/src/test/java/org/cardano/govtool/Scenario.java @@ -1,10 +1,10 @@ -package org.cardano.vva; +package org.cardano.govtool; import io.gatling.javaapi.core.ScenarioBuilder; -import org.cardano.vva.actions.Action; -import org.cardano.vva.actions.AdaHolderAction; -import org.cardano.vva.actions.AuthenticationAction; -import org.cardano.vva.actions.DRepAction; +import org.cardano.govtool.actions.Action; +import org.cardano.govtool.actions.AdaHolderAction; +import org.cardano.govtool.actions.AuthenticationAction; +import org.cardano.govtool.actions.DRepAction; import static io.gatling.javaapi.core.CoreDsl.scenario; diff --git a/tests/load-testing/src/test/java/org/cardano/vva/Test.java b/tests/load-testing/src/test/java/org/cardano/govtool/Test.java similarity index 95% rename from tests/load-testing/src/test/java/org/cardano/vva/Test.java rename to tests/load-testing/src/test/java/org/cardano/govtool/Test.java index b83ffa0b4..6162f7e56 100644 --- a/tests/load-testing/src/test/java/org/cardano/vva/Test.java +++ b/tests/load-testing/src/test/java/org/cardano/govtool/Test.java @@ -1,4 +1,4 @@ -package org.cardano.vva; +package org.cardano.govtool; public class Test { public static void main(String[] args) { diff --git a/tests/load-testing/src/test/java/org/cardano/vva/Utils.java b/tests/load-testing/src/test/java/org/cardano/govtool/Utils.java similarity index 97% rename from tests/load-testing/src/test/java/org/cardano/vva/Utils.java rename to tests/load-testing/src/test/java/org/cardano/govtool/Utils.java index 22952667c..a68f38ff0 100644 --- a/tests/load-testing/src/test/java/org/cardano/vva/Utils.java +++ b/tests/load-testing/src/test/java/org/cardano/govtool/Utils.java @@ -1,4 +1,4 @@ -package org.cardano.vva; +package org.cardano.govtool; import org.bouncycastle.crypto.digests.Blake2bDigest; import org.bouncycastle.util.encoders.Hex; diff --git a/tests/load-testing/src/test/java/org/cardano/vva/actions/Action.java b/tests/load-testing/src/test/java/org/cardano/govtool/actions/Action.java similarity index 82% rename from tests/load-testing/src/test/java/org/cardano/vva/actions/Action.java rename to tests/load-testing/src/test/java/org/cardano/govtool/actions/Action.java index 116b54fca..a29f798fe 100644 --- a/tests/load-testing/src/test/java/org/cardano/vva/actions/Action.java +++ b/tests/load-testing/src/test/java/org/cardano/govtool/actions/Action.java @@ -1,7 +1,7 @@ -package org.cardano.vva.actions; +package org.cardano.govtool.actions; import io.gatling.javaapi.core.ChainBuilder; -import org.cardano.vva.ApiService; +import org.cardano.govtool.ApiService; import static io.gatling.javaapi.core.CoreDsl.*; diff --git a/tests/load-testing/src/test/java/org/cardano/vva/actions/AdaHolderAction.java b/tests/load-testing/src/test/java/org/cardano/govtool/actions/AdaHolderAction.java similarity index 73% rename from tests/load-testing/src/test/java/org/cardano/vva/actions/AdaHolderAction.java rename to tests/load-testing/src/test/java/org/cardano/govtool/actions/AdaHolderAction.java index 37ee937ba..437202bcf 100644 --- a/tests/load-testing/src/test/java/org/cardano/vva/actions/AdaHolderAction.java +++ b/tests/load-testing/src/test/java/org/cardano/govtool/actions/AdaHolderAction.java @@ -1,9 +1,9 @@ -package org.cardano.vva.actions; +package org.cardano.govtool.actions; -import org.cardano.vva.ApiService; -import org.cardano.vva.configs.HeaderConfig; +import org.cardano.govtool.ApiService; +import org.cardano.govtool.configs.HeaderConfig; import io.gatling.javaapi.core.ChainBuilder; -import org.cardano.vva.feeders.RandomDataFeeder; +import org.cardano.govtool.feeders.RandomDataFeeder; import static io.gatling.javaapi.core.CoreDsl.*; diff --git a/tests/load-testing/src/test/java/org/cardano/vva/actions/AuthenticationAction.java b/tests/load-testing/src/test/java/org/cardano/govtool/actions/AuthenticationAction.java similarity index 83% rename from tests/load-testing/src/test/java/org/cardano/vva/actions/AuthenticationAction.java rename to tests/load-testing/src/test/java/org/cardano/govtool/actions/AuthenticationAction.java index 456bd2d05..fb46e53e4 100644 --- a/tests/load-testing/src/test/java/org/cardano/vva/actions/AuthenticationAction.java +++ b/tests/load-testing/src/test/java/org/cardano/govtool/actions/AuthenticationAction.java @@ -1,8 +1,8 @@ -package org.cardano.vva.actions; +package org.cardano.govtool.actions; import io.gatling.javaapi.core.ChainBuilder; -import org.cardano.vva.ApiService; -import org.cardano.vva.feeders.RandomDataFeeder; +import org.cardano.govtool.ApiService; +import org.cardano.govtool.feeders.RandomDataFeeder; import java.util.UUID; diff --git a/tests/load-testing/src/test/java/org/cardano/vva/actions/DRepAction.java b/tests/load-testing/src/test/java/org/cardano/govtool/actions/DRepAction.java similarity index 91% rename from tests/load-testing/src/test/java/org/cardano/vva/actions/DRepAction.java rename to tests/load-testing/src/test/java/org/cardano/govtool/actions/DRepAction.java index b3073b939..1860f6130 100644 --- a/tests/load-testing/src/test/java/org/cardano/vva/actions/DRepAction.java +++ b/tests/load-testing/src/test/java/org/cardano/govtool/actions/DRepAction.java @@ -1,7 +1,7 @@ -package org.cardano.vva.actions; +package org.cardano.govtool.actions; -import org.cardano.vva.ApiService; -import org.cardano.vva.feeders.RandomDataFeeder; +import org.cardano.govtool.ApiService; +import org.cardano.govtool.feeders.RandomDataFeeder; import io.gatling.javaapi.core.ChainBuilder; import static io.gatling.javaapi.core.CoreDsl.*; diff --git a/tests/load-testing/src/test/java/org/cardano/vva/configs/HeaderConfig.java b/tests/load-testing/src/test/java/org/cardano/govtool/configs/HeaderConfig.java similarity index 84% rename from tests/load-testing/src/test/java/org/cardano/vva/configs/HeaderConfig.java rename to tests/load-testing/src/test/java/org/cardano/govtool/configs/HeaderConfig.java index c0f1e41dd..c54b047a0 100644 --- a/tests/load-testing/src/test/java/org/cardano/vva/configs/HeaderConfig.java +++ b/tests/load-testing/src/test/java/org/cardano/govtool/configs/HeaderConfig.java @@ -1,4 +1,4 @@ -package org.cardano.vva.configs; +package org.cardano.govtool.configs; import java.util.Map; diff --git a/tests/load-testing/src/test/java/org/cardano/vva/feeders/RandomDataFeeder.java b/tests/load-testing/src/test/java/org/cardano/govtool/feeders/RandomDataFeeder.java similarity index 95% rename from tests/load-testing/src/test/java/org/cardano/vva/feeders/RandomDataFeeder.java rename to tests/load-testing/src/test/java/org/cardano/govtool/feeders/RandomDataFeeder.java index c9e0d64d6..80d35520b 100644 --- a/tests/load-testing/src/test/java/org/cardano/vva/feeders/RandomDataFeeder.java +++ b/tests/load-testing/src/test/java/org/cardano/govtool/feeders/RandomDataFeeder.java @@ -1,6 +1,6 @@ -package org.cardano.vva.feeders; +package org.cardano.govtool.feeders; -import org.cardano.vva.Utils; +import org.cardano.govtool.Utils; import java.util.Collections; import java.util.Iterator; diff --git a/tests/load-testing/src/test/java/org/cardano/vva/simulations/VvaSimulation.java b/tests/load-testing/src/test/java/org/cardano/govtool/simulations/VvaSimulation.java similarity index 98% rename from tests/load-testing/src/test/java/org/cardano/vva/simulations/VvaSimulation.java rename to tests/load-testing/src/test/java/org/cardano/govtool/simulations/VvaSimulation.java index 0fbbe2609..ff61cf533 100644 --- a/tests/load-testing/src/test/java/org/cardano/vva/simulations/VvaSimulation.java +++ b/tests/load-testing/src/test/java/org/cardano/govtool/simulations/VvaSimulation.java @@ -1,6 +1,6 @@ -package org.cardano.vva.simulations; +package org.cardano.govtool.simulations; -import org.cardano.vva.Scenario; +import org.cardano.govtool.Scenario; import io.gatling.javaapi.core.Simulation; import io.gatling.javaapi.http.HttpProtocolBuilder; diff --git a/tests/load-testing/src/test/resources/gatling.conf b/tests/load-testing/src/test/resources/gatling.conf index 1fcefc33b..48104c3d7 100644 --- a/tests/load-testing/src/test/resources/gatling.conf +++ b/tests/load-testing/src/test/resources/gatling.conf @@ -31,7 +31,7 @@ gatling { } } directory { - #org.cardano.vva.simulations = "" # If set, directory where simulation classes are located + #org.cardano.govtool.simulations = "" # If set, directory where simulation classes are located #resources = "" # If set, directory where resources, such as feeder files and request bodies, are located #reportsOnly = "" # If set, name of report folder to look for in order to generate its report #binaries = "" # If set, name of the folder where compiles classes are located: Defaults to GATLING_HOME/target. diff --git a/tests/load-testing/src/test/resources/recorder.conf b/tests/load-testing/src/test/resources/recorder.conf index 8db3ade3e..00808757c 100644 --- a/tests/load-testing/src/test/resources/recorder.conf +++ b/tests/load-testing/src/test/resources/recorder.conf @@ -6,15 +6,15 @@ recorder { # package = "" # The package's name of the generated simulation # className = "RecordedSimulation" # The name of the generated Simulation class # thresholdForPauseCreation = 100 # The minimum time, in milliseconds, that must pass between requests to trigger a pause creation - # saveConfig = false # When set to true, the configuration from the org.cardano.vva.Recorder GUI overwrites this configuration - # headless = false # When set to true, run the org.cardano.vva.Recorder in headless mode instead of the GUI + # saveConfig = false # When set to true, the configuration from the org.cardano.govtool.Recorder GUI overwrites this configuration + # headless = false # When set to true, run the org.cardano.govtool.Recorder in headless mode instead of the GUI # harFilePath = "" # The path of the HAR file to convert # format = "java8" # java8|java11|java17|kotlin|scala } filters { # enable = false # If filters are enabled - # allowList = [] # The list of ressources patterns that are part of the org.cardano.vva.Recorder's allow list - # denyList = [] # The list of ressources patterns that are part of the org.cardano.vva.Recorder's deny list + # allowList = [] # The list of ressources patterns that are part of the org.cardano.govtool.Recorder's allow list + # denyList = [] # The list of ressources patterns that are part of the org.cardano.govtool.Recorder's deny list } http { # automaticReferer = true # When set to false, write the referer + enable 'disableAutoReferer' in the generated simulation diff --git a/tests/test-infrastructure/.env.example b/tests/test-infrastructure/.env.example index 15cc6dc9d..fd9687eeb 100644 --- a/tests/test-infrastructure/.env.example +++ b/tests/test-infrastructure/.env.example @@ -1,4 +1,4 @@ -STACK_NAME=vva +STACK_NAME=govtool BASE_DOMAIN=cardanoapi.io BLOCKFROST_API_URL="" -BLOCKFROST_PROJECT_ID="" \ No newline at end of file +BLOCKFROST_PROJECT_ID="" diff --git a/tests/test-infrastructure/README.md b/tests/test-infrastructure/README.md index c69268078..99a872d26 100644 --- a/tests/test-infrastructure/README.md +++ b/tests/test-infrastructure/README.md @@ -1,7 +1,7 @@ -VVA Test Infrastructure +GovTool Test Infrastructure ==================== -Services required for testing VVA +Services required for testing GovTool ## 1. Setting up the services @@ -23,7 +23,7 @@ There's a helper script `deploy-swarm.sh` to load the environment variables from cd ./test/test-infrastructire # cd into the test-infrastructure folder docker swarm init # if swarm mode is not enabled yet. docker compose build # build the images -docker node update xxxx --label-add vva-test-stack=true ## set the node to be used for deploying the services +docker node update xxxx --label-add govtool-test-stack=true ## set the node to be used for deploying the services ./gen-configs.sh # generate configs and secrets. ./deploy-swarm.sh prepare # start postgres and nginx sleep 30 # wait for 30 secs for postgres to be healthy @@ -57,7 +57,7 @@ The analysis generated by sonar-scanner is saved to SonarQube server for better username: admin password: admin ``` -- Create new project and set the projectKey in file [src/vva-fe/sonar-project.properties](../../src/vva-fe/sonar-project.properties) +- Create new project and set the projectKey in file [govtool/frontend/sonar-project.properties](../../govtool/frontend/sonar-project.properties) - Update the github action secrets - SONAR_HOST_URL - SONAR_TOKEN @@ -74,7 +74,7 @@ It is used for visualizing the test metrics and the api response times over time ### Initial Configuration - Setup initial account for ligin via the webapp. - - Under database section in admin settings, add the `vva_lithghouse` and `vva_metrics` databases + - Under database section in admin settings, add the `govtool_lithghouse` and `govtool_metrics` databases - Select the database and add visualizations, queries for the data. ## LightHouse Report Server @@ -131,4 +131,4 @@ Kuber makes it easy to construct and submit transaction from the frontend. **Docker Image:** [dquadrant/kuber:70be9b0166177eab5cf33e603fd3dc579e14cf31](https://hub.docker.com/layers/dquadrant/kuber/70be9b0166177eab5cf33e603fd3dc579e14cf31/images/sha256-d3b3f7c2304da8c4777155b26220238b682c81a3ff2b14753a5dc41c4f151364?context=explore) ### Initial Configuration -- update `CYPRESS_kuberApiUrl` variable in [.github/workflows/test_integration_cypress.yml](../../.github/workflows/test_integration_cypress.yml) \ No newline at end of file +- update `CYPRESS_kuberApiUrl` variable in [.github/workflows/test_integration_cypress.yml](../../.github/workflows/test_integration_cypress.yml) diff --git a/tests/test-infrastructure/deploy-swarm.sh b/tests/test-infrastructure/deploy-swarm.sh index 6b20e2ab1..0c94386a8 100755 --- a/tests/test-infrastructure/deploy-swarm.sh +++ b/tests/test-infrastructure/deploy-swarm.sh @@ -39,7 +39,7 @@ then elif [ "$1" == "finalize" ] then ## apply the environment to compose file - ## deploy the vva test infrastructure stack + ## deploy the govtool test infrastructure stack envsubst < ./docker-compose.yml > ./docker-compose-rendered.yml docker stack deploy -c './docker-compose-rendered.yml' ${STACK_NAME} else diff --git a/tests/test-infrastructure/docker-compose-services.yml b/tests/test-infrastructure/docker-compose-services.yml index 9a2d3421e..d7563a2ad 100644 --- a/tests/test-infrastructure/docker-compose-services.yml +++ b/tests/test-infrastructure/docker-compose-services.yml @@ -54,7 +54,7 @@ services: deploy: placement: constraints: - - node.labels.vva-test-stack == true + - node.labels.govtool-test-stack == true restart_policy: delay: "10s" postgres: @@ -83,6 +83,6 @@ services: deploy: placement: constraints: - - node.labels.vva-test-stack == true + - node.labels.govtool-test-stack == true restart_policy: - delay: "30s" \ No newline at end of file + delay: "30s" diff --git a/tests/test-infrastructure/docker-compose.yml b/tests/test-infrastructure/docker-compose.yml index 995465b37..918fba7dc 100644 --- a/tests/test-infrastructure/docker-compose.yml +++ b/tests/test-infrastructure/docker-compose.yml @@ -61,7 +61,7 @@ services: deploy: placement: constraints: - - node.labels.vva-test-stack == true + - node.labels.govtool-test-stack == true restart_policy: delay: "30s" resources: @@ -77,7 +77,7 @@ services: retries: 5 metrics_api: - image: voltaire-era/vva-metrics-api + image: voltaire-era/govtool-metrics-api build: context: ../test-metrics-api @@ -98,7 +98,7 @@ services: deploy: placement: constraints: - - node.labels.vva-test-stack == true + - node.labels.govtool-test-stack == true restart_policy: delay: "30s" resources: @@ -122,7 +122,7 @@ services: deploy: placement: constraints: - - node.labels.vva-test-stack == true + - node.labels.govtool-test-stack == true restart_policy: delay: "30s" resources: @@ -132,18 +132,18 @@ services: memory: 300M governance-action-loader-ui: - image: voltaire-era/vva-governance-action-loader + image: voltaire-era/govtool-governance-action-loader build: context: ../../src/gov-action-loader-fe dockerfile: Dockerfile environment: - VIRTUAL_HOST: https://vva-governance.${BASE_DOMAIN} + VIRTUAL_HOST: https://govtool-governance.${BASE_DOMAIN} networks: - frontend deploy: placement: constraints: - - node.labels.vva-test-stack == true + - node.labels.govtool-test-stack == true restart_policy: delay: "30s" resources: @@ -153,7 +153,7 @@ services: memory: 100M governance-action-loader-api: - image: voltaire-era/vva-kuber-proposal-loader-proxy + image: voltaire-era/govtool-kuber-proposal-loader-proxy build: context: ../../src/gov-action-loader-be dockerfile: Dockerfile @@ -162,14 +162,14 @@ services: KUBER_API_KEY: "" BLOCKFROST_API_URL: "${BLOCKFROST_API_URL}" BLOCKFROST_PROJECT_ID: "${BLOCKFROST_PROJECT_ID}" - VIRTUAL_HOST: https://vva-governance.${BASE_DOMAIN}/api/ -> /api/ + VIRTUAL_HOST: https://govtool-governance.${BASE_DOMAIN}/api/ -> /api/ networks: - default - frontend deploy: placement: constraints: - - node.labels.vva-test-stack == true + - node.labels.govtool-test-stack == true restart_policy: delay: "30s" resources: @@ -196,7 +196,7 @@ services: deploy: placement: constraints: - - node.labels.vva-test-stack == true + - node.labels.govtool-test-stack == true restart_policy: delay: 15s resources: @@ -225,7 +225,7 @@ services: deploy: placement: constraints: - - node.labels.vva-test-stack == true + - node.labels.govtool-test-stack == true restart_policy: condition: on-failure delay: 15s @@ -241,7 +241,7 @@ services: deploy: placement: constraints: - - node.labels.vva-test-stack == true + - node.labels.govtool-test-stack == true restart_policy: delay: "30s" diff --git a/tests/test-infrastructure/gen-configs.sh b/tests/test-infrastructure/gen-configs.sh index da98fbf4f..b92d6d65d 100755 --- a/tests/test-infrastructure/gen-configs.sh +++ b/tests/test-infrastructure/gen-configs.sh @@ -44,9 +44,9 @@ if [ "$1" == "clean" ]; then fi ## Check if one fo the secrets already exists -if [[ -f ./secrets/vva_postgres_user ]] +if [[ -f ./secrets/govtool_postgres_user ]] then - echo "File ./secrets/vva_postgres_user already exists." + echo "File ./secrets/govtool_postgres_user already exists." echo "Assuming that the secrets were already generated" echo " Use:" echo " > ./gen-configs.sh clean" @@ -60,9 +60,9 @@ mkdir -p ./secrets; ## save secrets to secrets folder -echo -n $POSTGRES_USER > ./secrets/vva_postgres_user -echo -n $POSTGRES_PASSWORD > ./secrets/vva_postgres_password -echo -n $metrics_api_secret > ./secrets/vva_metrics_api_secret +echo -n $POSTGRES_USER > ./secrets/govtool_postgres_user +echo -n $POSTGRES_PASSWORD > ./secrets/govtool_postgres_password +echo -n $metrics_api_secret > ./secrets/govtool_metrics_api_secret ## loop over templates and updaete them. @@ -108,4 +108,4 @@ for SECRET_FILE in $(ls ./secrets_template) do echo -n "Creating Secret: ${STACK_NAME}_${SECRET_FILE} " cat "./secrets/${STACK_NAME}_${SECRET_FILE}" | docker secret create "${STACK_NAME}_${SECRET_FILE}" - ||true -done \ No newline at end of file +done diff --git a/tests/test-metrics-api/.env.example b/tests/test-metrics-api/.env.example index 6300825a2..ab6a5e93d 100644 --- a/tests/test-metrics-api/.env.example +++ b/tests/test-metrics-api/.env.example @@ -1,6 +1,6 @@ PGHOST='office.sireto.dev' PGPORT=8080 -PGDATABASE='vva' +PGDATABASE='govtool' PGUSER='postgres' PGPASSWORD='your password' API_SECRET_TOKEN='some-token' diff --git a/tests/test-metrics-api/README.md b/tests/test-metrics-api/README.md index e8a176c7f..5526d0adb 100644 --- a/tests/test-metrics-api/README.md +++ b/tests/test-metrics-api/README.md @@ -1,6 +1,6 @@ # Test Metrics API -This api is intended to be called by Github Action whenever a new commit to vva app has been made and new metrics are obtained. The api expects a POST request with a JSON file of the metrics which will then update the database with the new metrics. +This api is intended to be called by Github Action whenever a new commit to GovTool app has been made and new metrics are obtained. The api expects a POST request with a JSON file of the metrics which will then update the database with the new metrics. ## Prerequisite diff --git a/tests/vva-be/test_cases/test_ada_holder.py b/tests/vva-be/test_cases/test_ada_holder.py deleted file mode 100644 index 963b42b72..000000000 --- a/tests/vva-be/test_cases/test_ada_holder.py +++ /dev/null @@ -1,14 +0,0 @@ -from models.TestData import AdaHolder, Delegation - -def test_ada_delegation(vva_api, ada_holder_delegate_to_drep): - print(ada_holder_delegate_to_drep) - response = vva_api.ada_holder_get_current_delegation(ada_holder_delegate_to_drep["stakeKey"]) - resp = response.json() - if resp: - assert ada_holder_delegate_to_drep["drepId"] in resp - - -def test_check_voting_power(vva_api, ada_holder_delegate_to_drep): - response = vva_api.ada_holder_get_voting_power(ada_holder_delegate_to_drep["stakeKey"]) - ada_holder_voting_power = response.json() - assert isinstance(ada_holder_voting_power, int)