Skip to content

CyberArkForTheCommunity/jobli-backend

Repository files navigation

jobli-service

Prerequisite installation

You should install the following tools before starting to work

  1. Install Python 3.8.+
  2. Install pipenv for python dependency management
  • zsh shell (MacOS):
    pip install pipenv==2018.11.26
    echo export PIPENV_VENV_IN_PROJECT=true >> ~/.zshrc
  • bash shell (Linux):
    pip install pipenv==2018.11.26
    echo export PIPENV_VENV_IN_PROJECT=true >> ~/.bashrc
  1. Node.js download and install from: https://nodejs.org/en/download Then configure npm proxy
  2. Install AWS CDK
    npm install -g aws-cdk

Getting started

  1. Load your github.com ssh key in order to resolve dependencies next step

    ssh-add ~/.ssh/id_rsa
  2. Install dependencies

    pipenv install --dev 
  3. Enter virtual env by:

    pipenv shell 
  4. Retrieve AWS token for one day, execute the following:

    saml2aws login

    For more info go to https://github.com/Versent/saml2aws

Deploy

In order to deploy infra-library CloudFormation stack resources for example: KMS, S3

python deploy.py

You can also deploy faster if dependencies were not changed by running the following:

python deploy.py --skip-deps

Configure Google App credentials

Running python deploy.py will fail on missing environment variables. Do the following steps to fix this

  1. Go to: https://console.cloud.google.com/apis/credentials/oauthclient/909417432201-gkh6vpm1vdel1kq95j2pd3chtu3o8vua.apps.googleusercontent.com?authuser=1&project=jobliapp1&supportedpurview=project
  2. Sign in Jobli google account with jobli.akim@gmail.com user & password (you can also extract it from git secrets if you have permission)
  3. Go to created .env file under the project home directory and add (replace XXXX with actual Client ID & Secret shown in link above): GOOGLE_CLIENT_ID=XXXX GOOGLE_CLIENT_SECRET=XXXX
  4. run again: python deploy.py

Run tests

In order to run unit tests

pytest -v tests/unit

In order to run integration tests you should deploy first and then you can run

pytest -v tests/integration

In order to run all tests

pytest -v tests

Destroy

In order to delete the CloudFormation stack deployed in the last step:

python env_destroy.py

One time Google app configuration

Steps in creating a google application for authentication in jobli after login with google account credentials: https://console.cloud.google.com/apis

  1. Create a project with Google Account ("Jobli")
  2. Configure Oauth consent page: https://console.cloud.google.com/apis/credentials/consent?authuser=2&project=jobli-328707:
    • Configure application as "External" and add support email to be presented in Consent Page
    • As long "Publishing status" is in Testing status, in order to to authenticate with app using google account, you must add your email to the Test Users
  3. Create an API application by going to "Credentials" section: https://console.cloud.google.com/apis/credentials?authuser=2&project=jobli-328707:
    • Give Name for for API Client (for internal use, not displayed to users).
    • Add under "Authorized JavaScript origins our cognito custom domain: https://.auth..amazoncognito.com
    • Add under "Authorized JavaScript redirect URIs the cognito redirect URI: https://.auth..amazoncognito.com/oauth2/idpresponse

Deleting a seeker user data

For debug purpose, you will be able to delete yours seeker user data by creating a DELETE request via postman You shall login to the system via the client application, get the jwt authorization token, pass it as an 'Authorization' header of a DELETE /api/seeker without body. After you get successful result, reload the client application and start over as a new seeker.

Jobs and Employers upload for tests purposes

In order to upload a test data, update the test/resources/Jobli_jobs.json file with employers and jobs. The file is loaded into the system, by running the tests/integration/test_jobli_employers_it.py - test_create_jobli_employer_and_jobs_from_file integration test.
Few notes about the upload file process:

  • Only new employers will be created. If the upload process find in file an employer that already exists in the system (by the business name) that employer won't be loaded again
  • Following employer values are hard coded in the upload test: address, employer_email, employer_terms and business_website

Before data upload the system components must be installed on AWS (python deploy.py see above)

Uncomment the @pytest.mark.skip annotation Triggering file upload:
pytest tests/integration/test_jobli_employers_it.py::test_create_jobli_employer_and_jobs_from_file

Development Notes:

Project additional dependencies can be added in Pipfile

  • Runtime dependencies under [packages] section
  • Development only dependencies under [dev-packages] section

Deployment of this project is done via AWS CDK tools. If you want to add/remove AWS resources, please update the following file:

  • /cdk/jobli_service_cdk/service_stack/jobli_construct.py

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages