Skip to content

Commit

Permalink
Add WITHINGS_ACCOUNTS_URI
Browse files Browse the repository at this point in the history
  • Loading branch information
mucsi96 committed Jul 30, 2023
1 parent 823a20f commit e1fef22
Show file tree
Hide file tree
Showing 10 changed files with 98 additions and 7 deletions.
1 change: 1 addition & 0 deletions .devcontainer/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ services:
SPRING_ACTUATOR_PORT: 8081
SPRING_ADMIN_SERVER_HOST: localhost
SPRING_ADMIN_SERVER_PORT: 9090
WITHINGS_ACCOUNTS_URI: https://account.withings.com
WITHINGS_API_URI: https://wbsapi.withings.net
env_file:
- .env
Expand Down
1 change: 1 addition & 0 deletions provision.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
POSTGRES_PORT: "{{ db_port }}"
POSTGRES_USER: "{{ db_username }}"
POSTGRES_PASSWORD: "{{ db_password }}"
WITHINGS_ACCOUNTS_URI: "{{ withings_accounts_uri }}"
WITHINGS_API_URI: "{{ withings_api_uri }}"
WITHINGS_CLIENT_ID: "{{ withings_client_id }}"
WITHINGS_CLIENT_SECRET: "{{ withings_client_secret }}"
Expand Down
4 changes: 2 additions & 2 deletions server/src/main/resources/application.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ spring:
client:
provider:
withings:
authorization-uri: https://account.withings.com/oauth2_user/authorize2
token-uri: https://wbsapi.withings.net/v2/oauth2
authorization-uri: ${WITHINGS_ACCOUNTS_URI}/oauth2_user/authorize2
token-uri: ${WITHINGS_API_URI}/v2/oauth2
registration:
withings-client:
provider: withings
Expand Down
7 changes: 6 additions & 1 deletion test/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
version: '3.8'

services:
mock-backup-tool:
build: ./mock_backup_tool
mock-withings:
build: ./mock_withings
db:
image: postgres:15.2-bullseye
environment:
Expand All @@ -20,7 +24,8 @@ services:
SPRING_ACTUATOR_PORT: 8081
SPRING_ADMIN_SERVER_HOST: localhost
SPRING_ADMIN_SERVER_PORT: 9090
WITHINGS_API_URI: https://wbsapi.withings.net
WITHINGS_ACCOUNTS_URI: http://mock-withings:8080
WITHINGS_API_URI: http://mock-withings:8080
WITHINGS_CLIENT_ID: withings-client-id
WITHINGS_CLIENT_SECRET: withings-client-secret
reverse-proxy:
Expand Down
9 changes: 9 additions & 0 deletions test/mock_backup_tool/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
FROM node:18

WORKDIR /usr/src/app

COPY . .

EXPOSE 8080

CMD [ "node", "index.js" ]
23 changes: 23 additions & 0 deletions test/mock_backup_tool/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
const { createServer } = require("http");

const PORT = 8080;
const server = createServer();

server.on("request", (request, response) => {
response.setHeader("Content-Type", "application/json")
response.end(JSON.stringify(new Date(Date.now() - 5 * 60 * 1000)));
});

exitOnSignal('SIGINT');
exitOnSignal('SIGTERM');

server.listen(PORT, () => {
console.log(`starting server at port ${PORT}`);
});

function exitOnSignal(signal) {
process.on(signal, function() {
console.log('\ncaught ' + signal + ', exiting');
process.exit(1);
});
}
9 changes: 9 additions & 0 deletions test/mock_withings/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
FROM node:18

WORKDIR /usr/src/app

COPY . .

EXPOSE 8080

CMD [ "node", "index.js" ]
22 changes: 22 additions & 0 deletions test/mock_withings/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
const { createServer } = require("http");

const PORT = 8080;
const server = createServer();

server.on("request", (request, response) => {
response.end(request.url);
});

exitOnSignal('SIGINT');
exitOnSignal('SIGTERM');

server.listen(PORT, () => {
console.log(`starting server at port ${PORT}`);
});

function exitOnSignal(signal) {
process.on(signal, function() {
console.log('\ncaught ' + signal + ', exiting');
process.exit(1);
});
}
28 changes: 24 additions & 4 deletions test/reverse_proxy/traefik_dynamic_conf.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,41 @@ http:
routers:
client:
entryPoints:
- web
- web
service: client
rule: PathPrefix(`/`)
servers:
entryPoints:
- web
- web
middlewares:
- authHeaders
service: server
rule: PathPrefix(`/api`)
mock-backup-tool:
entryPoints:
- web
service: mock-backup-tool
rule: Path(`/db/last-backup-time`)

middlewares:
authHeaders:
headers:
customRequestHeaders:
Remote-User: rob
Remote-Groups: user
Remote-Name: Robert White
Remote-Email: [email protected]

services:
client:
loadBalancer:
servers:
- url: http://client:80
- url: http://client:80
server:
loadBalancer:
servers:
- url: http://server:8080
- url: http://server:8080
mock-backup-tool:
loadBalancer:
servers:
- url: http://mock-backup-tool:8080
1 change: 1 addition & 0 deletions vars/defaults.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,5 @@ db_backup_bucket: training-log-pro-backup
db_backup_exclude_tables:
- oauth2_authorized_client
db_backup_region: us-east-1
withings_accounts_uri: https://account.withings.com
withings_api_uri: https://wbsapi.withings.net

0 comments on commit e1fef22

Please sign in to comment.