-
Notifications
You must be signed in to change notification settings - Fork 53
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
109 changed files
with
4,346 additions
and
4,029 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | ||
}); | ||
}); | ||
|
||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
}); | ||
}); | ||
|
Oops, something went wrong.