Skip to content

Commit

Permalink
fix: merge confilcts
Browse files Browse the repository at this point in the history
  • Loading branch information
wm798222 committed Feb 26, 2021
2 parents 4dbdbb8 + b0412ef commit 82d46f6
Show file tree
Hide file tree
Showing 109 changed files with 4,346 additions and 4,029 deletions.
12 changes: 4 additions & 8 deletions .github/workflows/treetracker-wallet-api-build-deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -64,14 +64,6 @@ jobs:
file: ./Dockerfile
push: true
tags: greenstand/treetracker-wallet-api:${{ steps.package-version.outputs.current-version }}
- name: Build snapshot and push on merge
id: docker_build_merge
uses: docker/build-push-action@v2
with:
context: ./
file: ./Dockerfile
push: true
tags: greenstand/treetracker-wallet-api:latest
- shell: bash
run: |
echo '${{ steps.package-version.outputs.current-version }}' > image-tag
Expand Down Expand Up @@ -118,6 +110,10 @@ jobs:
token: ${{ secrets.DIGITALOCEAN_TOKEN }}
- name: Save DigitalOcean kubeconfig
run: doctl kubernetes cluster kubeconfig save ${{ secrets.CLUSTER_NAME }}
- name: Delete completed migration jobs prior to deployment
run: kubectl -n wallet-api delete job --ignore-not-found=true wallet-db-migration-job
- name: Update kubernetes resources
run: kubectl -n wallet-api apply --wait -k ./deployment/
- name: Attempt to wait for migration job to complete
run: kubectl wait --for=condition=complete --timeout=45s job/wallet-db-migration-job

45 changes: 45 additions & 0 deletions .github/workflows/treetracker-wallet-api-deploy-prod.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@

name: Deploy to Production Env


on:
workflow_dispatch:
inputs:
environment:
description: 'git-tag'
required: true

env:
project-directory: ./

jobs:
deploy-test:
name: Deploy selected tag to production environment, requires approval
runs-on: ubuntu-latest
if: |
github.repository == 'Greenstand/treetracker-wallet-api'
steps:
- uses: actions/checkout@v2
with:
ref: ${{ github.event.inputs.git-tag }}
- name: get-npm-version
id: package-version
uses: martinbeentjes/npm-get-version-action@master
with:
path: ./
- name: Install kustomize
run: curl -s "https://raw.githubusercontent.com/kubernetes-sigs/kustomize/master/hack/install_kustomize.sh" | bash
- name: Copy kustomize.yml
run: cp deployment/kustomize/kustomization.yaml deployment/kustomization.yaml
- name: Run kustomize
run: (cd deployment && ../kustomize edit set image greenstand/treetracker-wallet-api:${{ steps.package-version.outputs.current-version }} )
- name: Install doctl for kubernetes
uses: digitalocean/action-doctl@v2
with:
token: ${{ secrets.DIGITALOCEAN_PRODUCTION_TOKEN }}
- name: Save DigitalOcean kubeconfig
run: doctl kubernetes cluster kubeconfig save ${{ secrets.PRODUCTION_CLUSTER_NAME }}
- name: Delete completed migration jobs prior to deployment
run: kubectl -n wallet-api delete job --ignore-not-found=true wallet-db-migration-job
- name: Update kubernetes resources
run: kubectl -n wallet-api apply --wait -k ./deployment/
2 changes: 2 additions & 0 deletions .github/workflows/treetracker-wallet-api-deploy-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,5 +39,7 @@ jobs:
token: ${{ secrets.DIGITALOCEAN_TOKEN }}
- name: Save DigitalOcean kubeconfig
run: doctl kubernetes cluster kubeconfig save ${{ secrets.TEST_CLUSTER_NAME }}
- name: Delete completed migration jobs prior to deployment
run: kubectl -n wallet-api delete job wallet-db-migration-job
- name: Update kubernetes resources
run: kubectl -n wallet-api apply --wait -k ./deployment/
99 changes: 99 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,102 @@
# [1.8.0](https://github.com/Greenstand/treetracker-wallet-api/compare/v1.7.4...v1.8.0) (2021-02-20)


### Features

* use SERIALIZABLE transaction isolation level ([91b8f11](https://github.com/Greenstand/treetracker-wallet-api/commit/91b8f1148763019e7f297a3642f671f5cfd6f0fb))

## [1.7.4](https://github.com/Greenstand/treetracker-wallet-api/compare/v1.7.3...v1.7.4) (2021-02-19)


### Bug Fixes

* delete pre-existing job ([fea4677](https://github.com/Greenstand/treetracker-wallet-api/commit/fea4677d9827e98a2a02db14072f49928ce9e815))

## [1.7.3](https://github.com/Greenstand/treetracker-wallet-api/compare/v1.7.2...v1.7.3) (2021-02-19)


### Bug Fixes

* fix create demo wallet script ([3601917](https://github.com/Greenstand/treetracker-wallet-api/commit/360191767521fce7d9071aa6c666c5a88de1e7d7))

## [1.7.2](https://github.com/Greenstand/treetracker-wallet-api/compare/v1.7.1...v1.7.2) (2021-02-18)


### Bug Fixes

* do not rely on latest tag, use kustomization ([a9afb84](https://github.com/Greenstand/treetracker-wallet-api/commit/a9afb84cbe2c3a17589c549ef294ab64ea0fd4b0))
* remove unnecessary migration ([f7916fc](https://github.com/Greenstand/treetracker-wallet-api/commit/f7916fc1cf582021588849483537c163006c7634))

## [1.7.1](https://github.com/Greenstand/treetracker-wallet-api/compare/v1.7.0...v1.7.1) (2021-02-18)


### Bug Fixes

* clean up wallet table schema ([f329cdf](https://github.com/Greenstand/treetracker-wallet-api/commit/f329cdfbec4b8a47b89c06c51c7e55a629898607))
* try to get wait for job via kubectl working ([77c9077](https://github.com/Greenstand/treetracker-wallet-api/commit/77c907701f15ca46e0742b538d0dcc2223eb8315))

# [1.7.0](https://github.com/Greenstand/treetracker-wallet-api/compare/v1.6.1...v1.7.0) (2021-02-18)


### Bug Fixes

* all tests passing ([612cf55](https://github.com/Greenstand/treetracker-wallet-api/commit/612cf555dc9e64539481377ff984b902bd544263))
* all unit tests passing ([a7555fb](https://github.com/Greenstand/treetracker-wallet-api/commit/a7555fb0278508b38190dcd2f9973a4f56b03c1c))
* all unit tests working ([59a9c99](https://github.com/Greenstand/treetracker-wallet-api/commit/59a9c99665915a22e2bcdb473bba9352b1804576))
* clean up debugging logs ([4c927d2](https://github.com/Greenstand/treetracker-wallet-api/commit/4c927d2a59155e5c39e221ac6ae25d4f4f437613))
* fix calls to test routines in package.json ([dd3b340](https://github.com/Greenstand/treetracker-wallet-api/commit/dd3b340ced6d21779d5d99d825c7f586eda11240))
* fix seed tests that did not use knex ([1895bcf](https://github.com/Greenstand/treetracker-wallet-api/commit/1895bcf15ed936b8bdeec7ea3c0c10fcb461f02a))
* fix some integration tests ([66cbe0e](https://github.com/Greenstand/treetracker-wallet-api/commit/66cbe0ea7baf0f1657d5569cbc94c4e28b5faa5d))
* fixes to code found by integration testing ([f80691e](https://github.com/Greenstand/treetracker-wallet-api/commit/f80691e64674be284e7eada52469384e9fb1b2a6))
* fixing integration tests and codes ([e4ae6e1](https://github.com/Greenstand/treetracker-wallet-api/commit/e4ae6e11d8f72ed4b9c634c257ce006727ebd992))
* remove old supertest file ([26d2168](https://github.com/Greenstand/treetracker-wallet-api/commit/26d21687b2b0f1708db37644f6e342dad987103f))
* remove unused and incorrectly configured database pool module ([b9094b5](https://github.com/Greenstand/treetracker-wallet-api/commit/b9094b5104300e6a5ab02e2bf92c24005d4cac40))
* remove unused import ([16b285c](https://github.com/Greenstand/treetracker-wallet-api/commit/16b285ce1a313ed03d84b3c0a5ebec7a00b644a4))
* set scheme for seed tests in ci ([2ffe6eb](https://github.com/Greenstand/treetracker-wallet-api/commit/2ffe6ebdf582b05f3be8a53dfc82a82099f934e4))
* set scheme for seed tests in ci ([fc80a05](https://github.com/Greenstand/treetracker-wallet-api/commit/fc80a0592bbe65e876647d767808fe7398b8255b))
* switch UUID for all ids, and set default value ([1249c91](https://github.com/Greenstand/treetracker-wallet-api/commit/1249c9198f4a2838dc0e30a704ed481e130e184e))
* switch UUID for all ids, and set default value ([ed8f27d](https://github.com/Greenstand/treetracker-wallet-api/commit/ed8f27d6bee88878d9897ddf8055e7a777a57ff7))
* use .spec.js for all integration test scopes ([7fa943f](https://github.com/Greenstand/treetracker-wallet-api/commit/7fa943fbae6b0bb5ffeb1d3445af7c0623908f40))
* use the ci env for unit tests in github actions ([1bb0b1b](https://github.com/Greenstand/treetracker-wallet-api/commit/1bb0b1b385ef495abae1a37a6cf4103c1c6367e7))
* wip - fix unit tests for uuid ids ([70edfe7](https://github.com/Greenstand/treetracker-wallet-api/commit/70edfe7a3748b8996d6ba95b02adff20781e0b14))
* wip refactor integration tests ([44d2f7c](https://github.com/Greenstand/treetracker-wallet-api/commit/44d2f7cf8d3b2391bf121725985082d246496b66))
* work in progress ([af99b9d](https://github.com/Greenstand/treetracker-wallet-api/commit/af99b9d3d366ea7423efa29a5d049a27e7e991f9))
* work in progress ([69935b6](https://github.com/Greenstand/treetracker-wallet-api/commit/69935b61725fd8c0c6292b4f1c05a5495b627c31))
* work to get integration working with primary key UUIDs, plus a log ([a234a0c](https://github.com/Greenstand/treetracker-wallet-api/commit/a234a0c17095fe14d7f11f5748aa79b4d26fa9a8))


### Features

* switch to UUID for all primary keys ([706581e](https://github.com/Greenstand/treetracker-wallet-api/commit/706581ec22f655bab177702f798b8cbfe67e8fee))
* switch to UUID for all primary keys ([5bd9606](https://github.com/Greenstand/treetracker-wallet-api/commit/5bd9606b3814571844d969702e142c3f62607260))
* use the webmap api for capture data ([9d4fbe6](https://github.com/Greenstand/treetracker-wallet-api/commit/9d4fbe6e3fde98212f45e805811d782ef6ec768c))
* use the webmap api for capture data ([d2cfc0a](https://github.com/Greenstand/treetracker-wallet-api/commit/d2cfc0ae66cfb0f6940b8407cd2cbd2833a44048))
* wip updating tests and models to uuid as id type, making tests more maintainable ([86babd5](https://github.com/Greenstand/treetracker-wallet-api/commit/86babd55cb62c1e693d9beaf08e00a789c6c854e))
* wip updating tests and models to uuid as id type, making tests more maintainable ([9ef0d0f](https://github.com/Greenstand/treetracker-wallet-api/commit/9ef0d0f0a9509f9775acc9fbfdd0269e9ae4e56f))

## [1.6.1](https://github.com/Greenstand/treetracker-wallet-api/compare/v1.6.0...v1.6.1) (2021-02-11)


### Bug Fixes

* update db-migrate package ([b1514cb](https://github.com/Greenstand/treetracker-wallet-api/commit/b1514cb8c183535c46e9990570e975e5eaaa9e52))
* update pg package ([88486b3](https://github.com/Greenstand/treetracker-wallet-api/commit/88486b33c3e835121b2a389b6c9b2d20883eb6db))

# [1.6.0](https://github.com/Greenstand/treetracker-wallet-api/compare/v1.5.0...v1.6.0) (2021-01-22)


### Bug Fixes

* add db-migrate in package.json back ([6ac5e6b](https://github.com/Greenstand/treetracker-wallet-api/commit/6ac5e6bdbb86f5dc7cf5006e9bbdc1afb612ea4d))
* broken int test ([8a8cc9e](https://github.com/Greenstand/treetracker-wallet-api/commit/8a8cc9ef83c2878ad598c54d8fe9a01ea627d53a))
* rerun npm install ([08634d7](https://github.com/Greenstand/treetracker-wallet-api/commit/08634d73417a3636b8d502202db19e25ae869ae7))
* update yaml for issue 100 ([38f6622](https://github.com/Greenstand/treetracker-wallet-api/commit/38f6622b5c78e14a3806be3e753430b4d5fb1092))


### Features

* 2nd commit for issue 100 ([22b6bb4](https://github.com/Greenstand/treetracker-wallet-api/commit/22b6bb4221f7f7b7ca96030ac4e52165b941e983))

# [1.5.0](https://github.com/Greenstand/treetracker-wallet-api/compare/v1.4.1...v1.5.0) (2021-01-10)


Expand Down
18 changes: 10 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,12 @@ To view the specs for the new API visit https://editor.swagger.io and load the Y

## Project Setup

Open terminal and navigate to a folder to install this project:
Fork this repository to your account and clone from this forked copy.

Open terminal, navigate to a folder to install this project, and run the below commands:

```
git clone https://github.com/Greenstand/treetracker-token-trading-api.git
git clone https://github.com/[YOUR GITHUB USERNAME]/treetracker-wallet-api.git
```
Install all necessary dependencies:
Expand Down Expand Up @@ -73,9 +75,7 @@ DATABASE_SCHEMA=wallets
PUBLIC_KEY="-----BEGIN PUBLIC KEY-----\nXXXXXXXXXXXXXXXX\n-----END PUBLIC KEY-----"
PRIVATE_KEY="-----BEGIN RSA PRIVATE KEY-----\nXXXXXXXXXXXXXXXXXXXXX\n-----END RSA PRIVATE KEY-----"
NODE_LOG_LEVEL=trace
PUBLIC_KEY="[copy and paste all contents from your jwtRS256.key.pub]"
PRIVATE_KEY="[copy and paste all contents from your jwtRS256.key]"
NODE_LOG_LEVEL=trace
```
Copy and paste the PUBLIC_KEY and PRIVATE_KEY strings above exactly as is. Then, go to your jwtRS256.key.pub and jwtRS256.key files generated earlier in your config folder and remove all the new lines. Replace the "XXXXX.." with the key codes between the BEGIN PUBLIC KEY and END PUBLIC KEY sections (pasted as a single line) from your respective jwtRS256.key.pub and jwtRS256.key files. **Don't just copy and paste the whole block from these files into these sections since we need to preserve this format with the "\n" injected into the strings here.
Expand Down Expand Up @@ -114,7 +114,7 @@ To quickly build the necessary tables for your wallets schema, run:
db-migrate --env dev up
```

If you have not installed db-migrate globally, you can run:
If you have not installed db-migrate globally, while in the database folder, you can run:

```
../node_modules/db-migrate/bin/db-migrate --env dev up
Expand All @@ -127,7 +127,7 @@ If you run into issue:
```
ifError got unwanted exception: function uuid_generate_v4() does not exist
```
Delete and recreate your wallets schema and then open postgress terminal and run to install the required extension
Delete and recreate your wallets schema and then inside your postgres connection in terminal, run to install the required extension

```
\c <db name>
Expand Down Expand Up @@ -470,4 +470,6 @@ Create your local git branch and rebase it from the shared master branch. Please

Please follow this convention for commit messages [here](https://www.conventionalcommits.org/en/v1.0.0/)

When you are ready to submit a pull request from your local branch, please rebase your branch off of the shared master branch again to integrate any new updates in the codebase before submitting. Any developers joining the project should feel free to review any outstanding pull requests and assign themselves to any open tickets on the Issues list.
Any developers joining the project should feel free to review any outstanding pull requests and assign themselves to any open tickets on the Issues list. You can make a draft pull request as you are working on any open issue that interests you, and any changes you make on your local branch can be continually synced with this draft until you are ready to submit. Remember to push your changes up to your forked repository and then make any pull requests from your forked branch to the Greenstand master repository branch.

When you are ready to submit a pull request, please rebase your branch off of the shared master branch again to integrate any new updates in the codebase before submitting.
56 changes: 56 additions & 0 deletions __tests__/auth.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
require('dotenv').config()
const request = require('supertest');
const server = require("../server/app");
const { expect } = require('chai');
const seed = require('./seed');
const log = require('loglevel');
const Transfer = require("../server/models/Transfer");
const TrustRelationship = require("../server/models/TrustRelationship");
const sinon = require("sinon");
const chai = require("chai");
chai.use(require('chai-uuid'));

describe('Authentication', () => {
let bearerToken;
let bearerTokenB;

before( async () => {
await seed.clear();
await seed.seed();
});

beforeEach(async () => {
sinon.restore();
})

// Authorization path
it(`[POST /auth] login with ${seed.wallet.name}`, (done) => {
request(server)
.post('/auth')
.set('treetracker-api-key', seed.apiKey)
.send({wallet: seed.wallet.name, password: seed.wallet.password})
.expect('Content-Type', /application\/json/)
.expect(200)
.end((err, res) => {
if (err) done(err);
expect(res.body).to.have.property('token');
done();
});
});


it(`[POST /auth] login with using wallet id: ${seed.wallet.id}`, (done) => {
request(server)
.post('/auth')
.set('treetracker-api-key', seed.apiKey)
.send({wallet: seed.wallet.id, password: seed.wallet.password})
.expect('Content-Type', /application\/json/)
.expect(200)
.end((err, res) => {
if (err) done(err);
expect(res.body).to.have.property('token');
done();
});
});

});
95 changes: 95 additions & 0 deletions __tests__/bundle-transfer-cancel.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
require('dotenv').config()
const request = require('supertest');
const server = require("../server/app");
const { expect } = require('chai');
const seed = require('./seed');
const log = require('loglevel');
const Transfer = require("../server/models/Transfer");
const TrustRelationship = require("../server/models/TrustRelationship");
const sinon = require("sinon");
const chai = require("chai");
chai.use(require('chai-uuid'));

const apiKey = seed.apiKey;

describe('Create and accept a bundle transfer', () => {

let bearerToken;
let bearerTokenB;
let pendingTransfer;

before( async () => {

await seed.clear();
await seed.seed();

{
// Authorizes before each of the follow tests
const res = await request(server)
.post('/auth')
.set('treetracker-api-key', apiKey)
.send({
wallet: seed.wallet.name,
password: seed.wallet.password,
});
expect(res).to.have.property('statusCode', 200);
bearerToken = res.body.token;
expect(bearerToken).to.match(/\S+/);
}

{
// Authorizes before each of the follow tests
const res = await request(server)
.post('/auth')
.set('treetracker-api-key', apiKey)
.send({
wallet: seed.walletB.name,
password: seed.walletB.password,
});
expect(res).to.have.property('statusCode', 200);
bearerTokenB = res.body.token;
expect(bearerTokenB).to.match(/\S+/);
}
});

beforeEach(async () => {
sinon.restore();
})


it(`create Bundle transfer tokens from ${seed.wallet.name} to ${seed.walletB.name}`, async () => {
const res = await request(server)
.post("/transfers")
.set('treetracker-api-key', apiKey)
.set('Authorization', `Bearer ${bearerToken}`)
.send({
bundle: {
bundle_size: 1,
},
sender_wallet: seed.wallet.name,
receiver_wallet: seed.walletB.name,
});
expect(res).property("statusCode").to.eq(202);
pendingTransfer = res.body
expect(res).property("body").property("parameters").property("bundle").property("bundleSize").eq(1);
})

it("Delete/cancel the pending transfer", async () => {
const res = await request(server)
.del(`/transfers/${pendingTransfer.id}`)
.set('treetracker-api-key', apiKey)
.set('Authorization', `Bearer ${bearerToken}`);
expect(res).to.have.property('statusCode', 200);
})

it(`Wallet:${seed.wallet.name} should be able to find the transfer, it should be cancelled`, async () => {
const res = await request(server)
.get(`/transfers?limit=1000`)
.set('treetracker-api-key', apiKey)
.set('Authorization', `Bearer ${bearerToken}`);
expect(res).to.have.property('statusCode', 200);
expect(res.body.transfers).lengthOf(1);
expect(res.body.transfers[0]).property("state").eq(Transfer.STATE.cancelled);
});
});

Loading

0 comments on commit 82d46f6

Please sign in to comment.