From 86bf37c6eb87ab92130faf64ed0b0c090ebf857a Mon Sep 17 00:00:00 2001 From: hunterlong Date: Fri, 15 May 2020 15:04:09 -0700 Subject: [PATCH 01/49] docker compose stack updates --- dev/docker-compose.full.yml | 287 ++++++++++++---------------- dev/grafana/grafana.ini | 3 + dev/grafana/statping_dashboard.json | 18 +- dev/prometheus.yml | 22 +-- 4 files changed, 139 insertions(+), 191 deletions(-) diff --git a/dev/docker-compose.full.yml b/dev/docker-compose.full.yml index b293b5ce..eb35cbc7 100644 --- a/dev/docker-compose.full.yml +++ b/dev/docker-compose.full.yml @@ -1,73 +1,42 @@ version: '2.3' + +############################################### +# Statping Full Stack +# +# Statping SQLIte => http://localhost:8080 +# Statping MySQL => http://localhost:8081 +# Statping Postgres => http://localhost:8082 +# Statping MariaDB => http://localhost:8083 +# +# Adminer => http://localhost:8282 +# Prometheus => http://localhost:7050 +# Grafana => http://localhost:3000 +# +############################################### + services: - nginx-proxy: - image: jwilder/nginx-proxy - ports: - - 80:80 - volumes: - - /var/run/docker.sock:/tmp/docker.sock:ro - networks: - - statping - -# statping_dev: -# container_name: statping_dev -# build: -# context: . -# dockerfile: ./dev/Dockerfile.dev -# args: -# VERSION: DEV -# COMMIT: DEV -# restart: on-failure -# volumes: -# - ./:/go/src/github.com/statping/statping -# environment: -# VIRTUAL_HOST: local.statping.com -# VIRTUAL_PORT: 8888 -# GO_ENV: test -# DB_CONN: sqlite -# API_SECRET: exampleapisecret -# NAME: Statping on SQLite -# DOMAIN: http://localhost:4000 -# DESCRIPTION: This is a dev environment on SQLite! -# ADMIN_USER: admin -# ADMIN_PASS: admin -# PORT: 8585 -# SERVICES: '[{"name": "Local Statping", "type": "http", "domain": "http://localhost:8585", "interval": 30}]' -# ports: -# - 8888:8888 -# - 8585:8585 -# networks: -# - statping -# healthcheck: -# test: ["CMD-SHELL", "curl -f http://localhost:8585/health || false"] -# timeout: 2s -# interval: 20s -# retries: 30 - - statping: - container_name: statping + statping_sqlite: + container_name: statping_sqlite build: - context: ./ + context: ../ restart: on-failure volumes: - ./docker/statping/sqlite:/app environment: - SERVICES: '[{"name": "Local Statping", "type": "http", "domain": "http://localhost:8585", "interval": 30}]' - VIRTUAL_HOST: sqlite.dev.statping.com - VIRTUAL_PORT: 8080 DB_CONN: sqlite API_SECRET: exampleapisecret - NAME: Statping on SQLite - DOMAIN: http://localhost:4000 + NAME: Statping + DOMAIN: http://localhost:8080 DESCRIPTION: This is a dev environment on SQLite! ADMIN_USER: admin ADMIN_PASS: admin ports: - - 4000:8080 + - 8080:8080 networks: - - statping + - database + - frontend healthcheck: test: ["CMD-SHELL", "curl -f http://localhost:8080/health || false"] timeout: 2s @@ -77,88 +46,118 @@ services: statping_mysql: container_name: statping_mysql build: - context: ./ + context: ../ restart: on-failure - ports: - - 4005:8080 volumes: - ./docker/statping/mysql:/app - links: - - mysql environment: - VIRTUAL_HOST: mysql.dev.statping.com - VIRTUAL_PORT: 8080 DB_CONN: mysql DB_HOST: mysql - DB_PORT: 3306 - DB_DATABASE: statping DB_USER: root DB_PASS: password123 + DB_DATABASE: statping + DB_PORT: 3306 API_SECRET: exampleapisecret - NAME: Statping on MySQL - DOMAIN: http://localhost:4005 + NAME: Statping MySQL + DOMAIN: http://localhost:8080 DESCRIPTION: This is a dev environment on MySQL! ADMIN_USER: admin ADMIN_PASS: admin + ports: + - 8081:8080 networks: - - statping - depends_on: - mysql: - condition: service_healthy + - database + - frontend healthcheck: test: ["CMD-SHELL", "curl -f http://localhost:8080/health || false"] timeout: 2s interval: 10s retries: 20 + depends_on: + mysql: + condition: service_healthy statping_postgres: container_name: statping_postgres build: - context: ./ + context: ../ restart: on-failure - ports: - - 4010:8080 volumes: - - ./docker/statping/postgres:/app - links: - - postgres + - ./docker/statping/mysql:/app environment: - VIRTUAL_HOST: postgres.dev.statping.com - VIRTUAL_PORT: 8080 DB_CONN: postgres DB_HOST: postgres - DB_PORT: 5432 - DB_DATABASE: statping DB_USER: root DB_PASS: password123 + DB_DATABASE: statping + DB_PORT: 5432 API_SECRET: exampleapisecret - NAME: Statping on Postgres - DOMAIN: http://localhost:4010 + NAME: Statping Postgres + DOMAIN: http://localhost:8080 DESCRIPTION: This is a dev environment on Postgres! ADMIN_USER: admin ADMIN_PASS: admin + ports: + - 8082:8080 networks: - - statping + - database + - frontend + healthcheck: + test: ["CMD-SHELL", "curl -f http://localhost:8080/health || false"] + timeout: 2s + interval: 10s + retries: 20 depends_on: postgres: condition: service_healthy + + statping_mariadb: + container_name: statping_mariadb + build: + context: ../ + restart: on-failure + volumes: + - ./docker/statping/mariadb:/app + environment: + DB_CONN: mysql + DB_HOST: mariadb + DB_USER: root + DB_PASS: password123 + DB_DATABASE: statping + DB_PORT: 3306 + API_SECRET: exampleapisecret + NAME: Statping MariaDB + DOMAIN: http://localhost:8080 + DESCRIPTION: This is a dev environment on MariaDB! + ADMIN_USER: admin + ADMIN_PASS: admin + ports: + - 8083:8080 + networks: + - database + - frontend healthcheck: test: ["CMD-SHELL", "curl -f http://localhost:8080/health || false"] - timeout: 5s - interval: 5s - retries: 30 + timeout: 2s + interval: 10s + retries: 20 + depends_on: + mariadb: + condition: service_healthy postgres: container_name: postgres image: postgres volumes: - ./docker/databases/postgres:/var/lib/postgresql/data + ports: + - 5432:5432 environment: POSTGRES_PASSWORD: password123 POSTGRES_DB: statping POSTGRES_USER: root networks: - - statping + - database healthcheck: test: ["CMD-SHELL", "pg_isready -U root"] interval: 15s @@ -175,95 +174,59 @@ services: MYSQL_ROOT_PASSWORD: password123 MYSQL_DATABASE: statping MYSQL_USER: root - MYSQL_PASSWORD: password + MYSQL_PASSWORD: password123 + ports: + - 3306:3306 networks: - - statping + - database healthcheck: test: [ "CMD", "mysqladmin" ,"ping", "-h", "localhost" ] timeout: 20s interval: 15s retries: 30 - phpmyadmin: - container_name: phpmyadmin - image: phpmyadmin/phpmyadmin - restart: on-failure - depends_on: - mysql: - condition: service_healthy - ports: - - 5050:80 - links: - - mysql:db - environment: - VIRTUAL_HOST: phpmyadmin.statping.com - VIRTUAL_PORT: 80 - MYSQL_ROOT_PASSWORD: password123 - PMA_HOST: mysql - PMA_USER: root - PMA_PASSWORD: password123 - PMA_PORT: 3306 - networks: - - statping - - sqlite-web: - container_name: sqlite-web - image: coleifer/sqlite-web - restart: on-failure - command: sqlite_web -H 0.0.0.0 -r -x /data/statping.db - depends_on: - statping: - condition: service_healthy - ports: - - 6050:8080 - links: - - statping + mariadb: + container_name: mariadb + image: mariadb volumes: - - ./docker/statping/sqlite/statping.db:/data/statping.db:ro + - ./docker/databases/mariadb:/var/lib/mysql + restart: always environment: - VIRTUAL_HOST: sqladmin.statping.com - VIRTUAL_PORT: 8080 - SQLITE_DATABASE: /data/statping.db - networks: - - statping - - pgadmin4: - container_name: pgadmin4 - image: fenglc/pgadmin4 - restart: on-failure - environment: - VIRTUAL_HOST: pgadmin.statping.com - VIRTUAL_PORT: 5050 - DEFAULT_USER: admin@admin.com - DEFAULT_PASSWORD: admin - depends_on: - postgres: - condition: service_healthy + MYSQL_ROOT_PASSWORD: password123 + MYSQL_DATABASE: statping + MYSQL_USER: root + MYSQL_PASSWORD: password123 ports: - - 7000:5050 - links: - - postgres:postgres + - 3307:3306 networks: - - statping + - database + healthcheck: + test: [ "CMD", "mysqladmin" ,"ping", "-h", "localhost" ] + timeout: 20s + interval: 15s + retries: 30 + + adminer: + container_name: adminer + image: adminer + restart: always + networks: + - database + - frontend + ports: + - 8282:8080 prometheus: container_name: prometheus image: prom/prometheus:v2.0.0 restart: on-failure volumes: - - ./dev/prometheus.yml:/etc/prometheus/prometheus.yml + - ./prometheus.yml:/etc/prometheus/prometheus.yml - ./docker/databases/prometheus:/prometheus - links: - - statping - - statping_mysql - - statping_postgres ports: - 7050:9090 networks: - - statping - environment: - VIRTUAL_HOST: prometheus.statping.com - VIRTUAL_PORT: 9090 + - database healthcheck: test: "/bin/wget -q -Y off http://localhost:9090/status -O /dev/null > /dev/null 2>&1" interval: 10s @@ -277,25 +240,23 @@ services: - 3000:3000 volumes: - ./docker/grafana:/var/lib/grafana - - ./dev/grafana/datasource.yml:/etc/grafana/provisioning/datasources/datasource.yml - - ./dev/grafana/dashboard.yml:/etc/grafana/provisioning/dashboards/dashboard.yml - - ./dev/grafana/statping_dashboard.json:/etc/grafana/provisioning/dashboards/statping_dashboard.json + - ./grafana/datasource.yml:/etc/grafana/provisioning/datasources/datasource.yml + - ./grafana/dashboard.yml:/etc/grafana/provisioning/dashboards/dashboard.yml + - ./grafana/statping_dashboard.json:/etc/grafana/provisioning/dashboards/statping_dashboard.json environment: - - VIRTUAL_HOST=grafana.statping.com - - VIRTUAL_PORT=3000 - GF_USERS_ALLOW_SIGN_UP=false - GF_AUTH_ANONYMOUS_ENABLED=true depends_on: prometheus: condition: service_healthy - links: - - prometheus networks: - - statping + - frontend + - database healthcheck: test: "/usr/bin/wget -q -Y off http://localhost:3000/api/health -O /dev/null > /dev/null 2>&1" interval: 10s retries: 20 networks: - statping: + frontend: + database: diff --git a/dev/grafana/grafana.ini b/dev/grafana/grafana.ini index 6fe59c41..6096b4a9 100644 --- a/dev/grafana/grafana.ini +++ b/dev/grafana/grafana.ini @@ -1,7 +1,10 @@ [users] # disable user signup / registration allow_sign_up = false +viewers_can_edit = true +editors_can_admin = true [auth.anonymous] # enable anonymous access enabled = true + diff --git a/dev/grafana/statping_dashboard.json b/dev/grafana/statping_dashboard.json index 6f354f85..b70dbf83 100644 --- a/dev/grafana/statping_dashboard.json +++ b/dev/grafana/statping_dashboard.json @@ -558,24 +558,14 @@ "templating": { "list": [ { - "allValue": null, - "current": {}, - "datasource": "${DS_PROMETHEUS}", "hide": 0, - "includeAll": false, - "label": "service", - "multi": false, - "name": "service", + "label": "datasource", + "name": "DS_PROMETHEUS", "options": [], - "query": "label_values(statup_service_latency, name)", + "query": "prometheus", "refresh": 1, "regex": "", - "sort": 0, - "tagValuesQuery": "", - "tags": [], - "tagsQuery": "", - "type": "query", - "useTags": false + "type": "datasource" } ] }, diff --git a/dev/prometheus.yml b/dev/prometheus.yml index 8637d797..a8fea124 100644 --- a/dev/prometheus.yml +++ b/dev/prometheus.yml @@ -3,17 +3,11 @@ global: evaluation_interval: 15s scrape_configs: - - job_name: 'statping_local' - scrape_interval: 15s - bearer_token: 'samplesecret' - static_configs: - - targets: ['docker0:8585'] - - - job_name: 'statping' + - job_name: 'statping_sqlite' scrape_interval: 15s bearer_token: 'exampleapisecret' static_configs: - - targets: ['statping:8080'] + - targets: ['statping_sqlite:8080'] - job_name: 'statping_mysql' scrape_interval: 15s @@ -21,14 +15,14 @@ scrape_configs: static_configs: - targets: ['statping_mysql:8080'] + - job_name: 'statping_mariadb' + scrape_interval: 15s + bearer_token: 'exampleapisecret' + static_configs: + - targets: ['statping_mariadb:8080'] + - job_name: 'statping_postgres' scrape_interval: 15s bearer_token: 'exampleapisecret' static_configs: - targets: ['statping_postgres:8080'] - - - job_name: 'statping_dev' - scrape_interval: 15s - bearer_token: 'exampleapisecret' - static_configs: - - targets: ['statping_dev:8585'] From f9ab56073615708c4e97077018f85835db31659a Mon Sep 17 00:00:00 2001 From: hunterlong Date: Fri, 15 May 2020 17:21:54 -0700 Subject: [PATCH 02/49] including NAME, DESCRIPTION, and DOMAIN env vars to be used when Statping is setup (automatically), modified docker-compose full stack yml. --- dev/docker-compose.full.yml | 18 +++++++++++++++--- types/core/samples.go | 6 +++--- utils/configs.go | 3 +++ 3 files changed, 21 insertions(+), 6 deletions(-) diff --git a/dev/docker-compose.full.yml b/dev/docker-compose.full.yml index eb35cbc7..6c326ecb 100644 --- a/dev/docker-compose.full.yml +++ b/dev/docker-compose.full.yml @@ -13,6 +13,10 @@ version: '2.3' # Prometheus => http://localhost:7050 # Grafana => http://localhost:3000 # +# MySQL => http://localhost:3306 +# Postgres => http://localhost:5432 +# MariaDB => http://localhost:3307 +# ############################################### services: @@ -24,6 +28,7 @@ services: restart: on-failure volumes: - ./docker/statping/sqlite:/app + - ./services.yml:/app/services.yml environment: DB_CONN: sqlite API_SECRET: exampleapisecret @@ -32,6 +37,7 @@ services: DESCRIPTION: This is a dev environment on SQLite! ADMIN_USER: admin ADMIN_PASS: admin + SAMPLE_DATA: 'false' ports: - 8080:8080 networks: @@ -50,6 +56,7 @@ services: restart: on-failure volumes: - ./docker/statping/mysql:/app + - ./services.yml:/app/services.yml environment: DB_CONN: mysql DB_HOST: mysql @@ -59,10 +66,11 @@ services: DB_PORT: 3306 API_SECRET: exampleapisecret NAME: Statping MySQL - DOMAIN: http://localhost:8080 + DOMAIN: http://localhost:8081 DESCRIPTION: This is a dev environment on MySQL! ADMIN_USER: admin ADMIN_PASS: admin + SAMPLE_DATA: 'false' ports: - 8081:8080 networks: @@ -84,6 +92,7 @@ services: restart: on-failure volumes: - ./docker/statping/mysql:/app + - ./services.yml:/app/services.yml environment: DB_CONN: postgres DB_HOST: postgres @@ -93,10 +102,11 @@ services: DB_PORT: 5432 API_SECRET: exampleapisecret NAME: Statping Postgres - DOMAIN: http://localhost:8080 + DOMAIN: http://localhost:8082 DESCRIPTION: This is a dev environment on Postgres! ADMIN_USER: admin ADMIN_PASS: admin + SAMPLE_DATA: 'false' ports: - 8082:8080 networks: @@ -118,6 +128,7 @@ services: restart: on-failure volumes: - ./docker/statping/mariadb:/app + - ./services.yml:/app/services.yml environment: DB_CONN: mysql DB_HOST: mariadb @@ -127,10 +138,11 @@ services: DB_PORT: 3306 API_SECRET: exampleapisecret NAME: Statping MariaDB - DOMAIN: http://localhost:8080 + DOMAIN: http://localhost:8083 DESCRIPTION: This is a dev environment on MariaDB! ADMIN_USER: admin ADMIN_PASS: admin + SAMPLE_DATA: 'false' ports: - 8083:8080 networks: diff --git a/types/core/samples.go b/types/core/samples.go index 431cc6ba..57d8dd1d 100644 --- a/types/core/samples.go +++ b/types/core/samples.go @@ -13,10 +13,10 @@ func Samples() error { } core := &Core{ - Name: "Statping Sample Data", - Description: "This data is only used to testing", + Name: utils.Params.GetString("NAME"), + Description: utils.Params.GetString("DESCRIPTION"), ApiSecret: apiSecret, - Domain: "http://localhost:8080", + Domain: utils.Params.GetString("DOMAIN"), CreatedAt: utils.Now(), UseCdn: null.NewNullBool(false), Footer: null.NewNullString(""), diff --git a/utils/configs.go b/utils/configs.go index 477a7894..c63ee3cd 100644 --- a/utils/configs.go +++ b/utils/configs.go @@ -54,6 +54,9 @@ func setDefaults() { Params.SetDefault("USE_CDN", false) Params.SetDefault("ALLOW_REPORTS", false) Params.SetDefault("POSTGRES_SSLMODE", "disable") + Params.SetDefault("NAME", "Statping Sample Data") + Params.SetDefault("DOMAIN", "http://localhost:8080") + Params.SetDefault("DESCRIPTION", "This status page has sample data included") Params.SetDefault("REMOVE_AFTER", 2160*time.Hour) Params.SetDefault("CLEANUP_INTERVAL", 1*time.Hour) From 006d8555641370317f9af465be56d61ce36f7475 Mon Sep 17 00:00:00 2001 From: hunterlong Date: Fri, 15 May 2020 20:07:12 -0700 Subject: [PATCH 03/49] removed authentication for logout route --- handlers/routes.go | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/handlers/routes.go b/handlers/routes.go index 2db26c1e..ffe130de 100644 --- a/handlers/routes.go +++ b/handlers/routes.go @@ -75,7 +75,7 @@ func Router() *mux.Router { r.Handle("/api", scoped(apiIndexHandler)) r.Handle("/api/setup", http.HandlerFunc(processSetupHandler)).Methods("POST") api.Handle("/api/login", http.HandlerFunc(apiLoginHandler)).Methods("POST") - api.Handle("/api/logout", authenticated(logoutHandler, false)) + api.Handle("/api/logout", http.HandlerFunc(logoutHandler)) api.Handle("/api/renew", authenticated(apiRenewHandler, false)) api.Handle("/api/cache", authenticated(apiCacheHandler, false)).Methods("GET") api.Handle("/api/clear_cache", authenticated(apiClearCacheHandler, false)) @@ -160,7 +160,6 @@ func Router() *mux.Router { // API Generic Routes r.Handle("/metrics", readOnly(prometheusHandler, false)) r.Handle("/health", http.HandlerFunc(healthCheckHandler)) - api.Handle("/api/oauth/{provider}", http.HandlerFunc(oauthHandler)) r.Handle("/.well-known/", http.StripPrefix("/.well-known/", http.FileServer(http.Dir(dir+"/.well-known")))) r.NotFoundHandler = http.HandlerFunc(error404Handler) return r From 2a818d230c6078bf7fd7d2daf9cb9cfa19f1cba9 Mon Sep 17 00:00:00 2001 From: hunterlong Date: Mon, 18 May 2020 13:26:02 -0700 Subject: [PATCH 04/49] postman API tests for different databases --- .github/workflows/master.yml | 140 +++++++++++++++++++++++++++++++++-- 1 file changed, 135 insertions(+), 5 deletions(-) diff --git a/.github/workflows/master.yml b/.github/workflows/master.yml index a04aea68..2cb4f5f5 100644 --- a/.github/workflows/master.yml +++ b/.github/workflows/master.yml @@ -143,7 +143,7 @@ jobs: env: COVERALLS: ${{ secrets.COVERALLS }} - test-postman: + test-postman-sqlite: needs: compile runs-on: ubuntu-latest steps: @@ -178,14 +178,144 @@ jobs: API_SECRET=demosecret123 statping --port=8080 > /dev/null & sleep 3 - - name: Postman Tests + - name: Postman SQLite Tests uses: matt-ball/newman-action@master with: postmanApiKey: ${{ secrets.POSTMAN_API }} - collection: 1898229-94807b85-ef65-4370-9144-b1a74e04cb0e - environment: ./dev/postman_environment.json + collection: 1898229-3c6a7841-0b39-4878-a3a6-1c76832b7679 + globals: + endpoint: http://127.0.0.1:8080 + api_key: demosecret123 + db_connection: sqlite timeoutRequest: 15000 - delayRequest: 1000 + delayRequest: 500 + + test-postman-mysql: + needs: compile + runs-on: ubuntu-latest + + services: + mysql: + image: mysql:5.7 + env: + MYSQL_ROOT_PASSWORD: password123 + MYSQL_DATABASE: statping + ports: + - 3306:3306 + options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3 + + steps: + - uses: actions/checkout@v2 + - uses: actions/setup-go@v2 + with: + go-version: '1.14.2' + + - name: Setting ENV's + run: | + echo "::add-path::$(go env GOPATH)/bin" + echo "::add-path::/opt/hostedtoolcache/node/10.20.1/x64/bin" + echo ::set-env name=VERSION::$(cat version.txt) + shell: bash + + - name: Download Compiled Frontend (rice-box.go) + uses: actions/download-artifact@v1 + with: + name: static-rice-box + path: ./source + + - name: Install Statping + env: + VERSION: ${{ env.VERSION }} + run: | + make build + chmod +x statping + mv statping $(go env GOPATH)/bin/ + + - name: Run Statping + run: | + API_SECRET=demosecret123 statping --port=8080 > /dev/null & + sleep 3 + + - name: Postman MySQL Tests + uses: matt-ball/newman-action@master + with: + postmanApiKey: ${{ secrets.POSTMAN_API }} + collection: 1898229-3c6a7841-0b39-4878-a3a6-1c76832b7679 + globals: + endpoint: http://127.0.0.1:8080 + api_key: demosecret123 + db_connection: mysql + db_host: localhost + db_user: root + db_password: password123 + db_database: statping + db_port: 3306 + timeoutRequest: 15000 + delayRequest: 500 + + test-postman-postgres: + needs: compile + runs-on: ubuntu-latest + + services: + postgres: + image: postgres:10.8 + env: + POSTGRES_USER: root + POSTGRES_PASSWORD: password123 + POSTGRES_DB: statping + ports: + - 5432:5432 + options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5 + + steps: + - uses: actions/checkout@v2 + - uses: actions/setup-go@v2 + with: + go-version: '1.14.2' + + - name: Setting ENV's + run: | + echo "::add-path::$(go env GOPATH)/bin" + echo "::add-path::/opt/hostedtoolcache/node/10.20.1/x64/bin" + echo ::set-env name=VERSION::$(cat version.txt) + shell: bash + + - name: Download Compiled Frontend (rice-box.go) + uses: actions/download-artifact@v1 + with: + name: static-rice-box + path: ./source + + - name: Install Statping + env: + VERSION: ${{ env.VERSION }} + run: | + make build + chmod +x statping + mv statping $(go env GOPATH)/bin/ + + - name: Run Statping + run: | + API_SECRET=demosecret123 statping --port=8080 > /dev/null & + sleep 3 + + - name: Postman Postgres Tests + uses: matt-ball/newman-action@master + with: + postmanApiKey: ${{ secrets.POSTMAN_API }} + collection: 1898229-3c6a7841-0b39-4878-a3a6-1c76832b7679 + globals: + endpoint: http://127.0.0.1:8080 + api_key: demosecret123 + db_connection: postgres + db_host: localhost + db_user: root + db_password: password123 + db_database: statping + db_port: 5432 + timeoutRequest: 15000 + delayRequest: 500 build-binaries: needs: compile From 7bfddf0073a132e7948b6321e447690aff6157d8 Mon Sep 17 00:00:00 2001 From: hunterlong Date: Mon, 18 May 2020 13:27:32 -0700 Subject: [PATCH 05/49] postman API tests for different databases --- .github/workflows/master.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/master.yml b/.github/workflows/master.yml index 2cb4f5f5..41d844b7 100644 --- a/.github/workflows/master.yml +++ b/.github/workflows/master.yml @@ -380,7 +380,7 @@ jobs: path: ./build upload-release: - needs: [test, test-postman, build-binaries] + needs: [test, test-postman-sqlite, test-postman-mysql, test-postman-postgres, build-binaries] runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 From 2478df4d1ab2c240c903cc3ec3b97f1347e9eaf4 Mon Sep 17 00:00:00 2001 From: hunterlong Date: Mon, 18 May 2020 13:32:06 -0700 Subject: [PATCH 06/49] postman API tests for different databases --- .github/workflows/master.yml | 38 ++++++++++++++++++------------------ 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/.github/workflows/master.yml b/.github/workflows/master.yml index 41d844b7..9a4a8c73 100644 --- a/.github/workflows/master.yml +++ b/.github/workflows/master.yml @@ -184,9 +184,9 @@ jobs: postmanApiKey: ${{ secrets.POSTMAN_API }} collection: 1898229-3c6a7841-0b39-4878-a3a6-1c76832b7679 globals: - endpoint: http://127.0.0.1:8080 - api_key: demosecret123 - db_connection: sqlite + - endpoint: http://127.0.0.1:8080 + - api_key: demosecret123 + - db_connection: sqlite timeoutRequest: 15000 delayRequest: 500 @@ -242,14 +242,14 @@ jobs: postmanApiKey: ${{ secrets.POSTMAN_API }} collection: 1898229-3c6a7841-0b39-4878-a3a6-1c76832b7679 globals: - endpoint: http://127.0.0.1:8080 - api_key: demosecret123 - db_connection: mysql - db_host: localhost - db_user: root - db_password: password123 - db_database: statping - db_port: 3306 + - endpoint: http://127.0.0.1:8080 + - api_key: demosecret123 + - db_connection: mysql + - db_host: localhost + - db_user: root + - db_password: password123 + - db_database: statping + - db_port: 3306 timeoutRequest: 15000 delayRequest: 500 @@ -306,14 +306,14 @@ jobs: postmanApiKey: ${{ secrets.POSTMAN_API }} collection: 1898229-3c6a7841-0b39-4878-a3a6-1c76832b7679 globals: - endpoint: http://127.0.0.1:8080 - api_key: demosecret123 - db_connection: postgres - db_host: localhost - db_user: root - db_password: password123 - db_database: statping - db_port: 5432 + - endpoint: http://127.0.0.1:8080 + - api_key: demosecret123 + - db_connection: postgres + - db_host: localhost + - db_user: root + - db_password: password123 + - db_database: statping + - db_port: 5432 timeoutRequest: 15000 delayRequest: 500 From 429170f006bfafb548f7ad02323a0aff96a7dce0 Mon Sep 17 00:00:00 2001 From: hunterlong Date: Mon, 18 May 2020 13:36:41 -0700 Subject: [PATCH 07/49] postman API tests for different databases --- .github/workflows/master.yml | 41 +++++++++++++++++++----------------- 1 file changed, 22 insertions(+), 19 deletions(-) diff --git a/.github/workflows/master.yml b/.github/workflows/master.yml index 9a4a8c73..9d0c9812 100644 --- a/.github/workflows/master.yml +++ b/.github/workflows/master.yml @@ -184,9 +184,10 @@ jobs: postmanApiKey: ${{ secrets.POSTMAN_API }} collection: 1898229-3c6a7841-0b39-4878-a3a6-1c76832b7679 globals: - - endpoint: http://127.0.0.1:8080 - - api_key: demosecret123 - - db_connection: sqlite + - values: + endpoint: http://127.0.0.1:8080 + api_key: demosecret123 + db_connection: sqlite timeoutRequest: 15000 delayRequest: 500 @@ -242,14 +243,15 @@ jobs: postmanApiKey: ${{ secrets.POSTMAN_API }} collection: 1898229-3c6a7841-0b39-4878-a3a6-1c76832b7679 globals: - - endpoint: http://127.0.0.1:8080 - - api_key: demosecret123 - - db_connection: mysql - - db_host: localhost - - db_user: root - - db_password: password123 - - db_database: statping - - db_port: 3306 + - values: + endpoint: http://127.0.0.1:8080 + api_key: demosecret123 + db_connection: mysql + db_host: localhost + db_user: root + db_password: password123 + db_database: statping + db_port: 3306 timeoutRequest: 15000 delayRequest: 500 @@ -306,14 +308,15 @@ jobs: postmanApiKey: ${{ secrets.POSTMAN_API }} collection: 1898229-3c6a7841-0b39-4878-a3a6-1c76832b7679 globals: - - endpoint: http://127.0.0.1:8080 - - api_key: demosecret123 - - db_connection: postgres - - db_host: localhost - - db_user: root - - db_password: password123 - - db_database: statping - - db_port: 5432 + - values: + endpoint: http://127.0.0.1:8080 + api_key: demosecret123 + db_connection: postgres + db_host: localhost + db_user: root + db_password: password123 + db_database: statping + db_port: 5432 timeoutRequest: 15000 delayRequest: 500 From 416984d08381b910e7de96f237a4fefae862f181 Mon Sep 17 00:00:00 2001 From: hunterlong Date: Mon, 18 May 2020 13:50:09 -0700 Subject: [PATCH 08/49] postman API tests for different databases --- .github/workflows/dev.yml | 7 +- .github/workflows/master.yml | 28 +- dev/postman.json | 1456 ++++++++++++++++++++++++++++++--- dev/postman_env_mysql.json | 49 ++ dev/postman_env_postgres.json | 49 ++ dev/postman_env_sqlite.json | 49 ++ dev/postman_environment.json | 21 - 7 files changed, 1511 insertions(+), 148 deletions(-) create mode 100644 dev/postman_env_mysql.json create mode 100644 dev/postman_env_postgres.json create mode 100644 dev/postman_env_sqlite.json delete mode 100644 dev/postman_environment.json diff --git a/.github/workflows/dev.yml b/.github/workflows/dev.yml index 519d640a..d4607ff5 100644 --- a/.github/workflows/dev.yml +++ b/.github/workflows/dev.yml @@ -160,8 +160,7 @@ jobs: - name: Postman Tests uses: matt-ball/newman-action@master with: - postmanApiKey: ${{ secrets.POSTMAN_API }} - collection: 1898229-94807b85-ef65-4370-9144-b1a74e04cb0e - environment: ./dev/postman_environment.json + collection: ./dev/postman.json + environment: ./dev/postman_environment_sqlite.json timeoutRequest: 15000 - delayRequest: 1000 + delayRequest: 500 diff --git a/.github/workflows/master.yml b/.github/workflows/master.yml index 9d0c9812..6af1b976 100644 --- a/.github/workflows/master.yml +++ b/.github/workflows/master.yml @@ -183,11 +183,7 @@ jobs: with: postmanApiKey: ${{ secrets.POSTMAN_API }} collection: 1898229-3c6a7841-0b39-4878-a3a6-1c76832b7679 - globals: - - values: - endpoint: http://127.0.0.1:8080 - api_key: demosecret123 - db_connection: sqlite + environment: ./dev/postman_env_sqlite.json timeoutRequest: 15000 delayRequest: 500 @@ -242,16 +238,7 @@ jobs: with: postmanApiKey: ${{ secrets.POSTMAN_API }} collection: 1898229-3c6a7841-0b39-4878-a3a6-1c76832b7679 - globals: - - values: - endpoint: http://127.0.0.1:8080 - api_key: demosecret123 - db_connection: mysql - db_host: localhost - db_user: root - db_password: password123 - db_database: statping - db_port: 3306 + environment: ./dev/postman_env_mysql.json timeoutRequest: 15000 delayRequest: 500 @@ -307,16 +294,7 @@ jobs: with: postmanApiKey: ${{ secrets.POSTMAN_API }} collection: 1898229-3c6a7841-0b39-4878-a3a6-1c76832b7679 - globals: - - values: - endpoint: http://127.0.0.1:8080 - api_key: demosecret123 - db_connection: postgres - db_host: localhost - db_user: root - db_password: password123 - db_database: statping - db_port: 5432 + environment: ./dev/postman_env_postgres.json timeoutRequest: 15000 delayRequest: 500 diff --git a/dev/postman.json b/dev/postman.json index 1aa1cb71..453c9b8d 100644 --- a/dev/postman.json +++ b/dev/postman.json @@ -1,8 +1,8 @@ { "info": { - "_postman_id": "94807b85-ef65-4370-9144-b1a74e04cb0e", + "_postman_id": "3c6a7841-0b39-4878-a3a6-1c76832b7679", "name": "Statping", - "description": "The Statping API allows you to programmatically access data on your Statping server.\n\nThe easiest way to get started with the API is by running your own Docker or local instance of the Statping server.\n\n\n\n# Authentication\n\nAn API Key is required to be sent as part of every request to the Statping API, by using the `Authorization` and the API Secret Key as a header.\n\n> If you do not have an API Secret Key, you can find it on the Settings page.\n\nYou can Authenticate by implementing the following...\n- Using the `Authorization` header with API Secret Key\n- Setting `GO_ENV` to `test` to bypass all authentication\n- Adding `?api=` URL Query along with the API Secret Key\n- Being logged into Statping as an admin (using JWT sessions/cookies)\n\n# Environment Variables\nStatping includes many environment variables that can give you more control over your instance. Please view the [Environment Variables Wiki](https://github.com/statping/statping/wiki/Environment-Variables) page to view a complete list. Below are a couple important ones...\n- `STATPING_DIR` - Statping's working directory. By default, this will be set to the current working directory. This path will contain the `config.yml` file, `logs`, and `assets` folder. \n- `SASS` - Absolute path to the `sass` executable. By default it will attempt to find `sass` in your `$PATH`. \n\n# Demo\nYou can checkout the Statping Demo instance at [https://demo.statping.com](https://demo.statping.com). All features are available for you to experiment with. The API Secret Key is `demoapisecret123`. Since this instance is public, it will be reset with sample data **every 90 minutes**.\n", + "description": "The Statping API allows you to programmatically access data on your Statping server.\n\nThe easiest way to get started with the API is by running your own Docker or local instance of the Statping server.\n\n\n\n# Authentication\n\nAn API Key is required to be sent as part of every request to the Statping API, by using the `Authorization` and the API Secret Key as a header.\n\n> If you do not have an API Secret Key, you can find it on the Settings page.\n\nYou can Authenticate by implementing the following...\n- Using the `Authorization` header with API Secret Key\n- Setting `GO_ENV` to `test` to bypass all authentication\n- Adding `?api=` URL Query along with the API Secret Key\n- Being logged into Statping as an admin (using JWT sessions/cookies)\n\n> Authentication will create a cookie named `statping_auth`.\n\n# Environment Variables\nStatping includes many environment variables that can give you more control over your instance. Please view the [Environment Variables Wiki](https://github.com/statping/statping/wiki/Environment-Variables) page to view a complete list. Below are a couple important ones...\n- `STATPING_DIR` - Statping's working directory. By default, this will be set to the current working directory. This path will contain the `config.yml` file, `logs`, and `assets` folder. \n- `SASS` - Absolute path to the `sass` executable. By default it will attempt to find `sass` in your `$PATH`. \n\n# Demo\nYou can checkout the Statping Demo instance at [https://demo.statping.com](https://demo.statping.com). All features are available for you to experiment with. The API Secret Key is `demoapisecret123`. Since this instance is public, it will be reset with sample data **every 90 minutes**.\n", "schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json" }, "item": [ @@ -15,7 +15,7 @@ { "listen": "test", "script": { - "id": "08b8f487-2318-44b9-bdb8-f1f1041e9462", + "id": "29b5dc8d-60c1-4f70-853d-49114af6b254", "exec": [ "var tm = Math.round(new Date().getTime()/1000);", "pm.globals.set(\"start_time\", tm-259200);", @@ -32,6 +32,16 @@ ], "type": "text/javascript" } + }, + { + "listen": "prerequest", + "script": { + "id": "e5e9ea08-21d1-48d6-b019-9b4f93e813e5", + "exec": [ + "" + ], + "type": "text/javascript" + } } ], "request": { @@ -64,27 +74,27 @@ }, { "key": "db_user", - "value": "root", + "value": "{{db_user}}", "type": "text" }, { "key": "db_password", - "value": "password123", + "value": "{{db_password}}", "type": "text" }, { "key": "db_database", - "value": "statping", + "value": "{{db_database}}", "type": "text" }, { "key": "db_connection", - "value": "sqlite", + "value": "{{db_connection}}", "type": "text" }, { "key": "db_port", - "value": "3306", + "value": "{{db_port}}", "type": "text" }, { @@ -147,7 +157,7 @@ { "listen": "prerequest", "script": { - "id": "3faca200-30d4-4daf-8edf-059bf6b6fbf0", + "id": "ee74f82f-761a-46ae-a183-044b3d17c416", "type": "text/javascript", "exec": [ "" @@ -157,7 +167,7 @@ { "listen": "test", "script": { - "id": "a72027a1-280f-4ebf-887d-a19e9866d0ab", + "id": "99e1ad44-98bc-431c-bec6-d5b4ea3b94ac", "type": "text/javascript", "exec": [ "" @@ -176,7 +186,7 @@ { "listen": "test", "script": { - "id": "08b8f487-2318-44b9-bdb8-f1f1041e9462", + "id": "fb5b5fcf-86a0-4d22-9f4c-cc6955eb414a", "exec": [ "pm.test(\"Response is ok\", function () {", " pm.response.to.have.status(200);", @@ -186,7 +196,6 @@ " var jsonData = pm.response.json();", " pm.expect(jsonData.name).to.eql(\"Statping Monitoring Sample Data\");", " pm.expect(jsonData.using_cdn).to.eql(false);", - " pm.expect(jsonData.admin).to.eql(false);", "});" ], "type": "text/javascript" @@ -255,13 +264,171 @@ } ] }, + { + "name": "Logs", + "event": [ + { + "listen": "test", + "script": { + "id": "a694b786-796e-4d54-87fc-1848525bba65", + "exec": [ + "pm.test(\"Response is ok\", function () {", + " pm.response.to.have.status(200);", + "});" + ], + "type": "text/javascript" + } + } + ], + "request": { + "auth": { + "type": "bearer", + "bearer": [ + { + "key": "token", + "value": "{{api_key}}", + "type": "string" + } + ] + }, + "method": "GET", + "header": [], + "url": { + "raw": "{{endpoint}}/api/logs", + "host": [ + "{{endpoint}}" + ], + "path": [ + "api", + "logs" + ] + }, + "description": "This endpoint will return a list of the last 1,000 logs." + }, + "response": [ + { + "name": "Statping Details", + "originalRequest": { + "method": "GET", + "header": [], + "url": { + "raw": "{{endpoint}}/api", + "host": [ + "{{endpoint}}" + ], + "path": [ + "api" + ] + } + }, + "status": "OK", + "code": 200, + "_postman_previewlanguage": "json", + "header": [ + { + "key": "Content-Length", + "value": "398" + }, + { + "key": "Content-Type", + "value": "application/json" + }, + { + "key": "Date", + "value": "Sat, 02 May 2020 01:06:09 GMT" + } + ], + "cookie": [], + "body": "{\n \"admin\": false,\n \"allow_reports\": false,\n \"created_at\": \"2020-05-02T01:00:07.885973685Z\",\n \"description\": \"This data is only used to testing\",\n \"domain\": \"http://localhost:8080\",\n \"footer\": null,\n \"logged_in\": false,\n \"migration_id\": 1588381207,\n \"name\": \"Statping Sample Data\",\n \"setup\": true,\n \"started_on\": \"2020-05-02T01:00:14.255837864Z\",\n \"updated_at\": \"2020-05-02T01:00:12.731269305Z\",\n \"using_cdn\": false,\n \"version\": \"0.90.34\"\n}" + } + ] + }, + { + "name": "Logs Last Line", + "event": [ + { + "listen": "test", + "script": { + "id": "21501cae-bea0-4b6a-87cc-32a7f6da0771", + "exec": [ + "pm.test(\"Response is ok\", function () {", + " pm.response.to.have.status(200);", + "});" + ], + "type": "text/javascript" + } + } + ], + "request": { + "auth": { + "type": "bearer", + "bearer": [ + { + "key": "token", + "value": "{{api_key}}", + "type": "string" + } + ] + }, + "method": "GET", + "header": [], + "url": { + "raw": "{{endpoint}}/api/logs", + "host": [ + "{{endpoint}}" + ], + "path": [ + "api", + "logs" + ] + }, + "description": "This endpoint will return the last line in the logs." + }, + "response": [ + { + "name": "Statping Details", + "originalRequest": { + "method": "GET", + "header": [], + "url": { + "raw": "{{endpoint}}/api", + "host": [ + "{{endpoint}}" + ], + "path": [ + "api" + ] + } + }, + "status": "OK", + "code": 200, + "_postman_previewlanguage": "json", + "header": [ + { + "key": "Content-Length", + "value": "398" + }, + { + "key": "Content-Type", + "value": "application/json" + }, + { + "key": "Date", + "value": "Sat, 02 May 2020 01:06:09 GMT" + } + ], + "cookie": [], + "body": "{\n \"admin\": false,\n \"allow_reports\": false,\n \"created_at\": \"2020-05-02T01:00:07.885973685Z\",\n \"description\": \"This data is only used to testing\",\n \"domain\": \"http://localhost:8080\",\n \"footer\": null,\n \"logged_in\": false,\n \"migration_id\": 1588381207,\n \"name\": \"Statping Sample Data\",\n \"setup\": true,\n \"started_on\": \"2020-05-02T01:00:14.255837864Z\",\n \"updated_at\": \"2020-05-02T01:00:12.731269305Z\",\n \"using_cdn\": false,\n \"version\": \"0.90.34\"\n}" + } + ] + }, { "name": "Health Check", "event": [ { "listen": "test", "script": { - "id": "987cc831-4a88-45ea-a9d5-494d86887fc6", + "id": "1259b7bb-a330-4716-ae7c-386f96224a14", "exec": [ "pm.test(\"Response is ok\", function () {", " pm.response.to.have.status(200);", @@ -338,7 +505,7 @@ { "listen": "test", "script": { - "id": "2f977982-ef22-4cee-9c38-89ad4777d3e0", + "id": "04a41c9d-0659-44f8-9efb-d04fff1af6e3", "exec": [ "pm.test(\"Response is ok\", function () {", " pm.response.to.have.status(200);", @@ -406,7 +573,7 @@ { "listen": "test", "script": { - "id": "08b8f487-2318-44b9-bdb8-f1f1041e9462", + "id": "dbabc164-5030-441d-90f7-b29c7fe794df", "exec": [ "pm.test(\"Response is ok\", function () {", " pm.response.to.have.status(200);", @@ -486,7 +653,7 @@ { "listen": "test", "script": { - "id": "08b8f487-2318-44b9-bdb8-f1f1041e9462", + "id": "992ce59d-3cce-43f1-9c3d-895c55a3e0a1", "exec": [ "pm.test(\"Response is ok\", function () {", " pm.response.to.have.status(200);", @@ -566,7 +733,7 @@ { "listen": "test", "script": { - "id": "9b94f2ee-0918-4bc0-84a2-3b148b76126b", + "id": "8ee8bf21-4243-4f15-8a03-2189224360c7", "exec": [ "" ], @@ -636,7 +803,7 @@ { "listen": "prerequest", "script": { - "id": "883519e8-7c7d-49c0-9812-d988d0179907", + "id": "00ffb460-8bfc-4221-af12-b155a34c11fc", "type": "text/javascript", "exec": [ "" @@ -646,14 +813,15 @@ { "listen": "test", "script": { - "id": "7a0738e6-2fc4-45cb-9f1a-1cd57fb76b66", + "id": "ffe44bf8-4bf3-4175-bb4b-3c3910c674c3", "type": "text/javascript", "exec": [ "" ] } } - ] + ], + "protocolProfileBehavior": {} }, { "name": "Services", @@ -664,7 +832,7 @@ { "listen": "test", "script": { - "id": "d87f8a4e-7640-45b8-9d45-4f6e6f2463ee", + "id": "e89a245a-8ee6-4f3b-8cbc-5d7c3bbf687a", "exec": [ "pm.test(\"Response is ok\", function () {", " pm.response.to.have.status(200);", @@ -749,7 +917,7 @@ { "listen": "test", "script": { - "id": "023c5643-6cb1-4cd0-b775-566f232d68f8", + "id": "7c3e8784-0494-4957-ac45-b09c26580b40", "exec": [ "pm.test(\"Response is ok\", function () {", " pm.response.to.have.status(200);", @@ -850,7 +1018,7 @@ { "listen": "test", "script": { - "id": "023c5643-6cb1-4cd0-b775-566f232d68f8", + "id": "860fa275-aed7-481d-967f-11b481df49e0", "exec": [ "pm.test(\"Response is ok\", function () {", " pm.response.to.have.status(200);", @@ -986,7 +1154,7 @@ { "listen": "test", "script": { - "id": "023c5643-6cb1-4cd0-b775-566f232d68f8", + "id": "d89562d5-6742-447a-ae95-1ad044123f70", "exec": [ "pm.test(\"Response is ok\", function () {", " pm.response.to.have.status(200);", @@ -1122,7 +1290,7 @@ { "listen": "test", "script": { - "id": "023c5643-6cb1-4cd0-b775-566f232d68f8", + "id": "e5af74ef-3ae5-45ef-ac0c-30ec1ed006c3", "exec": [ "pm.test(\"Response is ok\", function () {", " pm.response.to.have.status(200);", @@ -1258,7 +1426,7 @@ { "listen": "test", "script": { - "id": "023c5643-6cb1-4cd0-b775-566f232d68f8", + "id": "b21c7e93-24a7-4c0a-90fa-89d3e34f0029", "exec": [ "pm.test(\"Response is ok\", function () {", " pm.response.to.have.status(200);", @@ -1322,7 +1490,7 @@ { "listen": "test", "script": { - "id": "023c5643-6cb1-4cd0-b775-566f232d68f8", + "id": "c6f024c5-f81d-4aca-92e8-b93bf9ac9068", "exec": [ "pm.test(\"Response is ok\", function () {", " pm.response.to.have.status(200);", @@ -1391,7 +1559,7 @@ { "listen": "test", "script": { - "id": "b5a67a19-fd08-40b0-a961-3e9474ab78c6", + "id": "cf487420-5c74-4572-b512-29fe6de72761", "exec": [ "pm.test(\"Response is ok\", function () {", " pm.response.to.have.status(200);", @@ -1494,7 +1662,7 @@ { "listen": "test", "script": { - "id": "d4eb16fe-8495-40e5-9ca3-be20951e5133", + "id": "7f96b2ec-11e5-44ab-b353-c2b4fa034f80", "exec": [ "pm.test(\"Response is ok\", function () {", " pm.response.to.have.status(200);", @@ -1602,7 +1770,7 @@ { "listen": "test", "script": { - "id": "b5a67a19-fd08-40b0-a961-3e9474ab78c6", + "id": "8f497902-ca10-45cb-bb98-96db1604b276", "exec": [ "pm.test(\"Response is ok\", function () {", " pm.response.to.have.status(200);", @@ -1714,7 +1882,7 @@ { "listen": "test", "script": { - "id": "dd4d721d-d874-448b-abc9-59c1afceb58e", + "id": "ea18e56c-382d-42c4-9bc7-477da1d760fe", "exec": [ "pm.test(\"Response is ok\", function () {", " pm.response.to.have.status(200);", @@ -1763,7 +1931,7 @@ { "listen": "test", "script": { - "id": "dd4d721d-d874-448b-abc9-59c1afceb58e", + "id": "c8b61f71-2f28-42a5-9ca1-e80038767fbe", "exec": [ "pm.test(\"Response is ok\", function () {", " pm.response.to.have.status(200);", @@ -1795,7 +1963,10 @@ "header": [], "body": { "mode": "raw", - "raw": "" + "raw": "", + "options": { + "raw": {} + } }, "url": { "raw": "{{endpoint}}/api/services/{{service_id}}", @@ -1870,7 +2041,7 @@ { "listen": "prerequest", "script": { - "id": "4cd2ab82-e60d-45cd-9b74-cb4b5d893f4d", + "id": "2d965d82-4d9e-4c37-a3d2-286c75ae00de", "type": "text/javascript", "exec": [ "" @@ -1880,14 +2051,670 @@ { "listen": "test", "script": { - "id": "c7cb2b6d-289a-4073-b291-202bbec8cb44", + "id": "f3cd55c0-923e-43fa-ab6b-e26df9f20e0a", "type": "text/javascript", "exec": [ "" ] } } - ] + ], + "protocolProfileBehavior": {} + }, + { + "name": "Incidents", + "item": [ + { + "name": "View Service Incidents", + "event": [ + { + "listen": "test", + "script": { + "id": "575ede33-53ac-4e8b-9dbf-3560409b6d1f", + "exec": [ + "pm.test(\"Response is ok\", function () {", + " pm.response.to.have.status(200);", + "});" + ], + "type": "text/javascript" + } + } + ], + "request": { + "auth": { + "type": "bearer", + "bearer": [ + { + "key": "token", + "value": "{{api_key}}", + "type": "string" + } + ] + }, + "method": "GET", + "header": [ + { + "key": "Content-Type", + "name": "Content-Type", + "type": "text", + "value": "application/json" + } + ], + "url": { + "raw": "{{endpoint}}/api/services/1/incidents", + "host": [ + "{{endpoint}}" + ], + "path": [ + "api", + "services", + "1", + "incidents" + ] + }, + "description": "View all incidents for a single service." + }, + "response": [ + { + "name": "View Service Incidents", + "originalRequest": { + "method": "GET", + "header": [ + { + "key": "Content-Type", + "name": "Content-Type", + "type": "text", + "value": "application/json" + } + ], + "url": { + "raw": "{{endpoint}}/api/services/1/incidents", + "host": [ + "{{endpoint}}" + ], + "path": [ + "api", + "services", + "1", + "incidents" + ] + } + }, + "status": "OK", + "code": 200, + "_postman_previewlanguage": "json", + "header": [ + { + "key": "Content-Type", + "value": "application/json" + }, + { + "key": "Date", + "value": "Mon, 04 May 2020 03:13:44 GMT" + }, + { + "key": "Content-Length", + "value": "136" + }, + { + "key": "Connection", + "value": "close" + } + ], + "cookie": [], + "body": "[\n {\n \"id\": 1,\n \"title\": \"Service Downtime\",\n \"service\": 1,\n \"created_at\": \"2020-05-04T03:11:51.752374Z\",\n \"updated_at\": \"2020-05-04T03:11:51.752374Z\"\n }\n]" + } + ] + }, + { + "name": "Create Incident", + "event": [ + { + "listen": "test", + "script": { + "id": "6252ebad-26a9-481d-a233-e097306fc598", + "exec": [ + "pm.test(\"Response is ok\", function () {", + " pm.response.to.have.status(200);", + "});", + "", + "pm.test(\"Incidents JSON\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData.status).to.eql(\"success\");", + " pm.expect(jsonData.method).to.eql(\"create\");", + "});" + ], + "type": "text/javascript" + } + } + ], + "request": { + "auth": { + "type": "bearer", + "bearer": [ + { + "key": "token", + "value": "{{api_key}}", + "type": "string" + } + ] + }, + "method": "POST", + "header": [ + { + "key": "Content-Type", + "name": "Content-Type", + "type": "text", + "value": "application/json" + } + ], + "body": { + "mode": "raw", + "raw": "{\n\t\"title\": \"Service Downtime\",\n\t\"description\": \"\"\n}", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": { + "raw": "{{endpoint}}/api/services/1/incidents", + "host": [ + "{{endpoint}}" + ], + "path": [ + "api", + "services", + "1", + "incidents" + ] + }, + "description": "Create an incident for a service." + }, + "response": [ + { + "name": "Create Incident", + "originalRequest": { + "method": "POST", + "header": [ + { + "key": "Content-Type", + "name": "Content-Type", + "type": "text", + "value": "application/json" + } + ], + "body": { + "mode": "raw", + "raw": "{\n\t\"title\": \"Service Downtime\",\n\t\"description\": \"\",\n\t\"service\": 1\n}", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": { + "raw": "{{endpoint}}/api/services/1/incidents", + "host": [ + "{{endpoint}}" + ], + "path": [ + "api", + "services", + "1", + "incidents" + ] + } + }, + "status": "OK", + "code": 200, + "_postman_previewlanguage": "json", + "header": [ + { + "key": "Content-Type", + "value": "application/json" + }, + { + "key": "Date", + "value": "Mon, 04 May 2020 03:11:51 GMT" + }, + { + "key": "Content-Length", + "value": "207" + }, + { + "key": "Connection", + "value": "close" + } + ], + "cookie": [], + "body": "{\n \"status\": \"success\",\n \"type\": \"incident\",\n \"method\": \"create\",\n \"id\": 1,\n \"output\": {\n \"id\": 1,\n \"title\": \"Service Downtime\",\n \"service\": 1,\n \"created_at\": \"2020-05-04T03:11:51.752374Z\",\n \"updated_at\": \"2020-05-04T03:11:51.752374Z\"\n }\n}" + } + ] + }, + { + "name": "Update Service Incident", + "event": [ + { + "listen": "test", + "script": { + "id": "42cd68de-5bd4-4d4e-b687-fa0bafc1d61a", + "exec": [ + "pm.test(\"Response is ok\", function () {", + " pm.response.to.have.status(200);", + "});" + ], + "type": "text/javascript" + } + } + ], + "request": { + "auth": { + "type": "bearer", + "bearer": [ + { + "key": "token", + "value": "{{api_key}}", + "type": "string" + } + ] + }, + "method": "POST", + "header": [ + { + "key": "Content-Type", + "name": "Content-Type", + "type": "text", + "value": "application/json" + } + ], + "body": { + "mode": "raw", + "raw": "{\n\t\"title\": \"Updated Downtime\",\n\t\"description\": \"This is an update for an incident\"\n}" + }, + "url": { + "raw": "{{endpoint}}/api/incidents/1", + "host": [ + "{{endpoint}}" + ], + "path": [ + "api", + "incidents", + "1" + ] + }, + "description": "View all incidents for a single service." + }, + "response": [] + }, + { + "name": "Delete Incident", + "event": [ + { + "listen": "test", + "script": { + "id": "c6735dbe-86e8-4b42-9b04-6fc1fea949df", + "exec": [ + "pm.test(\"Response is ok\", function () {", + " pm.response.to.have.status(200);", + "});" + ], + "type": "text/javascript" + } + } + ], + "request": { + "auth": { + "type": "bearer", + "bearer": [ + { + "key": "token", + "value": "{{api_key}}", + "type": "string" + } + ] + }, + "method": "DELETE", + "header": [ + { + "key": "Content-Type", + "name": "Content-Type", + "type": "text", + "value": "application/json" + } + ], + "url": { + "raw": "{{endpoint}}/api/incidents/1", + "host": [ + "{{endpoint}}" + ], + "path": [ + "api", + "incidents", + "1" + ] + }, + "description": "View all incidents for a single service." + }, + "response": [ + { + "name": "Delete Incident", + "originalRequest": { + "method": "DELETE", + "header": [ + { + "key": "Content-Type", + "name": "Content-Type", + "type": "text", + "value": "application/json" + } + ], + "url": { + "raw": "{{endpoint}}/api/incidents/2", + "host": [ + "{{endpoint}}" + ], + "path": [ + "api", + "incidents", + "2" + ] + } + }, + "status": "OK", + "code": 200, + "_postman_previewlanguage": "json", + "header": [ + { + "key": "Content-Type", + "value": "application/json" + }, + { + "key": "Date", + "value": "Mon, 04 May 2020 03:31:48 GMT" + }, + { + "key": "Content-Length", + "value": "207" + }, + { + "key": "Connection", + "value": "close" + } + ], + "cookie": [], + "body": "{\n \"status\": \"success\",\n \"type\": \"incident\",\n \"method\": \"delete\",\n \"id\": 2,\n \"output\": {\n \"id\": 2,\n \"title\": \"Service Downtime\",\n \"service\": 1,\n \"created_at\": \"2020-05-04T03:18:24.818629Z\",\n \"updated_at\": \"2020-05-04T03:18:24.818629Z\"\n }\n}" + } + ] + }, + { + "name": "Incident Updates", + "event": [ + { + "listen": "test", + "script": { + "id": "e2e7d38f-efae-44d1-9361-cd301547feb3", + "exec": [ + "pm.test(\"Response is ok\", function () {", + " pm.response.to.have.status(200);", + "});" + ], + "type": "text/javascript" + } + } + ], + "request": { + "auth": { + "type": "bearer", + "bearer": [ + { + "key": "token", + "value": "{{api_key}}", + "type": "string" + } + ] + }, + "method": "GET", + "header": [ + { + "key": "Content-Type", + "name": "Content-Type", + "type": "text", + "value": "application/json" + } + ], + "url": { + "raw": "{{endpoint}}/api/incidents/2/updates", + "host": [ + "{{endpoint}}" + ], + "path": [ + "api", + "incidents", + "2", + "updates" + ] + }, + "description": "View all incidents for a single service." + }, + "response": [] + }, + { + "name": "Create Incident Update", + "event": [ + { + "listen": "test", + "script": { + "id": "4478e35f-8da6-4f74-9100-0bb92ac6466e", + "exec": [ + "pm.test(\"Response is ok\", function () {", + " pm.response.to.have.status(200);", + "});" + ], + "type": "text/javascript" + } + } + ], + "request": { + "auth": { + "type": "bearer", + "bearer": [ + { + "key": "token", + "value": "{{api_key}}", + "type": "string" + } + ] + }, + "method": "POST", + "header": [ + { + "key": "Content-Type", + "name": "Content-Type", + "type": "text", + "value": "application/json" + } + ], + "body": { + "mode": "raw", + "raw": "{\n\t\"message\": \"Website is loading very slowly, looking into this.\",\n\t\"type\": \"Investigating\"\n}" + }, + "url": { + "raw": "{{endpoint}}/api/incidents/2/updates", + "host": [ + "{{endpoint}}" + ], + "path": [ + "api", + "incidents", + "2", + "updates" + ] + }, + "description": "View all incidents for a single service." + }, + "response": [ + { + "name": "Create Incident Update", + "originalRequest": { + "method": "POST", + "header": [ + { + "key": "Content-Type", + "name": "Content-Type", + "type": "text", + "value": "application/json" + } + ], + "body": { + "mode": "raw", + "raw": "{\n\t\"message\": \"Website is loading very slowly, looking into this.\",\n\t\"type\": \"Investigating\"\n}" + }, + "url": { + "raw": "{{endpoint}}/api/incidents/2/updates", + "host": [ + "{{endpoint}}" + ], + "path": [ + "api", + "incidents", + "2", + "updates" + ] + } + }, + "status": "OK", + "code": 200, + "_postman_previewlanguage": "json", + "header": [ + { + "key": "Content-Type", + "value": "application/json" + }, + { + "key": "Date", + "value": "Mon, 04 May 2020 03:20:05 GMT" + }, + { + "key": "Content-Length", + "value": "261" + }, + { + "key": "Connection", + "value": "close" + } + ], + "cookie": [], + "body": "{\n \"status\": \"success\",\n \"type\": \"incident_update\",\n \"method\": \"create\",\n \"id\": 1,\n \"output\": {\n \"id\": 1,\n \"message\": \"Website is loading very slowly, looking into this.\",\n \"type\": \"Investigating\",\n \"created_at\": \"2020-05-04T03:20:05.102435Z\",\n \"updated_at\": \"2020-05-04T03:20:05.102435Z\"\n }\n}" + } + ] + }, + { + "name": "Delete Incident Update", + "event": [ + { + "listen": "test", + "script": { + "id": "4578b229-5a85-4d3c-acdc-360ad50a35f2", + "exec": [ + "pm.test(\"Response is ok\", function () {", + " pm.response.to.have.status(200);", + "});" + ], + "type": "text/javascript" + } + } + ], + "request": { + "auth": { + "type": "bearer", + "bearer": [ + { + "key": "token", + "value": "{{api_key}}", + "type": "string" + } + ] + }, + "method": "DELETE", + "header": [ + { + "key": "Content-Type", + "name": "Content-Type", + "type": "text", + "value": "application/json" + } + ], + "url": { + "raw": "{{endpoint}}/api/incidents/2/updates/1", + "host": [ + "{{endpoint}}" + ], + "path": [ + "api", + "incidents", + "2", + "updates", + "1" + ] + }, + "description": "View all incidents for a single service." + }, + "response": [ + { + "name": "Delete Incident Update", + "originalRequest": { + "method": "DELETE", + "header": [ + { + "key": "Content-Type", + "name": "Content-Type", + "type": "text", + "value": "application/json" + } + ], + "url": { + "raw": "{{endpoint}}/api/incidents/2/updates/1", + "host": [ + "{{endpoint}}" + ], + "path": [ + "api", + "incidents", + "2", + "updates", + "1" + ] + } + }, + "status": "OK", + "code": 200, + "_postman_previewlanguage": "json", + "header": [ + { + "key": "Content-Type", + "value": "application/json" + }, + { + "key": "Date", + "value": "Mon, 04 May 2020 03:23:00 GMT" + }, + { + "key": "Content-Length", + "value": "261" + }, + { + "key": "Connection", + "value": "close" + } + ], + "cookie": [], + "body": "{\n \"status\": \"success\",\n \"type\": \"incident_update\",\n \"method\": \"delete\",\n \"id\": 1,\n \"output\": {\n \"id\": 1,\n \"message\": \"Website is loading very slowly, looking into this.\",\n \"type\": \"Investigating\",\n \"created_at\": \"2020-05-04T03:20:05.102435Z\",\n \"updated_at\": \"2020-05-04T03:20:05.102435Z\"\n }\n}" + } + ] + } + ], + "protocolProfileBehavior": {} }, { "name": "Groups", @@ -1898,7 +2725,7 @@ { "listen": "test", "script": { - "id": "d87f8a4e-7640-45b8-9d45-4f6e6f2463ee", + "id": "e83ac60d-3683-441e-a78b-d15b6c2b704d", "exec": [ "pm.test(\"View All Groups\", function () {", " var jsonData = pm.response.json();", @@ -1979,7 +2806,7 @@ { "listen": "test", "script": { - "id": "023c5643-6cb1-4cd0-b775-566f232d68f8", + "id": "d2bba501-9674-4143-a51d-33721eb4785f", "exec": [ "pm.test(\"Response is ok\", function () {", " pm.response.to.have.status(200);", @@ -2080,7 +2907,7 @@ { "listen": "test", "script": { - "id": "d4eb16fe-8495-40e5-9ca3-be20951e5133", + "id": "6ea60d3a-b601-41a8-8b5e-734f3946d34c", "exec": [ "pm.test(\"Response is ok\", function () {", " pm.response.to.have.status(200);", @@ -2184,7 +3011,7 @@ { "listen": "test", "script": { - "id": "b5a67a19-fd08-40b0-a961-3e9474ab78c6", + "id": "4efd65bf-6e56-4600-91af-36cb82ffb125", "exec": [ "pm.test(\"Response is ok\", function () {", " pm.response.to.have.status(200);", @@ -2214,7 +3041,10 @@ ], "body": { "mode": "raw", - "raw": "[{\"group\":1,\"order\":1},{\"group\":2,\"order\":2}]" + "raw": "[{\"group\":1,\"order\":1},{\"group\":2,\"order\":2}]", + "options": { + "raw": {} + } }, "url": { "raw": "{{endpoint}}/api/reorder/groups", @@ -2237,7 +3067,7 @@ { "listen": "test", "script": { - "id": "dd4d721d-d874-448b-abc9-59c1afceb58e", + "id": "ec903995-c37b-436a-b554-c9e4ee5ff52a", "exec": [ "pm.test(\"Response is ok\", function () {", " pm.response.to.have.status(200);", @@ -2344,7 +3174,7 @@ { "listen": "prerequest", "script": { - "id": "4cd2ab82-e60d-45cd-9b74-cb4b5d893f4d", + "id": "abe8dbf2-9e63-49b5-b5d3-7a50217c87a3", "type": "text/javascript", "exec": [ "" @@ -2354,7 +3184,7 @@ { "listen": "test", "script": { - "id": "c7cb2b6d-289a-4073-b291-202bbec8cb44", + "id": "de397a38-c190-4928-92f0-393ab85e5342", "type": "text/javascript", "exec": [ "" @@ -2373,7 +3203,7 @@ { "listen": "test", "script": { - "id": "08b8f487-2318-44b9-bdb8-f1f1041e9462", + "id": "eaec5a14-dd31-4e9c-9e30-8999591514c3", "exec": [ "pm.test(\"Response is ok\", function () {", " pm.response.to.have.status(200);", @@ -2505,7 +3335,7 @@ { "listen": "test", "script": { - "id": "f6848835-443c-4dfa-abb9-ddea712cd0d1", + "id": "f858d94a-6534-452b-9197-99c64d7b4009", "exec": [ "" ], @@ -2549,7 +3379,7 @@ { "listen": "test", "script": { - "id": "9a2977fe-9689-4039-bdcb-eaa34abee958", + "id": "20b79651-9175-4a30-98f3-4666ebf9ab05", "exec": [ "pm.test(\"Response is ok\", function () {", " pm.response.to.have.status(200);", @@ -2638,7 +3468,7 @@ { "listen": "test", "script": { - "id": "1913466d-83b2-4d5b-ac48-89c9abdd0c8d", + "id": "fd7e8b36-70c2-4060-bb50-5d87e663dea3", "exec": [ "pm.test(\"Response is ok\", function () {", " pm.response.to.have.status(200);", @@ -2744,7 +3574,7 @@ { "listen": "test", "script": { - "id": "555b7ba4-bb36-4e86-a541-fa5a5008f951", + "id": "925d3cea-fa59-42db-9d4e-154021cfbd37", "exec": [ "pm.test(\"Response is ok\", function () {", " pm.response.to.have.status(200);", @@ -2834,7 +3664,7 @@ { "listen": "prerequest", "script": { - "id": "d23b1822-d1de-4545-9a82-3cf4719a7e82", + "id": "2802ca86-12c2-41ce-947d-e086fcb7c753", "exec": [ "" ], @@ -2844,7 +3674,7 @@ { "listen": "test", "script": { - "id": "b0d22bbd-a428-4df3-8295-b40542bfa21f", + "id": "19f750c7-1df2-4a03-b0f0-b487d80d4917", "exec": [ "pm.test(\"Response is ok\", function () {", " pm.response.to.have.status(200);", @@ -2949,7 +3779,7 @@ { "listen": "test", "script": { - "id": "bd8c3425-a97f-4f8c-b849-71b65dd543ee", + "id": "d94974c7-7c6f-4298-8ab7-6bd7a789020f", "exec": [ "pm.test(\"Response is ok\", function () {", " pm.response.to.have.status(200);", @@ -3050,7 +3880,7 @@ { "listen": "prerequest", "script": { - "id": "9720db1a-bc4c-4e05-94ea-2782aaafb793", + "id": "8cef4ad5-1c96-46e8-8fc9-9e9e044730dc", "type": "text/javascript", "exec": [ "" @@ -3060,7 +3890,7 @@ { "listen": "test", "script": { - "id": "c667ae2d-41f3-4dea-ab62-3b544e2bc8f9", + "id": "872da99f-a57d-4a54-bd5e-18b5529c715f", "type": "text/javascript", "exec": [ "" @@ -3079,7 +3909,7 @@ { "listen": "test", "script": { - "id": "e9105618-6db8-4a57-ae7f-782989842f4a", + "id": "9f3e4a3e-a690-4dcb-897f-fdfa8503d79f", "exec": [ "pm.test(\"Response is ok\", function () {", " pm.response.to.have.status(200);", @@ -3164,7 +3994,7 @@ { "listen": "test", "script": { - "id": "acac30b6-3caa-46c9-89be-1efbadf89f22", + "id": "7a42a113-8bdb-47dd-a914-36bc2aa65aba", "exec": [ "pm.test(\"Response is ok\", function () {", " pm.response.to.have.status(200);", @@ -3252,7 +4082,7 @@ { "listen": "test", "script": { - "id": "d714d71d-4d6a-4b2e-a6ea-16c34dec3041", + "id": "2a8a1a62-57ea-4a7a-9f0a-713ac548c151", "exec": [ "pm.test(\"Response is ok\", function () {", " pm.response.to.have.status(200);", @@ -3291,7 +4121,10 @@ ], "body": { "mode": "raw", - "raw": "{\n \"method\": \"slack\",\n \"host\": \"https://hooks.slack.com/services/EXAMPLEIDHERE/BV33WKP0C/MtKw3Kc8BFylTv4pohKqHtXX\",\n \"enabled\": true,\n \"limits\": 55\n}" + "raw": "{\n \"method\": \"slack\",\n \"host\": \"https://hooks.slack.com/services/EXAMPLEIDHERE/BV33WKP0C/MtKw3Kc8BFylTv4pohKqHtXX\",\n \"enabled\": true,\n \"limits\": 55\n}", + "options": { + "raw": {} + } }, "url": { "raw": "{{endpoint}}/api/notifier/slack", @@ -3356,6 +4189,127 @@ "body": "{\n \"status\": \"success\",\n \"type\": \"string\",\n \"method\": \"update\",\n \"output\": \"slack\"\n}" } ] + }, + { + "name": "Test Notifier", + "event": [ + { + "listen": "test", + "script": { + "id": "198374af-ccbc-4e2e-8af2-df58622379d4", + "exec": [ + "pm.test(\"Response is ok\", function () {", + " pm.response.to.have.status(200);", + "});", + "", + "pm.test(\"Test Notifier\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData.success).to.eql(false);", + "});" + ], + "type": "text/javascript" + } + } + ], + "request": { + "auth": { + "type": "bearer", + "bearer": [ + { + "key": "token", + "value": "{{api_key}}", + "type": "string" + } + ] + }, + "method": "POST", + "header": [ + { + "key": "Content-Type", + "name": "Content-Type", + "type": "text", + "value": "application/json" + } + ], + "body": { + "mode": "raw", + "raw": "{\n \"method\": \"slack\",\n \"host\": \"https://hooks.slack.com/services/EXAMPLEIDHERE/BV33WKP0C/MtKw3Kc8BFylTv4pohKqHtXX\",\n \"enabled\": true,\n \"limits\": 55\n}", + "options": { + "raw": {} + } + }, + "url": { + "raw": "{{endpoint}}/api/notifier/slack/test", + "host": [ + "{{endpoint}}" + ], + "path": [ + "api", + "notifier", + "slack", + "test" + ] + }, + "description": "Update a notifier to change it's values." + }, + "response": [ + { + "name": "Test Notifier", + "originalRequest": { + "method": "POST", + "header": [ + { + "key": "Content-Type", + "name": "Content-Type", + "type": "text", + "value": "application/json" + } + ], + "body": { + "mode": "raw", + "raw": "{\n \"method\": \"slack\",\n \"host\": \"https://hooks.slack.com/services/EXAMPLEIDHERE/BV33WKP0C/MtKw3Kc8BFylTv4pohKqHtXX\",\n \"enabled\": true,\n \"limits\": 55\n}", + "options": { + "raw": {} + } + }, + "url": { + "raw": "{{endpoint}}/api/notifier/slack/test", + "host": [ + "{{endpoint}}" + ], + "path": [ + "api", + "notifier", + "slack", + "test" + ] + } + }, + "status": "OK", + "code": 200, + "_postman_previewlanguage": "json", + "header": [ + { + "key": "Content-Type", + "value": "application/json" + }, + { + "key": "Date", + "value": "Mon, 04 May 2020 03:25:07 GMT" + }, + { + "key": "Connection", + "value": "close" + }, + { + "key": "Transfer-Encoding", + "value": "chunked" + } + ], + "cookie": [], + "body": "{\n \"success\": false,\n \"response\": \"There's been a glitch… | Slack

There’s been a glitch…

We’re not quite sure what went wrong. You can go back, or try looking on our Help Center if you need a hand.

\\n\\n\\n\\n\",\n \"error\": {}\n}" + } + ] } ], "description": "Statping contains multiple notifiers that will send you a notification whenever a service become offline, or online. You can create your own 3rd party notifier by reading more on the [Notifiers Wiki](https://github.com/statping/statping/wiki/Notifiers) on the Github repo.", @@ -3373,7 +4327,7 @@ { "listen": "prerequest", "script": { - "id": "bd5d8232-7ed7-4607-ab7c-14de85c3a033", + "id": "8f3b2e75-ce23-4294-b5bb-05b1248b9ef3", "type": "text/javascript", "exec": [ "" @@ -3383,7 +4337,7 @@ { "listen": "test", "script": { - "id": "ef420ba0-37dc-4ffc-b38f-a43ccca76606", + "id": "06653dbc-888b-4016-8964-82d25e0273e3", "type": "text/javascript", "exec": [ "" @@ -3402,7 +4356,7 @@ { "listen": "test", "script": { - "id": "3c484d1b-6e77-4084-b844-3ca77dc50108", + "id": "b2374cab-1ce8-4f9e-a2fa-f92477936cd4", "exec": [ "pm.test(\"Response is ok\", function () {", " pm.response.to.have.status(200);", @@ -3480,7 +4434,7 @@ { "listen": "test", "script": { - "id": "12caf74a-61d7-4f6e-89b5-fca2f65464c4", + "id": "66307d95-1833-4786-a29a-40fc05153d09", "exec": [ "pm.test(\"Response is ok\", function () {", " pm.response.to.have.status(200);", @@ -3583,7 +4537,7 @@ { "listen": "test", "script": { - "id": "c30cc333-53f4-4e9a-9c32-958c905ec163", + "id": "7e17e9cb-6750-411a-8a9a-335ece3b3cda", "exec": [ "pm.test(\"Response is ok\", function () {", " pm.response.to.have.status(200);", @@ -3661,7 +4615,7 @@ { "listen": "test", "script": { - "id": "e9dd78cc-0f38-4516-bf82-38dd3451b2e7", + "id": "c89210ce-dfce-4acf-8bf5-f601f53d353e", "exec": [ "pm.test(\"Response is ok\", function () {", " pm.response.to.have.status(200);", @@ -3693,7 +4647,10 @@ ], "body": { "mode": "raw", - "raw": "{\n \"title\": \"Updated Message\",\n \"description\": \"This message was updated\",\n \"start_on\": \"2022-11-17T03:28:16.323797-08:00\",\n \"end_on\": \"2022-11-17T05:13:16.323798-08:00\",\n \"service\": 1,\n \"notify_users\": true,\n \"notify_method\": \"email\",\n \"notify_before\": 3,\n \"notify_before_scale\": \"hour\"\n}" + "raw": "{\n \"title\": \"Updated Message\",\n \"description\": \"This message was updated\",\n \"start_on\": \"2022-11-17T03:28:16.323797-08:00\",\n \"end_on\": \"2022-11-17T05:13:16.323798-08:00\",\n \"service\": 1,\n \"notify_users\": true,\n \"notify_method\": \"email\",\n \"notify_before\": 3,\n \"notify_before_scale\": \"hour\"\n}", + "options": { + "raw": {} + } }, "url": { "raw": "{{endpoint}}/api/messages/{{message_id}}", @@ -3765,7 +4722,7 @@ { "listen": "test", "script": { - "id": "6cb2527f-41c2-4feb-9573-1e4d59efa116", + "id": "61a55ba9-d524-4509-a93f-679b5574182a", "exec": [ "pm.test(\"Response is ok\", function () {", " pm.response.to.have.status(200);", @@ -3864,7 +4821,7 @@ { "listen": "prerequest", "script": { - "id": "8d24599b-f157-475b-9e30-06c1171c85bc", + "id": "b2160e12-ca83-4454-be33-7eac6f32e16b", "type": "text/javascript", "exec": [ "" @@ -3874,7 +4831,7 @@ { "listen": "test", "script": { - "id": "497c2428-fe8a-42c2-bf6f-8f2cdf959771", + "id": "a140fc05-3ec2-40dc-a5c5-93d055242995", "type": "text/javascript", "exec": [ "" @@ -3893,7 +4850,7 @@ { "listen": "test", "script": { - "id": "54bded63-de27-4839-8783-25874c35c3ea", + "id": "e94a6ff9-bbea-4947-9360-6302a29bdddd", "exec": [ "pm.test(\"Response is ok\", function () {", " pm.response.to.have.status(200);", @@ -3972,7 +4929,7 @@ { "listen": "test", "script": { - "id": "af07a95b-1bf5-42c7-bd3f-a32f3ab2a264", + "id": "4d656189-d860-43d5-b9b9-d526c6d52338", "exec": [ "pm.test(\"Response is ok\", function () {", " pm.response.to.have.status(200);", @@ -4015,7 +4972,10 @@ ], "body": { "mode": "raw", - "raw": "{\n \"service_id\": 2,\n \"name\": \"Server Checkin\",\n \"interval\": 900,\n \"grace\": 60\n}" + "raw": "{\n \"service_id\": 2,\n \"name\": \"Server Checkin\",\n \"interval\": 900,\n \"grace\": 60\n}", + "options": { + "raw": {} + } }, "url": { "raw": "{{endpoint}}/api/checkins", @@ -4085,7 +5045,7 @@ { "listen": "test", "script": { - "id": "652a1c5b-5379-43c2-9cd8-ebd8f8dad0f6", + "id": "cb89fcee-0ae4-4496-a159-c214238965ab", "exec": [ "pm.test(\"Response is ok\", function () {", " pm.response.to.have.status(200);", @@ -4161,7 +5121,7 @@ { "listen": "test", "script": { - "id": "93ff6b86-368b-406f-9d75-07338714ebca", + "id": "25998408-3f55-4d42-ac4f-b6163c1fc0a5", "exec": [ "pm.test(\"Response is ok\", function () {", " pm.response.to.have.status(200);", @@ -4242,7 +5202,7 @@ { "listen": "test", "script": { - "id": "d3fdc6b9-d8ca-4634-a735-af8db0f31cef", + "id": "0ddca6d9-b1f9-49db-be8d-75fcab4cab0d", "exec": [ "pm.test(\"Response is ok\", function () {", " pm.response.to.have.status(200);", @@ -4276,7 +5236,10 @@ "header": [], "body": { "mode": "raw", - "raw": "" + "raw": "", + "options": { + "raw": {} + } }, "url": { "raw": "{{endpoint}}/api/checkins/{{checkin_id}}", @@ -4351,7 +5314,7 @@ { "listen": "prerequest", "script": { - "id": "fefe9fc9-8020-41ec-b20f-dd2c5ad951e9", + "id": "d880b73c-1edd-40d7-aac5-6ef0d2e2704b", "type": "text/javascript", "exec": [ "" @@ -4361,7 +5324,7 @@ { "listen": "test", "script": { - "id": "4a611b52-8ec2-4e26-8ed8-51f2729f93a1", + "id": "adf70343-e8f3-4162-8eeb-6fb71784ef57", "type": "text/javascript", "exec": [ "" @@ -4380,11 +5343,9 @@ { "listen": "test", "script": { - "id": "cf003eb2-e18e-46f0-bee2-2a9915525651", + "id": "11f52299-58b7-4a57-9842-252e2d8e139e", "exec": [ - "pm.test(\"Response is ok\", function () {", - " pm.response.to.have.status(200);", - "});" + "" ], "type": "text/javascript" } @@ -4424,11 +5385,9 @@ { "listen": "test", "script": { - "id": "8520bcc3-1176-4eb9-b22e-31169e093568", + "id": "8dace46e-1e0d-4d7c-90f0-c5a29cd2f0c0", "exec": [ - "pm.test(\"Response is ok\", function () {", - " pm.response.to.have.status(200);", - "});" + "" ], "type": "text/javascript" } @@ -4467,11 +5426,9 @@ { "listen": "test", "script": { - "id": "d9665e36-02b4-4c9f-b155-aded33b3936e", + "id": "b18f4b1d-3019-4b96-8203-d1876deab89f", "exec": [ - "pm.test(\"Response is ok\", function () {", - " pm.response.to.have.status(200);", - "});" + "" ], "type": "text/javascript" } @@ -4519,11 +5476,9 @@ { "listen": "test", "script": { - "id": "22213939-d2be-47fb-8c76-b8b4c4956b81", + "id": "5e59d318-3e11-44be-9d78-85398d35e9be", "exec": [ - "pm.test(\"Response is ok\", function () {", - " pm.response.to.have.status(200);", - "});" + "" ], "type": "text/javascript" } @@ -4609,7 +5564,7 @@ { "listen": "prerequest", "script": { - "id": "cb6d709c-85c1-4dc3-9434-04f817db23ea", + "id": "8512f9f2-50af-4c7c-90af-4feb43908ac9", "type": "text/javascript", "exec": [ "" @@ -4619,7 +5574,311 @@ { "listen": "test", "script": { - "id": "88b7bef2-103e-455c-a8f8-bce15c73d6d7", + "id": "f28d8c39-84fa-4e20-9bd9-e8f8a0158919", + "type": "text/javascript", + "exec": [ + "" + ] + } + } + ], + "protocolProfileBehavior": {} + }, + { + "name": "oAuth", + "item": [ + { + "name": "Set Keys", + "event": [ + { + "listen": "test", + "script": { + "id": "3b2cf616-7e7d-4e11-beee-7027e0ed6dd2", + "exec": [ + "pm.test(\"Response is ok\", function () {", + " pm.response.to.have.status(200);", + "});", + "", + "pm.test(\"update check\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData.status).to.eql(\"success\");", + " pm.expect(jsonData.method).to.eql(\"update\");", + "});" + ], + "type": "text/javascript" + } + } + ], + "request": { + "auth": { + "type": "bearer", + "bearer": [ + { + "key": "token", + "value": "{{api_key}}", + "type": "string" + } + ] + }, + "method": "POST", + "header": [], + "body": { + "mode": "raw", + "raw": "{\n \"gh_client_id\": \"githubid\",\n \"gh_client_secret\": \"githubsecret\",\n \"google_client_id\": \"googleid\",\n \"google_client_secret\": \"googlesecret\",\n \"oauth_domains\": \"gmail.com,yahoo.com,socialeck.com\",\n \"oauth_providers\": \"local,slack,google,github\",\n \"slack_client_id\": \"936045034737.1044972172659\",\n \"slack_client_secret\": \"05dd514efb382971e538a5561981e54a\",\n \"slack_team\": \"dev\"\n}", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": { + "raw": "{{endpoint}}/api/oauth", + "host": [ + "{{endpoint}}" + ], + "path": [ + "api", + "oauth" + ] + }, + "description": "This endpoint will return the last line in the logs." + }, + "response": [ + { + "name": "Statping Details", + "originalRequest": { + "method": "GET", + "header": [], + "url": { + "raw": "{{endpoint}}/api", + "host": [ + "{{endpoint}}" + ], + "path": [ + "api" + ] + } + }, + "status": "OK", + "code": 200, + "_postman_previewlanguage": "json", + "header": [ + { + "key": "Content-Length", + "value": "398" + }, + { + "key": "Content-Type", + "value": "application/json" + }, + { + "key": "Date", + "value": "Sat, 02 May 2020 01:06:09 GMT" + } + ], + "cookie": [], + "body": "{\n \"admin\": false,\n \"allow_reports\": false,\n \"created_at\": \"2020-05-02T01:00:07.885973685Z\",\n \"description\": \"This data is only used to testing\",\n \"domain\": \"http://localhost:8080\",\n \"footer\": null,\n \"logged_in\": false,\n \"migration_id\": 1588381207,\n \"name\": \"Statping Sample Data\",\n \"setup\": true,\n \"started_on\": \"2020-05-02T01:00:14.255837864Z\",\n \"updated_at\": \"2020-05-02T01:00:12.731269305Z\",\n \"using_cdn\": false,\n \"version\": \"0.90.34\"\n}" + } + ] + }, + { + "name": "Get Keys", + "event": [ + { + "listen": "test", + "script": { + "id": "a3dd164d-56dc-43c9-80ae-ad42ced9542f", + "exec": [ + "pm.test(\"Response is ok\", function () {", + " pm.response.to.have.status(200);", + "});", + "", + "", + "pm.test(\"correct values\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData.gh_client_id).to.eql(\"githubid\");", + " pm.expect(jsonData.gh_client_secret).to.eql(\"githubsecret\");", + "});" + ], + "type": "text/javascript" + } + } + ], + "request": { + "auth": { + "type": "bearer", + "bearer": [ + { + "key": "token", + "value": "{{api_key}}", + "type": "string" + } + ] + }, + "method": "GET", + "header": [], + "url": { + "raw": "{{endpoint}}/api/oauth", + "host": [ + "{{endpoint}}" + ], + "path": [ + "api", + "oauth" + ] + }, + "description": "This endpoint will return the last line in the logs." + }, + "response": [ + { + "name": "Statping Details", + "originalRequest": { + "method": "GET", + "header": [], + "url": { + "raw": "{{endpoint}}/api", + "host": [ + "{{endpoint}}" + ], + "path": [ + "api" + ] + } + }, + "status": "OK", + "code": 200, + "_postman_previewlanguage": "json", + "header": [ + { + "key": "Content-Length", + "value": "398" + }, + { + "key": "Content-Type", + "value": "application/json" + }, + { + "key": "Date", + "value": "Sat, 02 May 2020 01:06:09 GMT" + } + ], + "cookie": [], + "body": "{\n \"admin\": false,\n \"allow_reports\": false,\n \"created_at\": \"2020-05-02T01:00:07.885973685Z\",\n \"description\": \"This data is only used to testing\",\n \"domain\": \"http://localhost:8080\",\n \"footer\": null,\n \"logged_in\": false,\n \"migration_id\": 1588381207,\n \"name\": \"Statping Sample Data\",\n \"setup\": true,\n \"started_on\": \"2020-05-02T01:00:14.255837864Z\",\n \"updated_at\": \"2020-05-02T01:00:12.731269305Z\",\n \"using_cdn\": false,\n \"version\": \"0.90.34\"\n}" + } + ] + }, + { + "name": "Authenticate token", + "event": [ + { + "listen": "test", + "script": { + "id": "2d5f11de-4041-4667-b094-4e1934195649", + "exec": [ + "pm.test(\"Response is ok\", function () {", + " pm.response.to.have.status(500);", + "});", + "", + "pm.test(\"missing values\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData.error).to.eql(\"oauth2: server response missing access_token\");", + "});" + ], + "type": "text/javascript" + } + } + ], + "protocolProfileBehavior": { + "disableBodyPruning": true + }, + "request": { + "auth": { + "type": "noauth" + }, + "method": "GET", + "header": [], + "body": { + "mode": "formdata", + "formdata": [ + { + "key": "code", + "value": "936045034737.1125195726608.7440bec1a519b713bd3c39c4aaed46f5a4891878c1616d1a6ac2be3bc0cc9867", + "type": "text" + }, + { + "key": "state", + "value": "0", + "type": "text" + } + ] + }, + "url": { + "raw": "{{endpoint}}/oauth/slack", + "host": [ + "{{endpoint}}" + ], + "path": [ + "oauth", + "slack" + ] + }, + "description": "This endpoint will return the last line in the logs." + }, + "response": [ + { + "name": "Statping Details", + "originalRequest": { + "method": "GET", + "header": [], + "url": { + "raw": "{{endpoint}}/api", + "host": [ + "{{endpoint}}" + ], + "path": [ + "api" + ] + } + }, + "status": "OK", + "code": 200, + "_postman_previewlanguage": "json", + "header": [ + { + "key": "Content-Length", + "value": "398" + }, + { + "key": "Content-Type", + "value": "application/json" + }, + { + "key": "Date", + "value": "Sat, 02 May 2020 01:06:09 GMT" + } + ], + "cookie": [], + "body": "{\n \"admin\": false,\n \"allow_reports\": false,\n \"created_at\": \"2020-05-02T01:00:07.885973685Z\",\n \"description\": \"This data is only used to testing\",\n \"domain\": \"http://localhost:8080\",\n \"footer\": null,\n \"logged_in\": false,\n \"migration_id\": 1588381207,\n \"name\": \"Statping Sample Data\",\n \"setup\": true,\n \"started_on\": \"2020-05-02T01:00:14.255837864Z\",\n \"updated_at\": \"2020-05-02T01:00:12.731269305Z\",\n \"using_cdn\": false,\n \"version\": \"0.90.34\"\n}" + } + ] + } + ], + "description": "You can allow other users to login through other services by using OAuth.\n\n- [Google OAuth](https://developers.google.com/identity/protocols/oauth2)\n- [Slack OAuth](https://api.slack.com/legacy/oauth)\n- [Github OAuth](https://developer.github.com/apps/building-oauth-apps/authorizing-oauth-apps/)\n\n### Redirect URL\nEach OAuth service has a dedicated redirect URL: `/oauth/{provider}`. Replace `{provider}` with google, slack, or github depending on which service you're using.", + "event": [ + { + "listen": "prerequest", + "script": { + "id": "2792fd81-5e3a-434b-8f51-992bea3a2b49", + "type": "text/javascript", + "exec": [ + "" + ] + } + }, + { + "listen": "test", + "script": { + "id": "467bdaac-344d-451e-a4b4-825aec80ceef", "type": "text/javascript", "exec": [ "" @@ -4644,7 +5903,7 @@ { "listen": "prerequest", "script": { - "id": "e37b4946-9995-4fb5-88a9-39adb191d076", + "id": "a88caffc-d042-4f68-9757-3b5b3e628737", "type": "text/javascript", "exec": [ "" @@ -4654,12 +5913,13 @@ { "listen": "test", "script": { - "id": "8fa9bd45-c197-4751-baa6-c58143156aea", + "id": "dc71e455-8623-429d-890b-0cfc3bb9f8d1", "type": "text/javascript", "exec": [ "" ] } } - ] + ], + "protocolProfileBehavior": {} } \ No newline at end of file diff --git a/dev/postman_env_mysql.json b/dev/postman_env_mysql.json new file mode 100644 index 00000000..02284809 --- /dev/null +++ b/dev/postman_env_mysql.json @@ -0,0 +1,49 @@ +{ + "id": "0ff1dcd6-54f3-44a7-9c18-cc3c8e7df357", + "name": "Local Statping", + "values": [ + { + "key": "endpoint", + "value": "http://0.0.0.0:8585", + "enabled": true + }, + { + "key": "api_key", + "value": "demosecret123", + "enabled": true + }, + { + "key": "db_connection", + "value": "mysql", + "enabled": true + }, + { + "key": "db_host", + "value": "localhost", + "enabled": true + }, + { + "key": "db_user", + "value": "root", + "enabled": true + }, + { + "key": "db_password", + "value": "password123", + "enabled": true + }, + { + "key": "db_database", + "value": "statping", + "enabled": true + }, + { + "key": "db_port", + "value": "3306", + "enabled": true + } + ], + "_postman_variable_scope": "environment", + "_postman_exported_at": "2020-05-18T20:44:05.571Z", + "_postman_exported_using": "Postman/7.24.0" +} diff --git a/dev/postman_env_postgres.json b/dev/postman_env_postgres.json new file mode 100644 index 00000000..6093018b --- /dev/null +++ b/dev/postman_env_postgres.json @@ -0,0 +1,49 @@ +{ + "id": "0ff1dcd6-54f3-44a7-9c18-cc3c8e7df357", + "name": "Local Statping", + "values": [ + { + "key": "endpoint", + "value": "http://0.0.0.0:8585", + "enabled": true + }, + { + "key": "api_key", + "value": "demosecret123", + "enabled": true + }, + { + "key": "db_connection", + "value": "postgres", + "enabled": true + }, + { + "key": "db_host", + "value": "localhost", + "enabled": true + }, + { + "key": "db_user", + "value": "root", + "enabled": true + }, + { + "key": "db_password", + "value": "password123", + "enabled": true + }, + { + "key": "db_database", + "value": "statping", + "enabled": true + }, + { + "key": "db_port", + "value": "5432", + "enabled": true + } + ], + "_postman_variable_scope": "environment", + "_postman_exported_at": "2020-05-18T20:44:05.571Z", + "_postman_exported_using": "Postman/7.24.0" +} diff --git a/dev/postman_env_sqlite.json b/dev/postman_env_sqlite.json new file mode 100644 index 00000000..fcde08b5 --- /dev/null +++ b/dev/postman_env_sqlite.json @@ -0,0 +1,49 @@ +{ + "id": "0ff1dcd6-54f3-44a7-9c18-cc3c8e7df357", + "name": "Local Statping", + "values": [ + { + "key": "endpoint", + "value": "http://0.0.0.0:8585", + "enabled": true + }, + { + "key": "api_key", + "value": "demosecret123", + "enabled": true + }, + { + "key": "db_connection", + "value": "sqlite", + "enabled": true + }, + { + "key": "db_host", + "value": "localhost", + "enabled": true + }, + { + "key": "db_user", + "value": "root", + "enabled": true + }, + { + "key": "db_password", + "value": "password123", + "enabled": true + }, + { + "key": "db_database", + "value": "statping", + "enabled": true + }, + { + "key": "db_port", + "value": "3306", + "enabled": true + } + ], + "_postman_variable_scope": "environment", + "_postman_exported_at": "2020-05-18T20:44:05.571Z", + "_postman_exported_using": "Postman/7.24.0" +} diff --git a/dev/postman_environment.json b/dev/postman_environment.json deleted file mode 100644 index ad4333ca..00000000 --- a/dev/postman_environment.json +++ /dev/null @@ -1,21 +0,0 @@ -{ - "id": "0ff1dcd6-54f3-44a7-9c18-cc3c8e7df357", - "name": "Local Statping", - "values": [ - { - "key": "endpoint", - "value": "http://127.0.0.1:8080", - "description": "", - "enabled": true - }, - { - "key": "api_key", - "value": "demosecret123", - "description": "", - "enabled": true - } - ], - "_postman_variable_scope": "environment", - "_postman_exported_at": "2018-11-17T16:55:15.031Z", - "_postman_exported_using": "Postman/6.5.2" -} From 32f0d46f0ad4da6a2a1c9c8dd07f7e26c466d81c Mon Sep 17 00:00:00 2001 From: hunterlong Date: Mon, 18 May 2020 14:45:04 -0700 Subject: [PATCH 09/49] postman API tests for different databases --- .github/workflows/master.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/master.yml b/.github/workflows/master.yml index 6af1b976..f28fb43c 100644 --- a/.github/workflows/master.yml +++ b/.github/workflows/master.yml @@ -182,7 +182,7 @@ jobs: uses: matt-ball/newman-action@master with: postmanApiKey: ${{ secrets.POSTMAN_API }} - collection: 1898229-3c6a7841-0b39-4878-a3a6-1c76832b7679 + collection: ./dev/postman.json environment: ./dev/postman_env_sqlite.json timeoutRequest: 15000 delayRequest: 500 @@ -237,7 +237,7 @@ jobs: uses: matt-ball/newman-action@master with: postmanApiKey: ${{ secrets.POSTMAN_API }} - collection: 1898229-3c6a7841-0b39-4878-a3a6-1c76832b7679 + collection: ./dev/postman.json environment: ./dev/postman_env_mysql.json timeoutRequest: 15000 delayRequest: 500 @@ -293,7 +293,7 @@ jobs: uses: matt-ball/newman-action@master with: postmanApiKey: ${{ secrets.POSTMAN_API }} - collection: 1898229-3c6a7841-0b39-4878-a3a6-1c76832b7679 + collection: ./dev/postman.json environment: ./dev/postman_env_postgres.json timeoutRequest: 15000 delayRequest: 500 From 3edfd7658d3b41ad235da5451f6d9aa2f86961f1 Mon Sep 17 00:00:00 2001 From: hunterlong Date: Mon, 18 May 2020 14:51:48 -0700 Subject: [PATCH 10/49] postman API tests for different databases --- .github/workflows/master.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/master.yml b/.github/workflows/master.yml index f28fb43c..90ca1b94 100644 --- a/.github/workflows/master.yml +++ b/.github/workflows/master.yml @@ -181,7 +181,7 @@ jobs: - name: Postman SQLite Tests uses: matt-ball/newman-action@master with: - postmanApiKey: ${{ secrets.POSTMAN_API }} + apiKey: ${{ secrets.POSTMAN_API }} collection: ./dev/postman.json environment: ./dev/postman_env_sqlite.json timeoutRequest: 15000 @@ -236,7 +236,7 @@ jobs: - name: Postman MySQL Tests uses: matt-ball/newman-action@master with: - postmanApiKey: ${{ secrets.POSTMAN_API }} + apiKey: ${{ secrets.POSTMAN_API }} collection: ./dev/postman.json environment: ./dev/postman_env_mysql.json timeoutRequest: 15000 @@ -292,7 +292,7 @@ jobs: - name: Postman Postgres Tests uses: matt-ball/newman-action@master with: - postmanApiKey: ${{ secrets.POSTMAN_API }} + apiKey: ${{ secrets.POSTMAN_API }} collection: ./dev/postman.json environment: ./dev/postman_env_postgres.json timeoutRequest: 15000 From ce86b931c25f28ab0a8f57958c15b42854d1bfe2 Mon Sep 17 00:00:00 2001 From: hunterlong Date: Mon, 18 May 2020 14:59:58 -0700 Subject: [PATCH 11/49] postman API tests, mobile design update for dropdown --- .github/workflows/master.yml | 6 +++--- frontend/src/assets/scss/mobile.scss | 7 +++++++ 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/.github/workflows/master.yml b/.github/workflows/master.yml index 90ca1b94..1e85a347 100644 --- a/.github/workflows/master.yml +++ b/.github/workflows/master.yml @@ -175,7 +175,7 @@ jobs: - name: Run Statping run: | - API_SECRET=demosecret123 statping --port=8080 > /dev/null & + API_SECRET=demosecret123 statping --port=8585 > /dev/null & sleep 3 - name: Postman SQLite Tests @@ -230,7 +230,7 @@ jobs: - name: Run Statping run: | - API_SECRET=demosecret123 statping --port=8080 > /dev/null & + API_SECRET=demosecret123 statping --port=8585 > /dev/null & sleep 3 - name: Postman MySQL Tests @@ -286,7 +286,7 @@ jobs: - name: Run Statping run: | - API_SECRET=demosecret123 statping --port=8080 > /dev/null & + API_SECRET=demosecret123 statping --port=8585 > /dev/null & sleep 3 - name: Postman Postgres Tests diff --git a/frontend/src/assets/scss/mobile.scss b/frontend/src/assets/scss/mobile.scss index ca50c0be..8ad729d0 100644 --- a/frontend/src/assets/scss/mobile.scss +++ b/frontend/src/assets/scss/mobile.scss @@ -6,6 +6,13 @@ background-color: $sm-background-color; } + .service-tm-menu { + height: 300px; + } + + .service-tm-menu A { + height: 27px; + } .index-chart { height: 380px; From 6de67a1906987864a5dc591ba10ca688fdd4d0be Mon Sep 17 00:00:00 2001 From: hunterlong Date: Mon, 18 May 2020 20:46:54 -0700 Subject: [PATCH 12/49] bulk SQL records insert fix --- database/database.go | 5 +++++ go.mod | 3 ++- go.sum | 16 ++++++++++++++++ types/failures/samples.go | 10 ++++------ types/hits/samples.go | 16 +++++++--------- 5 files changed, 34 insertions(+), 16 deletions(-) diff --git a/database/database.go b/database/database.go index 479aa9ce..69c29989 100644 --- a/database/database.go +++ b/database/database.go @@ -104,6 +104,11 @@ type Database interface { FormatTime(t time.Time) string ParseTime(t string) (time.Time, error) DbType() string + GormDB() *gorm.DB +} + +func (it *Db) GormDB() *gorm.DB { + return it.Database } func (it *Db) DbType() string { diff --git a/go.mod b/go.mod index d256b14e..fcc3797b 100644 --- a/go.mod +++ b/go.mod @@ -37,8 +37,9 @@ require ( github.com/spf13/pflag v1.0.5 // indirect github.com/spf13/viper v1.6.3 github.com/stretchr/testify v1.5.1 + github.com/t-tiger/gorm-bulk-insert/v2 v2.0.1 github.com/tatsushid/go-fastping v0.0.0-20160109021039-d7bb493dee3e - golang.org/x/crypto v0.0.0-20200320181102-891825fb96df + golang.org/x/crypto v0.0.0-20200406173513-056763e48d71 golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be golang.org/x/sys v0.0.0-20200413165638-669c56c373c4 // indirect golang.org/x/text v0.3.2 // indirect diff --git a/go.sum b/go.sum index 271df335..315b77f5 100755 --- a/go.sum +++ b/go.sum @@ -5,6 +5,7 @@ github.com/BurntSushi/toml v0.3.1 h1:WXkYYl6Yr3qBf1K79EBnL4mak0OimBfB0XUf9Vl28OQ github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= github.com/CloudyKit/fastprinter v0.0.0-20170127035650-74b38d55f37a/go.mod h1:EFZQ978U7x8IRnstaskI3IysnWY5Ao3QgZUKOXlsAdw= github.com/CloudyKit/jet v2.1.3-0.20180809161101-62edd43e4f88+incompatible/go.mod h1:HPYO+50pSWkPoj9Q/eq0aRGByCL6ScRlUmiEX5Zgm+w= +github.com/DATA-DOG/go-sqlmock v1.4.1/go.mod h1:f/Ixk793poVmq4qj/V1dPUg2JEAKC73Q5eFN3EC/SaM= github.com/GeertJohan/go.incremental v1.0.0 h1:7AH+pY1XUgQE4Y1HcXYaMqAI0m9yrFqo/jt0CW30vsg= github.com/GeertJohan/go.incremental v1.0.0/go.mod h1:6fAjUhbVuX1KcMD3c8TEgVUqmo4seqhv0i0kdATSkM0= github.com/GeertJohan/go.rice v1.0.0 h1:KkI6O9uMaQU3VEKaj01ulavtF7o1fWT7+pk/4voiMLQ= @@ -43,6 +44,7 @@ github.com/coreos/go-systemd v0.0.0-20190321100706-95778dfbb74e/go.mod h1:F5haX7 github.com/coreos/pkg v0.0.0-20180928190104-399ea9e2e55f/go.mod h1:E3G3o1h8I7cfcXa63jLwjI0eiQQMgzzUDFVpN/nH/eA= github.com/cpuguy83/go-md2man v1.0.10/go.mod h1:SmD6nW6nTyfqj6ABTjUi3V3JVMnlJmwcJI5acqYI6dE= github.com/cpuguy83/go-md2man/v2 v2.0.0/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU= +github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= github.com/daaku/go.zipexe v1.0.0 h1:VSOgZtH418pH9L16hC/JrgSNJbbAL26pj7lmD1+CGdY= github.com/daaku/go.zipexe v1.0.0/go.mod h1:z8IiR6TsVLEYKwXAoE/I+8ys/sDkgTzSL0CLnGVd57E= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= @@ -50,6 +52,7 @@ github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/denisenkom/go-mssqldb v0.0.0-20191124224453-732737034ffd h1:83Wprp6ROGeiHFAP8WJdI2RoxALQYgdllERc3N5N2DM= github.com/denisenkom/go-mssqldb v0.0.0-20191124224453-732737034ffd/go.mod h1:xbL0rPBG9cCiLr28tMa8zpbdarY27NDyej4t/EjAShU= +github.com/denisenkom/go-mssqldb v0.0.0-20200206145737-bbfc9a55622e/go.mod h1:xbL0rPBG9cCiLr28tMa8zpbdarY27NDyej4t/EjAShU= github.com/dgraph-io/badger v1.6.0/go.mod h1:zwt7syl517jmP8s94KqSxTlM6IMsdhYy6psNgSztDR4= github.com/dgrijalva/jwt-go v3.2.0+incompatible h1:7qlOGliEKZXTDg6OTjfoBKDXWrumCAMpl/TFQ4/5kLM= github.com/dgrijalva/jwt-go v3.2.0+incompatible/go.mod h1:E3ru+11k8xSBh+hMPgOLZmtrrCbhqsmaPHjLKYnJCaQ= @@ -90,6 +93,8 @@ github.com/go-mail/mail v2.3.1+incompatible/go.mod h1:VPWjmmNyRsWXQZHVHT3g0YbIIN github.com/go-martini/martini v0.0.0-20170121215854-22fa46961aab/go.mod h1:/P9AEU963A2AYjv4d1V5eVL1CQbEJq6aCNHDDjibzu8= github.com/go-sql-driver/mysql v1.4.1 h1:g24URVg0OFbNUTx9qqY1IRZ9D9z3iPyi5zKhQZpNwpA= github.com/go-sql-driver/mysql v1.4.1/go.mod h1:zAC/RDZ24gD3HViQzih4MyKcchzm+sOG5ZlKdlhCg5w= +github.com/go-sql-driver/mysql v1.5.0 h1:ozyZYNQW3x3HtqT1jira07DN2PArx2v7/mN66gGcHOs= +github.com/go-sql-driver/mysql v1.5.0/go.mod h1:DCzpHaOWr8IXmIStZouvnhqoel9Qv2LBy8hT2VhHyBg= github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY= github.com/gobwas/httphead v0.0.0-20180130184737-2c6c146eadee/go.mod h1:L0fX3K22YWvt/FAX9NnzrNzcI4wNYi9Yku4O0LKYflo= github.com/gobwas/pool v0.2.0/go.mod h1:q8bcK0KcYlCgd9e7WYLm9LpyS+YeLd8JVDW6WezmKEw= @@ -151,6 +156,7 @@ github.com/jinzhu/inflection v1.0.0 h1:K317FqzuhWc8YvSVlFMCCUb36O/S9MCKRDI7QkRKD github.com/jinzhu/inflection v1.0.0/go.mod h1:h+uFLlag+Qp1Va5pdKtLDYj+kHp5pxUVkryuEj+Srlc= github.com/jinzhu/now v1.0.1 h1:HjfetcXq097iXP0uoPCdnM4Efp5/9MsM0/M+XOTeR3M= github.com/jinzhu/now v1.0.1/go.mod h1:d3SSVoowX0Lcu0IBviAWJpolVfI5UJVZZ7cO71lE/z8= +github.com/jinzhu/now v1.1.1/go.mod h1:d3SSVoowX0Lcu0IBviAWJpolVfI5UJVZZ7cO71lE/z8= github.com/joho/godotenv v1.3.0 h1:Zjp+RcGpHhGlrMbJzXTrZZPrWj+1vfm90La1wgB6Bhc= github.com/joho/godotenv v1.3.0/go.mod h1:7hK45KPybAkOC6peb+G5yklZfMxEjkZhHbwpqxOKXbg= github.com/jonboulle/clockwork v0.1.0/go.mod h1:Ii8DK3G1RaLaWxj9trq07+26W01tbo22gdxWY5EU2bo= @@ -183,10 +189,13 @@ github.com/kr/logfmt v0.0.0-20140226030751-b84e30acd515/go.mod h1:+0opPa2QZZtGFB github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= +github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= github.com/labstack/echo/v4 v4.1.11/go.mod h1:i541M3Fj6f76NZtHSj7TXnyM8n2gaodfvfxNnFqi74g= github.com/labstack/gommon v0.3.0/go.mod h1:MULnywXg0yavhxWKc+lOruYdAhDwPK9wf0OL7NoOu+k= github.com/lib/pq v1.1.1 h1:sJZmqHoEaY7f+NPP8pgLB/WxulyR3fewgCM2qaSlBb4= github.com/lib/pq v1.1.1/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo= +github.com/lib/pq v1.3.0 h1:/qkRGz8zljWiDcFvgpwUpwIAPu3r07TDvs3Rws+o/pU= +github.com/lib/pq v1.3.0/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo= github.com/magiconair/properties v1.8.0/go.mod h1:PppfXfuXeibc/6YijjN8zIbojt8czPbwD3XqdrwzmxQ= github.com/magiconair/properties v1.8.1 h1:ZC2Vc7/ZFkGmsVC9KvOjumD+G5lXy2RtTKyzRKO2BQ4= github.com/magiconair/properties v1.8.1/go.mod h1:PppfXfuXeibc/6YijjN8zIbojt8czPbwD3XqdrwzmxQ= @@ -221,6 +230,7 @@ github.com/mwitkow/go-conntrack v0.0.0-20161129095857-cc309e4a2223/go.mod h1:qRW github.com/nats-io/nats.go v1.8.1/go.mod h1:BrFz9vVn0fU3AcH9Vn4Kd7W0NpJ651tD5omQ3M8LwxM= github.com/nats-io/nkeys v0.0.2/go.mod h1:dab7URMsZm6Z/jp9Z5UGa87Uutgc2mVpXLC4B7TDb/4= github.com/nats-io/nuid v1.0.1/go.mod h1:19wcPz3Ph3q0Jbyiqsd0kePYG7A95tJPxeL+1OSON2c= +github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e/go.mod h1:zD1mROLANZcx1PVRCS0qkT7pwLkGfwJo4zjcN/Tysno= github.com/nkovacs/streamquote v0.0.0-20170412213628-49af9bddb229 h1:E2B8qYyeSgv5MXpmzZXRNp8IAQ4vjxIjhpAf5hv/tAg= github.com/nkovacs/streamquote v0.0.0-20170412213628-49af9bddb229/go.mod h1:0aYXnNPJ8l7uZxf45rWW1a/uME32OF0rhiYGNQ2oF2E= github.com/oklog/ulid v1.3.1/go.mod h1:CirwcVhetQ6Lv90oh/F+FBtV6XMibvdAFo93nm5qn4U= @@ -308,6 +318,9 @@ github.com/stretchr/testify v1.5.1 h1:nOGnQDM7FYENwehXlg/kFVnos3rEvtKTjRvOWSzb6H github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA= github.com/subosito/gotenv v1.2.0 h1:Slr1R9HxAlEKefgq5jn9U+DnETlIUa6HfgEzj0g5d7s= github.com/subosito/gotenv v1.2.0/go.mod h1:N0PQaV/YGNqwC0u51sEeR/aUtSLEXKX9iv69rRypqCw= +github.com/t-tiger/gorm-bulk-insert v1.3.0 h1:9k7BaVEhw/3fsvh6GTOBwJ2RXk3asc5xs5m6hwozq20= +github.com/t-tiger/gorm-bulk-insert/v2 v2.0.1 h1:HGVkRrwDCbmSP6h1CoBDj6l/mhnvsP5JbYaQ4ss0R6o= +github.com/t-tiger/gorm-bulk-insert/v2 v2.0.1/go.mod h1:I3xbaE9ud9/TEXzehwkHx86SyJwqeSNsX2X5oV61jIg= github.com/tatsushid/go-fastping v0.0.0-20160109021039-d7bb493dee3e h1:nt2877sKfojlHCTOBXbpWjBkuWKritFaGIfgQwbQUls= github.com/tatsushid/go-fastping v0.0.0-20160109021039-d7bb493dee3e/go.mod h1:B4+Kq1u5FlULTjFSM707Q6e/cOHFv0z/6QRoxubDIQ8= github.com/tmc/grpc-websocket-proxy v0.0.0-20190109142713-0ad062ec5ee5/go.mod h1:ncp9v5uamzpCO7NfCPTXjqaC+bZgJeR0sMTm6dMHP7U= @@ -345,6 +358,8 @@ golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8U golang.org/x/crypto v0.0.0-20191205180655-e7c4368fe9dd/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20200320181102-891825fb96df h1:lDWgvUvNnaTnNBc/dwOty86cFeKoKWbwy2wQj0gIxbU= golang.org/x/crypto v0.0.0-20200320181102-891825fb96df/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= +golang.org/x/crypto v0.0.0-20200406173513-056763e48d71 h1:DOmugCavvUtnUD114C1Wh+UgTgQZ4pMLzXxi1pSt+/Y= +golang.org/x/crypto v0.0.0-20200406173513-056763e48d71/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU= @@ -431,6 +446,7 @@ gopkg.in/alexcesaro/quotedprintable.v3 v3.0.0-20150716171945-2caba252f4dc/go.mod gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys= gopkg.in/go-playground/assert.v1 v1.2.1/go.mod h1:9RXL0bg/zibRAgZUYszZSwO/z8Y/a8bDuhia5mkpMnE= gopkg.in/go-playground/validator.v8 v8.18.2/go.mod h1:RX2a/7Ha8BgOhfk7j780h4/u/RRjR0eouCJSH80/M2Y= diff --git a/types/failures/samples.go b/types/failures/samples.go index 06e53297..069fb842 100644 --- a/types/failures/samples.go +++ b/types/failures/samples.go @@ -4,6 +4,7 @@ import ( "fmt" "github.com/statping/statping/types" "github.com/statping/statping/utils" + gormbulk "github.com/t-tiger/gorm-bulk-insert/v2" "time" ) @@ -15,8 +16,6 @@ func Samples() error { createdAt := utils.Now().Add(-3 * types.Day) for i := int64(1); i <= 4; i++ { - tx := db.Begin() - f1 := &Failure{ Service: i, Issue: "Server failure", @@ -33,21 +32,20 @@ func Samples() error { log.Infoln(fmt.Sprintf("Adding %v Failure records to service", 400)) + var records []interface{} for fi := 0.; fi <= float64(400); fi++ { failure := &Failure{ Service: i, Issue: "testing right here", CreatedAt: createdAt.UTC(), } - - tx = tx.Create(&failure) + records = append(records, failure) createdAt = createdAt.Add(35 * time.Minute) } - if err := tx.Commit().Error(); err != nil { + if err := gormbulk.BulkInsert(db.GormDB(), records, 3000); err != nil { log.Error(err) return err } } - return nil } diff --git a/types/hits/samples.go b/types/hits/samples.go index d0b283b9..a85cf19d 100644 --- a/types/hits/samples.go +++ b/types/hits/samples.go @@ -5,9 +5,9 @@ import ( _ "github.com/jinzhu/gorm/dialects/mysql" _ "github.com/jinzhu/gorm/dialects/postgres" _ "github.com/mattn/go-sqlite3" - "github.com/statping/statping/database" "github.com/statping/statping/types" "github.com/statping/statping/utils" + gormbulk "github.com/t-tiger/gorm-bulk-insert/v2" "time" ) @@ -15,24 +15,22 @@ var SampleHits = 99900. func Samples() error { for i := int64(1); i <= 5; i++ { - tx := db.Begin() - tx = createHitsAt(tx, i) - - if err := tx.Commit().Error(); err != nil { + records := createHitsAt(i) + if err := gormbulk.BulkInsert(db.GormDB(), records, 3000); err != nil { log.Error(err) return err } } - return nil } -func createHitsAt(db database.Database, serviceID int64) database.Database { +func createHitsAt(serviceID int64) []interface{} { log.Infoln(fmt.Sprintf("Adding Sample records to service #%d...", serviceID)) createdAt := utils.Now().Add(-3 * types.Day) p := utils.NewPerlin(2, 2, 5, utils.Now().UnixNano()) + var records []interface{} for hi := 0.; hi <= SampleHits; hi++ { latency := p.Noise1D(hi / 500) @@ -43,7 +41,7 @@ func createHitsAt(db database.Database, serviceID int64) database.Database { CreatedAt: createdAt, } - db = db.Create(&hit) + records = append(records, hit) if createdAt.After(utils.Now()) { break @@ -51,5 +49,5 @@ func createHitsAt(db database.Database, serviceID int64) database.Database { createdAt = createdAt.Add(30 * time.Second) } - return db + return records } From bcd38ec668fcfd0f11777d65f135dfcf1ac351ee Mon Sep 17 00:00:00 2001 From: hunterlong Date: Mon, 18 May 2020 21:17:38 -0700 Subject: [PATCH 13/49] bulk SQL records insert fix, chunk size per db type --- database/database.go | 12 ++++++++++++ types/failures/samples.go | 2 +- types/hits/samples.go | 2 +- 3 files changed, 14 insertions(+), 2 deletions(-) diff --git a/database/database.go b/database/database.go index 69c29989..1ed39905 100644 --- a/database/database.go +++ b/database/database.go @@ -105,6 +105,18 @@ type Database interface { ParseTime(t string) (time.Time, error) DbType() string GormDB() *gorm.DB + ChunkSize() int +} + +func (it *Db) ChunkSize() int { + switch it.Database.Dialect().GetName() { + case "mysql": + return 3000 + case "postgres": + return 3000 + default: + return 100 + } } func (it *Db) GormDB() *gorm.DB { diff --git a/types/failures/samples.go b/types/failures/samples.go index 069fb842..1fb333b9 100644 --- a/types/failures/samples.go +++ b/types/failures/samples.go @@ -42,7 +42,7 @@ func Samples() error { records = append(records, failure) createdAt = createdAt.Add(35 * time.Minute) } - if err := gormbulk.BulkInsert(db.GormDB(), records, 3000); err != nil { + if err := gormbulk.BulkInsert(db.GormDB(), records, db.ChunkSize()); err != nil { log.Error(err) return err } diff --git a/types/hits/samples.go b/types/hits/samples.go index a85cf19d..d432886d 100644 --- a/types/hits/samples.go +++ b/types/hits/samples.go @@ -16,7 +16,7 @@ var SampleHits = 99900. func Samples() error { for i := int64(1); i <= 5; i++ { records := createHitsAt(i) - if err := gormbulk.BulkInsert(db.GormDB(), records, 3000); err != nil { + if err := gormbulk.BulkInsert(db.GormDB(), records, db.ChunkSize()); err != nil { log.Error(err) return err } From 86204d27bdc40bd0c80bcebf3d88e81f6c6af483 Mon Sep 17 00:00:00 2001 From: hunterlong Date: Mon, 18 May 2020 22:19:59 -0700 Subject: [PATCH 14/49] test fix for postman sqlite, postgres, and sqlite. --- dev/docker-compose.db.yml | 4 ++-- dev/postman.json | 19 ++++++------------- 2 files changed, 8 insertions(+), 15 deletions(-) diff --git a/dev/docker-compose.db.yml b/dev/docker-compose.db.yml index c76a1254..434f8e8f 100644 --- a/dev/docker-compose.db.yml +++ b/dev/docker-compose.db.yml @@ -10,7 +10,7 @@ services: POSTGRES_DB: statping POSTGRES_USER: root ports: - - "127.0.0.1:5432:5432" + - 5432:5432 healthcheck: test: ["CMD-SHELL", "pg_isready -U root"] interval: 15s @@ -27,7 +27,7 @@ services: MYSQL_USER: root MYSQL_PASSWORD: password123 ports: - - "127.0.0.1:3306:3306" + - 3306:3306 healthcheck: test: [ "CMD", "mysqladmin" ,"ping", "-h", "localhost" ] timeout: 20s diff --git a/dev/postman.json b/dev/postman.json index 453c9b8d..069ddea5 100644 --- a/dev/postman.json +++ b/dev/postman.json @@ -17,17 +17,17 @@ "script": { "id": "29b5dc8d-60c1-4f70-853d-49114af6b254", "exec": [ - "var tm = Math.round(new Date().getTime()/1000);", - "pm.globals.set(\"start_time\", tm-259200);", + "var tm = Math.round(new Date().getTime() / 1000);", + "pm.globals.set(\"start_time\", tm - 259200);", "pm.globals.set(\"end_time\", tm);", "", "pm.test(\"Response is ok\", function () {", " pm.response.to.have.status(200);", "});", "", - "pm.test(\"Check Core API Route\", function () {", + "pm.test(\"Check Setup\", function () {", " var jsonData = pm.response.json();", - " pm.expect(jsonData.config.connection).to.eql(\"sqlite3\");", + " pm.expect(jsonData.message).to.eql(\"success\");", "});" ], "type": "text/javascript" @@ -46,14 +46,7 @@ ], "request": { "auth": { - "type": "bearer", - "bearer": [ - { - "key": "token", - "value": "{{api_key}}", - "type": "string" - } - ] + "type": "noauth" }, "method": "POST", "header": [ @@ -69,7 +62,7 @@ "urlencoded": [ { "key": "db_host", - "value": "localhost", + "value": "{{db_host}}", "type": "text" }, { From 0116560831d10db91d46902483ab12c33fd5dc62 Mon Sep 17 00:00:00 2001 From: hunterlong Date: Mon, 18 May 2020 22:38:43 -0700 Subject: [PATCH 15/49] version up --- CHANGELOG.md | 5 +++++ version.txt | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d9e4476c..e2e51326 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,8 @@ +# 0.90.40 (05-18-2020) +- Fixed issues with MySQL and Postgres taking forever to insert sample data (now run in bulk) +- Removed API Authentication for /api/logout route +- Modified Core Sample/Upstart row to include NAME, DESCRIPTION, and DOMAIN environment vars (also added default values) + # 0.90.39 (05-15-2020) - Modified some SCSS designs for services failures in group - Fixed Twilio notifier and tests diff --git a/version.txt b/version.txt index aeb36050..1d535ecf 100644 --- a/version.txt +++ b/version.txt @@ -1 +1 @@ -0.90.39 +0.90.40 From 47e80397618d1eb89368ec9f15c7cb07b7e3ffea Mon Sep 17 00:00:00 2001 From: hunterlong Date: Mon, 18 May 2020 22:55:58 -0700 Subject: [PATCH 16/49] version up --- dev/postman.json | 2 ++ 1 file changed, 2 insertions(+) diff --git a/dev/postman.json b/dev/postman.json index 069ddea5..eb07a2ad 100644 --- a/dev/postman.json +++ b/dev/postman.json @@ -21,6 +21,8 @@ "pm.globals.set(\"start_time\", tm - 259200);", "pm.globals.set(\"end_time\", tm);", "", + "var connection = pm.environment.get(\"db_connection\");", + "", "pm.test(\"Response is ok\", function () {", " pm.response.to.have.status(200);", "});", From 4618d56c18204e25c092d4c0c23bcaef0895cc61 Mon Sep 17 00:00:00 2001 From: hunterlong Date: Tue, 19 May 2020 23:41:50 -0700 Subject: [PATCH 17/49] mTLS service check (http) --- Makefile | 8 ++++++ cmd/cli.go | 2 +- frontend/src/forms/Service.vue | 47 ++++++++++++++++++++++++++++++++-- handlers/oauth.go | 2 +- notifiers/discord.go | 4 +-- notifiers/line_notify.go | 2 +- notifiers/mobile.go | 2 +- notifiers/pushover.go | 2 +- notifiers/slack.go | 4 +-- notifiers/telegram.go | 2 +- notifiers/twilio.go | 2 +- types/services/methods.go | 42 +++++++++++++++++++++++++++++- types/services/routine.go | 8 ++++-- types/services/struct.go | 3 +++ utils/file.go | 10 ++++++++ utils/utils.go | 6 ++++- 16 files changed, 129 insertions(+), 17 deletions(-) diff --git a/Makefile b/Makefile index 30b9ac1f..d9f3c8be 100644 --- a/Makefile +++ b/Makefile @@ -322,5 +322,13 @@ postman: clean compile newman run -e dev/postman_environment.json dev/postman.json killall statping +certs: + openssl req -newkey rsa:2048 \ + -new -nodes -x509 \ + -days 3650 \ + -out cert.pem \ + -keyout key.pem \ + -subj "/C=US/ST=California/L=Santa Monica/O=Statping/OU=Development/CN=localhost" + .PHONY: all build build-all build-alpine test-all test test-api docker frontend up down print_details lite sentry-release snapcraft build-linux build-mac build-win build-all postman .SILENT: travis_s3_creds diff --git a/cmd/cli.go b/cmd/cli.go index ffbed998..083b55dd 100644 --- a/cmd/cli.go +++ b/cmd/cli.go @@ -285,7 +285,7 @@ func runOnce() error { func checkGithubUpdates() (githubResponse, error) { url := "https://api.github.com/repos/statping/statping/releases/latest" - contents, _, err := utils.HttpRequest(url, "GET", nil, nil, nil, time.Duration(2*time.Second), true) + contents, _, err := utils.HttpRequest(url, "GET", nil, nil, nil, time.Duration(2*time.Second), true, nil) if err != nil { return githubResponse{}, err } diff --git a/frontend/src/forms/Service.vue b/frontend/src/forms/Service.vue index 1dfb926c..146bc5fa 100644 --- a/frontend/src/forms/Service.vue +++ b/frontend/src/forms/Service.vue @@ -156,6 +156,41 @@ +
+ +
+ + + + + +
+
+ +
+ +
+ + Absolute path to TLS Client Certificate file or in PEM format +
+
+ +
+ +
+ + Absolute path to TLS Client Key file or in PEM format +
+
+ +
+ +
+ + Absolute path to Root CA file or in PEM format (optional) +
+
+ @@ -235,6 +270,10 @@ notify_all_changes: true, notify_after: 2, public: true, + use_tls: false, + tls_cert: "", + tls_cert_key: "", + tls_cert_root: "", }, groups: [], } @@ -247,12 +286,15 @@ watch: { in_service () { this.service = this.in_service + if (this.service.tls_cert) { + this.service.use_tls = true + } } }, async mounted () { if (!this.$store.getters.groups) { - const groups = await Api.groups() - this.$store.commit('setGroups', groups) + const groups = await Api.groups() + this.$store.commit('setGroups', groups) } }, methods: { @@ -289,6 +331,7 @@ delete s.last_success delete s.latency delete s.online_24_hours + delete s.use_tls s.check_interval = parseInt(s.check_interval) s.timeout = parseInt(s.timeout) s.port = parseInt(s.port) diff --git a/handlers/oauth.go b/handlers/oauth.go index 09ceb8d0..ce9158bf 100644 --- a/handlers/oauth.go +++ b/handlers/oauth.go @@ -143,7 +143,7 @@ func slackOAuth(r *http.Request) (*oAuth, error) { // slackIdentity will query the Slack API to fetch the users ID, username, and email address. func (a *oAuth) slackIdentity() (*oAuth, error) { url := fmt.Sprintf("https://slack.com/api/users.identity?token=%s", a.Token) - out, resp, err := utils.HttpRequest(url, "GET", "application/x-www-form-urlencoded", nil, nil, 10*time.Second, true) + out, resp, err := utils.HttpRequest(url, "GET", "application/x-www-form-urlencoded", nil, nil, 10*time.Second, true, nil) if err != nil { return a, err } diff --git a/notifiers/discord.go b/notifiers/discord.go index 988c7734..4d9ca75a 100644 --- a/notifiers/discord.go +++ b/notifiers/discord.go @@ -39,7 +39,7 @@ var Discorder = &discord{¬ifications.Notification{ // Send will send a HTTP Post to the discord API. It accepts type: []byte func (d *discord) sendRequest(msg string) error { - _, _, err := utils.HttpRequest(Discorder.GetValue("host"), "POST", "application/json", nil, strings.NewReader(msg), time.Duration(10*time.Second), true) + _, _, err := utils.HttpRequest(Discorder.GetValue("host"), "POST", "application/json", nil, strings.NewReader(msg), time.Duration(10*time.Second), true, nil) return err } @@ -63,7 +63,7 @@ func (d *discord) OnSuccess(s *services.Service) error { func (d *discord) OnTest() (string, error) { outError := errors.New("Incorrect discord URL, please confirm URL is correct") message := `{"content": "Testing the discord notifier"}` - contents, _, err := utils.HttpRequest(Discorder.Host, "POST", "application/json", nil, bytes.NewBuffer([]byte(message)), time.Duration(10*time.Second), true) + contents, _, err := utils.HttpRequest(Discorder.Host, "POST", "application/json", nil, bytes.NewBuffer([]byte(message)), time.Duration(10*time.Second), true, nil) if string(contents) == "" { return "", nil } diff --git a/notifiers/line_notify.go b/notifiers/line_notify.go index f6955d92..549449b9 100644 --- a/notifiers/line_notify.go +++ b/notifiers/line_notify.go @@ -47,7 +47,7 @@ func (l *lineNotifier) sendMessage(message string) (string, error) { v := url.Values{} v.Set("message", message) headers := []string{fmt.Sprintf("Authorization=Bearer %v", l.ApiSecret)} - content, _, err := utils.HttpRequest("https://notify-api.line.me/api/notify", "POST", "application/x-www-form-urlencoded", headers, strings.NewReader(v.Encode()), time.Duration(10*time.Second), true) + content, _, err := utils.HttpRequest("https://notify-api.line.me/api/notify", "POST", "application/x-www-form-urlencoded", headers, strings.NewReader(v.Encode()), time.Duration(10*time.Second), true, nil) return string(content), err } diff --git a/notifiers/mobile.go b/notifiers/mobile.go index edaadb9d..8ade1a8e 100644 --- a/notifiers/mobile.go +++ b/notifiers/mobile.go @@ -142,7 +142,7 @@ func pushRequest(msg *pushArray) ([]byte, error) { return nil, err } url := "https://push.statping.com/api/push" - body, _, err = utils.HttpRequest(url, "POST", "application/json", nil, bytes.NewBuffer(body), time.Duration(20*time.Second), true) + body, _, err = utils.HttpRequest(url, "POST", "application/json", nil, bytes.NewBuffer(body), time.Duration(20*time.Second), true, nil) return body, err } diff --git a/notifiers/pushover.go b/notifiers/pushover.go index ae85eb13..6e93b8e1 100644 --- a/notifiers/pushover.go +++ b/notifiers/pushover.go @@ -59,7 +59,7 @@ func (t *pushover) sendMessage(message string) (string, error) { v.Set("message", message) rb := strings.NewReader(v.Encode()) - content, _, err := utils.HttpRequest(pushoverUrl, "POST", "application/x-www-form-urlencoded", nil, rb, time.Duration(10*time.Second), true) + content, _, err := utils.HttpRequest(pushoverUrl, "POST", "application/x-www-form-urlencoded", nil, rb, time.Duration(10*time.Second), true, nil) if err != nil { return "", err } diff --git a/notifiers/slack.go b/notifiers/slack.go index 2eb776cb..8687b481 100644 --- a/notifiers/slack.go +++ b/notifiers/slack.go @@ -50,7 +50,7 @@ var slacker = &slack{¬ifications.Notification{ // Send will send a HTTP Post to the slack webhooker API. It accepts type: string func (s *slack) sendSlack(msg string) error { - _, resp, err := utils.HttpRequest(s.Host, "POST", "application/json", nil, strings.NewReader(msg), time.Duration(10*time.Second), true) + _, resp, err := utils.HttpRequest(s.Host, "POST", "application/json", nil, strings.NewReader(msg), time.Duration(10*time.Second), true, nil) if err != nil { return err } @@ -60,7 +60,7 @@ func (s *slack) sendSlack(msg string) error { func (s *slack) OnTest() (string, error) { testMsg := ReplaceVars(failingTemplate, exampleService, exampleFailure) - contents, resp, err := utils.HttpRequest(s.Host, "POST", "application/json", nil, bytes.NewBuffer([]byte(testMsg)), time.Duration(10*time.Second), true) + contents, resp, err := utils.HttpRequest(s.Host, "POST", "application/json", nil, bytes.NewBuffer([]byte(testMsg)), time.Duration(10*time.Second), true, nil) if err != nil { return "", err } diff --git a/notifiers/telegram.go b/notifiers/telegram.go index 0be97e96..214150e3 100644 --- a/notifiers/telegram.go +++ b/notifiers/telegram.go @@ -59,7 +59,7 @@ func (t *telegram) sendMessage(message string) (string, error) { v.Set("text", message) rb := *strings.NewReader(v.Encode()) - contents, _, err := utils.HttpRequest(apiEndpoint, "GET", "application/x-www-form-urlencoded", nil, &rb, time.Duration(10*time.Second), true) + contents, _, err := utils.HttpRequest(apiEndpoint, "GET", "application/x-www-form-urlencoded", nil, &rb, time.Duration(10*time.Second), true, nil) success, _ := telegramSuccess(contents) if !success { diff --git a/notifiers/twilio.go b/notifiers/twilio.go index e3ec3aaf..ef7bec7e 100644 --- a/notifiers/twilio.go +++ b/notifiers/twilio.go @@ -72,7 +72,7 @@ func (t *twilio) sendMessage(message string) (string, error) { authHeader := utils.Base64(fmt.Sprintf("%s:%s", t.ApiKey, t.ApiSecret)) - contents, _, err := utils.HttpRequest(twilioUrl, "POST", "application/x-www-form-urlencoded", []string{"Authorization=Basic " + authHeader}, rb, 10*time.Second, true) + contents, _, err := utils.HttpRequest(twilioUrl, "POST", "application/x-www-form-urlencoded", []string{"Authorization=Basic " + authHeader}, rb, 10*time.Second, true, nil) success, _ := twilioSuccess(contents) if !success { errorOut := twilioError(contents) diff --git a/types/services/methods.go b/types/services/methods.go index a2e5e84a..471f58f9 100644 --- a/types/services/methods.go +++ b/types/services/methods.go @@ -2,13 +2,16 @@ package services import ( "crypto/sha1" + "crypto/tls" + "crypto/x509" "encoding/hex" - "errors" "fmt" "github.com/statping/statping/types" + "github.com/statping/statping/types/errors" "github.com/statping/statping/types/failures" "github.com/statping/statping/types/hits" "github.com/statping/statping/utils" + "io/ioutil" "sort" "strconv" "time" @@ -16,6 +19,43 @@ import ( const limitedFailures = 25 +func (s *Service) LoadTLSCert() (*tls.Config, error) { + if !s.TLSCert.Valid && !s.TLSCertKey.Valid { + return nil, nil + } + + // load TLS cert and key from file path or PEM format + var cert tls.Certificate + var err error + tlsCertExtension := utils.FileExtension(s.TLSCert.String) + tlsCertKeyExtension := utils.FileExtension(s.TLSCertKey.String) + if tlsCertExtension == "" && tlsCertKeyExtension == "" { + cert, err = tls.X509KeyPair([]byte(s.TLSCert.String), []byte(s.TLSCertKey.String)) + } else { + cert, err = tls.LoadX509KeyPair(s.TLSCert.String, s.TLSCertKey.String) + } + if err != nil { + return nil, errors.Wrap(err, "issue loading X509KeyPair") + } + + // create Root CA pool or use Root CA provided + chainFile := s.TLSCert.String + if s.TLSCertRoot.String != "" { + chainFile = s.TLSCertRoot.String + } + caCert, err := ioutil.ReadFile(chainFile) + if err != nil { + return nil, errors.Wrap(err, "issue reading cert file: "+chainFile) + } + caCertPool := x509.NewCertPool() + caCertPool.AppendCertsFromPEM(caCert) + + return &tls.Config{ + RootCAs: caCertPool, + Certificates: []tls.Certificate{cert}, + }, nil +} + func (s *Service) Duration() time.Duration { return time.Duration(s.Interval) * time.Second } diff --git a/types/services/routine.go b/types/services/routine.go index c7956e76..a6230691 100644 --- a/types/services/routine.go +++ b/types/services/routine.go @@ -258,8 +258,12 @@ func CheckHttp(s *Service, record bool) *Service { contentType = "application/json" } - content, res, err = utils.HttpRequest(s.Domain, s.Method, contentType, - headers, data, timeout, s.VerifySSL.Bool) + customTLS, err := s.LoadTLSCert() + if err != nil { + log.Errorln(err) + } + + content, res, err = utils.HttpRequest(s.Domain, s.Method, contentType, headers, data, timeout, s.VerifySSL.Bool, customTLS) if err != nil { if record { recordFailure(s, fmt.Sprintf("HTTP Error %v", err)) diff --git a/types/services/struct.go b/types/services/struct.go index bdd17086..88406f21 100644 --- a/types/services/struct.go +++ b/types/services/struct.go @@ -37,6 +37,9 @@ type Service struct { VerifySSL null.NullBool `gorm:"default:false;column:verify_ssl" json:"verify_ssl" scope:"user,admin" yaml:"verify_ssl"` Public null.NullBool `gorm:"default:true;column:public" json:"public" yaml:"public"` GroupId int `gorm:"default:0;column:group_id" json:"group_id" yaml:"group_id"` + TLSCert null.NullString `gorm:"column:tls_cert" json:"tls_cert" scope:"user,admin" yaml:"tls_cert"` + TLSCertKey null.NullString `gorm:"column:tls_cert_key" json:"tls_cert_key" scope:"user,admin" yaml:"tls_cert_key"` + TLSCertRoot null.NullString `gorm:"column:tls_cert_root" json:"tls_cert_root" scope:"user,admin" yaml:"tls_cert_root"` Headers null.NullString `gorm:"column:headers" json:"headers" scope:"user,admin" yaml:"headers"` Permalink null.NullString `gorm:"column:permalink;unique;" json:"permalink" yaml:"permalink"` Redirect null.NullBool `gorm:"default:false;column:redirect" json:"redirect" scope:"user,admin" yaml:"redirect"` diff --git a/utils/file.go b/utils/file.go index 07b77338..1019b6fd 100644 --- a/utils/file.go +++ b/utils/file.go @@ -3,6 +3,7 @@ package utils import ( "io/ioutil" "os" + "strings" ) // DeleteDirectory will attempt to delete a directory and all contents inside @@ -30,6 +31,15 @@ func FolderExists(folder string) bool { return false } +// FileExtension returns the file extension based on a file path +func FileExtension(path string) string { + s := strings.Split(path, ".") + if len(s) == 0 { + return "" + } + return s[len(s)-1] +} + // FileExists returns true if a file exists // exists := FileExists("assets/css/base.css") func FileExists(name string) bool { diff --git a/utils/utils.go b/utils/utils.go index 2085b8f2..2d6dce27 100644 --- a/utils/utils.go +++ b/utils/utils.go @@ -197,7 +197,7 @@ func DurationReadable(d time.Duration) string { // // body - The body or form data to send with HTTP request // // timeout - Specific duration to timeout on. time.Duration(30 * time.Seconds) // // You can use a HTTP Proxy if you HTTP_PROXY environment variable -func HttpRequest(url, method string, content interface{}, headers []string, body io.Reader, timeout time.Duration, verifySSL bool) ([]byte, *http.Response, error) { +func HttpRequest(url, method string, content interface{}, headers []string, body io.Reader, timeout time.Duration, verifySSL bool, customTLS *tls.Config) ([]byte, *http.Response, error) { var err error var req *http.Request t1 := Now() @@ -247,6 +247,10 @@ func HttpRequest(url, method string, content interface{}, headers []string, body return dialer.DialContext(ctx, network, addr) }, } + if customTLS != nil { + transport.TLSClientConfig.RootCAs = customTLS.RootCAs + transport.TLSClientConfig.Certificates = customTLS.Certificates + } client := &http.Client{ Transport: transport, Timeout: timeout, From 7630eb3263d3341fd47f46236214154d84ca44aa Mon Sep 17 00:00:00 2001 From: hunterlong Date: Tue, 19 May 2020 23:59:28 -0700 Subject: [PATCH 18/49] TLS with TCP --- frontend/src/forms/Service.vue | 2 +- types/services/routine.go | 14 +++++++++++++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/frontend/src/forms/Service.vue b/frontend/src/forms/Service.vue index 146bc5fa..e3f2a267 100644 --- a/frontend/src/forms/Service.vue +++ b/frontend/src/forms/Service.vue @@ -156,7 +156,7 @@ -
+
diff --git a/types/services/routine.go b/types/services/routine.go index a6230691..43aa2c7d 100644 --- a/types/services/routine.go +++ b/types/services/routine.go @@ -2,6 +2,7 @@ package services import ( "bytes" + "crypto/tls" "fmt" "google.golang.org/grpc" "net" @@ -181,7 +182,18 @@ func CheckTcp(s *Service, record bool) *Service { domain = fmt.Sprintf("[%v]:%v", s.Domain, s.Port) } } - conn, err := net.DialTimeout(s.Type, domain, time.Duration(s.Timeout)*time.Second) + + tlsConfig, err := s.LoadTLSCert() + if err != nil { + log.Errorln(err) + } + + dialer := &net.Dialer{ + KeepAlive: time.Duration(s.Timeout) * time.Second, + Timeout: time.Duration(s.Timeout) * time.Second, + } + + conn, err := tls.DialWithDialer(dialer, s.Type, domain, tlsConfig) if err != nil { if record { recordFailure(s, fmt.Sprintf("Dial Error %v", err)) From 42fb363673007e2a81b462ff9017fe8c67460f97 Mon Sep 17 00:00:00 2001 From: hunterlong Date: Wed, 20 May 2020 00:10:04 -0700 Subject: [PATCH 19/49] version up, TLS, ADMIN_PASS to ADMIN_PASSWORD --- CHANGELOG.md | 4 ++++ dev/docker-compose.full.yml | 8 ++++---- dev/docker-compose.lite.yml | 2 +- dev/pwd-stack.yml | 2 +- types/configs/load.go | 2 +- version.txt | 2 +- 6 files changed, 12 insertions(+), 8 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e2e51326..9e8b9f0f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +# 0.90.41 (05-20-2020) +- Added TLS Client Cert/Key feature for HTTP and TCP/UDP services +- Replaced environment variable ADMIN_PASS to ADMIN_PASSWORD. + # 0.90.40 (05-18-2020) - Fixed issues with MySQL and Postgres taking forever to insert sample data (now run in bulk) - Removed API Authentication for /api/logout route diff --git a/dev/docker-compose.full.yml b/dev/docker-compose.full.yml index 6c326ecb..740c75b8 100644 --- a/dev/docker-compose.full.yml +++ b/dev/docker-compose.full.yml @@ -36,7 +36,7 @@ services: DOMAIN: http://localhost:8080 DESCRIPTION: This is a dev environment on SQLite! ADMIN_USER: admin - ADMIN_PASS: admin + ADMIN_PASSWORD: admin SAMPLE_DATA: 'false' ports: - 8080:8080 @@ -69,7 +69,7 @@ services: DOMAIN: http://localhost:8081 DESCRIPTION: This is a dev environment on MySQL! ADMIN_USER: admin - ADMIN_PASS: admin + ADMIN_PASSWORD: admin SAMPLE_DATA: 'false' ports: - 8081:8080 @@ -105,7 +105,7 @@ services: DOMAIN: http://localhost:8082 DESCRIPTION: This is a dev environment on Postgres! ADMIN_USER: admin - ADMIN_PASS: admin + ADMIN_PASSWORD: admin SAMPLE_DATA: 'false' ports: - 8082:8080 @@ -141,7 +141,7 @@ services: DOMAIN: http://localhost:8083 DESCRIPTION: This is a dev environment on MariaDB! ADMIN_USER: admin - ADMIN_PASS: admin + ADMIN_PASSWORD: admin SAMPLE_DATA: 'false' ports: - 8083:8080 diff --git a/dev/docker-compose.lite.yml b/dev/docker-compose.lite.yml index 65c47a68..75e48a54 100644 --- a/dev/docker-compose.lite.yml +++ b/dev/docker-compose.lite.yml @@ -24,7 +24,7 @@ services: DOMAIN: http://localhost:8585 DESCRIPTION: This is a dev environment with auto reloading! ADMIN_USER: admin - ADMIN_PASS: admin + ADMIN_PASSWORD: admin PORT: 8585 ports: - 8888:8888 diff --git a/dev/pwd-stack.yml b/dev/pwd-stack.yml index 602f5612..71c2a179 100644 --- a/dev/pwd-stack.yml +++ b/dev/pwd-stack.yml @@ -18,7 +18,7 @@ services: DOMAIN: http://localhost:8080 DESCRIPTION: This is a dev environment on SQLite! ADMIN_USER: admin - ADMIN_PASS: admin + ADMIN_PASSWORD: admin postgres: hostname: postgres diff --git a/types/configs/load.go b/types/configs/load.go index 6bb6d79d..335cc01b 100644 --- a/types/configs/load.go +++ b/types/configs/load.go @@ -62,7 +62,7 @@ func LoadConfigFile(configFile string) (*DbConfig, error) { Domain: p.GetString("DOMAIN"), Email: p.GetString("EMAIL"), Username: p.GetString("ADMIN_USER"), - Password: p.GetString("ADMIN_PASS"), + Password: p.GetString("ADMIN_PASSWORD"), Location: utils.Directory, SqlFile: p.GetString("SQL_FILE"), } diff --git a/version.txt b/version.txt index 1d535ecf..fb82a5d2 100644 --- a/version.txt +++ b/version.txt @@ -1 +1 @@ -0.90.40 +0.90.41 From 70c5b672b3357e8708e9fdd923360ef6189228e7 Mon Sep 17 00:00:00 2001 From: hunterlong Date: Wed, 20 May 2020 01:36:02 -0700 Subject: [PATCH 20/49] test fix --- utils/utils_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/utils/utils_test.go b/utils/utils_test.go index 55200c1a..4aec3132 100644 --- a/utils/utils_test.go +++ b/utils/utils_test.go @@ -174,7 +174,7 @@ func TestHttpRequest(t *testing.T) { // Close the server when test finishes defer server.Close() - body, resp, err := HttpRequest(server.URL, "GET", "application/json", []string{"aaa=bbbb=", "ccc=ddd"}, nil, 2*time.Second, false) + body, resp, err := HttpRequest(server.URL, "GET", "application/json", []string{"aaa=bbbb=", "ccc=ddd"}, nil, 2*time.Second, false, nil) assert.Nil(t, err) assert.Equal(t, []byte("OK"), body) From 65d654b86d945dc5fe179753d417813c250748d3 Mon Sep 17 00:00:00 2001 From: hunterlong Date: Wed, 20 May 2020 16:40:54 -0700 Subject: [PATCH 21/49] attempt to use GH actions and xgo to build binaries --- .github/workflows/master.yml | 126 ++++++++++++++++++++++++++--------- Makefile | 30 +++++---- 2 files changed, 112 insertions(+), 44 deletions(-) diff --git a/.github/workflows/master.yml b/.github/workflows/master.yml index 1e85a347..1a5d61d0 100644 --- a/.github/workflows/master.yml +++ b/.github/workflows/master.yml @@ -298,7 +298,7 @@ jobs: timeoutRequest: 15000 delayRequest: 500 - build-binaries: + build-linux: needs: compile runs-on: ubuntu-latest steps: @@ -307,30 +307,6 @@ jobs: go-version: '1.14.2' - uses: actions/checkout@v2 - - name: Install cross compiling libraries - run: | - sudo apt-get update - sudo apt-get install -y automake autogen build-essential ca-certificates libsqlite3-dev \ - gcc-5-arm-linux-gnueabi g++-5-arm-linux-gnueabi libc6-dev-armel-cross linux-headers-generic \ - gcc-5-arm-linux-gnueabihf g++-5-arm-linux-gnueabihf libc6-dev-armhf-cross \ - gcc-5-aarch64-linux-gnu g++-5-aarch64-linux-gnu libc6-dev-arm64-cross \ - gcc-5-mips-linux-gnu g++-5-mips-linux-gnu libc6-dev-mips-cross \ - gcc-5-mipsel-linux-gnu g++-5-mipsel-linux-gnu libc6-dev-mipsel-cross \ - gcc-5-mips64-linux-gnuabi64 g++-5-mips64-linux-gnuabi64 libc6-dev-mips64-cross \ - gcc-5-mips64el-linux-gnuabi64 g++-5-mips64el-linux-gnuabi64 libc6-dev-mips64el-cross \ - gcc-5-multilib g++-5-multilib gcc-mingw-w64 g++-mingw-w64 clang llvm-dev \ - gcc-6-arm-linux-gnueabi g++-6-arm-linux-gnueabi libc6-dev-armel-cross \ - gcc-6-arm-linux-gnueabihf g++-6-arm-linux-gnueabihf libc6-dev-armhf-cross \ - gcc-6-aarch64-linux-gnu g++-6-aarch64-linux-gnu libc6-dev-arm64-cross \ - gcc-6-mips-linux-gnu g++-6-mips-linux-gnu libc6-dev-mips-cross \ - gcc-6-mipsel-linux-gnu g++-6-mipsel-linux-gnu libc6-dev-mipsel-cross \ - gcc-6-mips64-linux-gnuabi64 g++-6-mips64-linux-gnuabi64 libc6-dev-mips64-cross \ - gcc-6-mips64el-linux-gnuabi64 g++-6-mips64el-linux-gnuabi64 libc6-dev-mips64el-cross \ - gcc-6-multilib gcc-7-multilib g++-6-multilib gcc-mingw-w64 g++-mingw-w64 clang llvm-dev \ - libtool libxml2-dev uuid-dev libssl-dev swig openjdk-8-jdk pkg-config patch \ - make xz-utils cpio wget zip unzip p7zip git mercurial bzr texinfo help2man cmake --no-install-recommends - sudo ln -s /usr/include/asm-generic/ /usr/include/asm - - name: Setting ENV's run: | echo "::add-path::$(go env GOPATH)/bin" @@ -348,20 +324,96 @@ jobs: name: static-rice-box path: ./source - - name: Build Binaries + - name: Build Linux Binaries env: VERSION: ${{ env.VERSION }} COMMIT: $GITHUB_SHA - run: make build-folders build-linux build-linux-arm build-darwin build-win compress-folders + run: make build-linux build-linux-arm - name: Upload Builds uses: actions/upload-artifact@v1 with: - name: builds + name: builds-linux + path: ./build + + build-windows: + needs: compile + runs-on: ubuntu-latest + steps: + - uses: actions/setup-go@v2 + with: + go-version: '1.14.2' + - uses: actions/checkout@v2 + + - name: Setting ENV's + run: | + echo "::add-path::$(go env GOPATH)/bin" + echo "::add-path::/opt/hostedtoolcache/node/10.20.1/x64/bin" + echo ::set-env name=VERSION::$(cat version.txt) + shell: bash + + - name: Download Go mods + run: | + make test-deps + + - name: Download Compiled Frontend (rice-box.go) + uses: actions/download-artifact@v1 + with: + name: static-rice-box + path: ./source + + - name: Build Windows Binaries + env: + VERSION: ${{ env.VERSION }} + COMMIT: $GITHUB_SHA + run: make build-win + + - name: Upload Builds + uses: actions/upload-artifact@v1 + with: + name: builds-windows + path: ./build + + build-mac: + needs: compile + runs-on: ubuntu-latest + steps: + - uses: actions/setup-go@v2 + with: + go-version: '1.14.2' + - uses: actions/checkout@v2 + + - name: Setting ENV's + run: | + echo "::add-path::$(go env GOPATH)/bin" + echo "::add-path::/opt/hostedtoolcache/node/10.20.1/x64/bin" + echo ::set-env name=VERSION::$(cat version.txt) + shell: bash + + - name: Download Go mods + run: | + make test-deps + + - name: Download Compiled Frontend (rice-box.go) + uses: actions/download-artifact@v1 + with: + name: static-rice-box + path: ./source + + - name: Build MacOSX Binaries + env: + VERSION: ${{ env.VERSION }} + COMMIT: $GITHUB_SHA + run: make build-darwin + + - name: Upload Builds + uses: actions/upload-artifact@v1 + with: + name: builds-mac path: ./build upload-release: - needs: [test, test-postman-sqlite, test-postman-mysql, test-postman-postgres, build-binaries] + needs: [test, test-postman-sqlite, test-postman-mysql, test-postman-postgres, build-linux, build-windows, build-mac] runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 @@ -373,10 +425,22 @@ jobs: echo ::set-env name=VERSION::$(cat version.txt) shell: bash - - name: Download Builds + - name: Download Linux Builds uses: actions/download-artifact@v1 with: - name: builds + name: builds-linux + path: ./builds + + - name: Download Windows Builds + uses: actions/download-artifact@v1 + with: + name: builds-windows + path: ./builds + + - name: Download MacOSX Builds + uses: actions/download-artifact@v1 + with: + name: builds-mac path: ./builds - name: Upload Releases diff --git a/Makefile b/Makefile index d9f3c8be..efa33e71 100644 --- a/Makefile +++ b/Makefile @@ -156,25 +156,29 @@ generate: build-all: clean compile build-folders build-linux build-linux-arm build-darwin build-win compress-folders build-win: - CGO_ENABLED=1 CC=x86_64-w64-mingw32-gcc-posix CXX=x86_64-w64-mingw32-g++-posix GO111MODULE="on" GOOS=windows GOARCH=amd64 \ - go build -a -ldflags "-s -w -extldflags -static -X main.VERSION=${VERSION}" -o releases/statping-windows-amd64/statping.exe ./cmd - CGO_ENABLED=1 CC=i686-w64-mingw32-gcc-posix CXX=i686-w64-mingw32-g++-posix GO111MODULE="on" GOOS=windows GOARCH=386 \ - go build -a -ldflags "-s -w -extldflags -static -X main.VERSION=${VERSION}" -o releases/statping-windows-386/statping.exe ./cmd + xgo --go=1.14.2 --dest=build --targets="windows-6.0/386,windows-6.0/amd64" -out statping -ldflags="-s -w -extldflags -static -X main.VERSION=${VERSION}" --pkg cmd /home/runner/work/statping/statping +# CGO_ENABLED=1 CC=x86_64-w64-mingw32-gcc-posix CXX=x86_64-w64-mingw32-g++-posix GO111MODULE="on" GOOS=windows GOARCH=amd64 \ +# go build -a -ldflags "-s -w -extldflags -static -X main.VERSION=${VERSION}" -o releases/statping-windows-amd64/statping.exe ./cmd +# CGO_ENABLED=1 CC=i686-w64-mingw32-gcc-posix CXX=i686-w64-mingw32-g++-posix GO111MODULE="on" GOOS=windows GOARCH=386 \ +# go build -a -ldflags "-s -w -extldflags -static -X main.VERSION=${VERSION}" -o releases/statping-windows-386/statping.exe ./cmd build-darwin: - GO111MODULE="on" GOOS=darwin GOARCH=amd64 go build -a -ldflags "-s -w -X main.VERSION=${VERSION}" -o releases/statping-darwin-amd64/statping --tags "darwin" ./cmd + xgo --go=1.14.2 --dest=build --targets="darwin/386,darwin/amd64" -out statping -ldflags="-s -w -X main.VERSION=${VERSION}" --pkg cmd /home/runner/work/statping/statping +# GO111MODULE="on" GOOS=darwin GOARCH=amd64 go build -a -ldflags "-s -w -X main.VERSION=${VERSION}" -o releases/statping-darwin-amd64/statping --tags "darwin" ./cmd build-linux: - CGO_ENABLED=1 GO111MODULE="on" GOOS=linux GOARCH=amd64 \ - go build -a -ldflags "-s -w -extldflags -static -X main.VERSION=${VERSION}" -o releases/statping-linux-amd64/statping --tags "linux" ./cmd - CGO_ENABLED=1 GO111MODULE="on" GOOS=linux GOARCH=386 \ - go build -a -ldflags "-s -w -extldflags -static -X main.VERSION=${VERSION}" -o releases/statping-linux-386/statping --tags "linux" ./cmd + xgo --go=1.14.2 --dest=build --targets="linux/386,linux/amd64" -out statping -ldflags="-s -w -extldflags -static -X main.VERSION=${VERSION}" --pkg cmd /home/runner/work/statping/statping +# CGO_ENABLED=1 GO111MODULE="on" GOOS=linux GOARCH=amd64 \ +# go build -a -ldflags "-s -w -extldflags -static -X main.VERSION=${VERSION}" -o releases/statping-linux-amd64/statping --tags "linux" ./cmd +# CGO_ENABLED=1 GO111MODULE="on" GOOS=linux GOARCH=386 \ +# go build -a -ldflags "-s -w -extldflags -static -X main.VERSION=${VERSION}" -o releases/statping-linux-386/statping --tags "linux" ./cmd build-linux-arm: - CGO_ENABLED=1 CC=arm-linux-gnueabihf-gcc-6 CXX=arm-linux-gnueabihf-g++-6 GO111MODULE="on" GOOS=linux GOARCH=arm GOARM=7 \ - go build -a -ldflags "-s -w -extldflags -static -X main.VERSION=${VERSION}" -o releases/statping-linux-arm/statping ./cmd - CGO_ENABLED=1 CC=aarch64-linux-gnu-gcc-6 CXX=aarch64-linux-gnu-g++-6 GO111MODULE="on" GOOS=linux GOARCH=arm64 \ - go build -a -ldflags "-s -w -extldflags -static -X main.VERSION=${VERSION}" -o releases/statping-linux-arm64/statping ./cmd + xgo --go=1.14.2 --dest=build --targets="linux/arm-7,linux/arm64" -out statping -ldflags="-s -w -extldflags -static -X main.VERSION=${VERSION}" --pkg cmd /home/runner/work/statping/statping +# CGO_ENABLED=1 CC=arm-linux-gnueabihf-gcc-6 CXX=arm-linux-gnueabihf-g++-6 GO111MODULE="on" GOOS=linux GOARCH=arm GOARM=7 \ +# go build -a -ldflags "-s -w -extldflags -static -X main.VERSION=${VERSION}" -o releases/statping-linux-arm/statping ./cmd +# CGO_ENABLED=1 CC=aarch64-linux-gnu-gcc-6 CXX=aarch64-linux-gnu-g++-6 GO111MODULE="on" GOOS=linux GOARCH=arm64 \ +# go build -a -ldflags "-s -w -extldflags -static -X main.VERSION=${VERSION}" -o releases/statping-linux-arm64/statping ./cmd build-folders: mkdir build || true From 0ad1f826133408b5ddaf03bbe22a2a0c840fdddf Mon Sep 17 00:00:00 2001 From: hunterlong Date: Wed, 20 May 2020 17:02:36 -0700 Subject: [PATCH 22/49] attempt to use GH actions and xgo to build binaries --- .github/workflows/master.yml | 6 +++--- Makefile | 3 ++- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/.github/workflows/master.yml b/.github/workflows/master.yml index 1a5d61d0..56235166 100644 --- a/.github/workflows/master.yml +++ b/.github/workflows/master.yml @@ -322,7 +322,7 @@ jobs: uses: actions/download-artifact@v1 with: name: static-rice-box - path: ./source + path: /home/runner/work/statping/statping/source - name: Build Linux Binaries env: @@ -360,7 +360,7 @@ jobs: uses: actions/download-artifact@v1 with: name: static-rice-box - path: ./source + path: /home/runner/work/statping/statping/source - name: Build Windows Binaries env: @@ -398,7 +398,7 @@ jobs: uses: actions/download-artifact@v1 with: name: static-rice-box - path: ./source + path: /home/runner/work/statping/statping/source - name: Build MacOSX Binaries env: diff --git a/Makefile b/Makefile index efa33e71..61b604af 100644 --- a/Makefile +++ b/Makefile @@ -50,13 +50,14 @@ cypress: clean test-api: DB_CONN=sqlite DB_HOST=localhost DB_DATABASE=sqlite DB_PASS=none DB_USER=none statping & - sleep 5000 && newman run source/tmpl/postman.json -e dev/postman_environment.json --delay-request 500 + sleep 5000 && newman run dev/postman.json -e dev/postman_environment_sqlite.json --delay-request 500 test-deps: go get golang.org/x/tools/cmd/cover go get github.com/mattn/goveralls go get github.com/GeertJohan/go.rice/rice go get github.com/mattn/go-sqlite3 + go get github.com/crazy-max/xgo go install github.com/mattn/go-sqlite3 deps: From e25e55bde288ec867d7553f1936909b146478791 Mon Sep 17 00:00:00 2001 From: hunterlong Date: Wed, 20 May 2020 17:48:16 -0700 Subject: [PATCH 23/49] attempt to use GH actions and xgo to build binaries --- .github/workflows/master.yml | 70 ++++++++++++++++++++++++++---------- 1 file changed, 52 insertions(+), 18 deletions(-) diff --git a/.github/workflows/master.yml b/.github/workflows/master.yml index 56235166..02f7dd5c 100644 --- a/.github/workflows/master.yml +++ b/.github/workflows/master.yml @@ -322,13 +322,33 @@ jobs: uses: actions/download-artifact@v1 with: name: static-rice-box - path: /home/runner/work/statping/statping/source + path: ./source - - name: Build Linux Binaries - env: - VERSION: ${{ env.VERSION }} - COMMIT: $GITHUB_SHA - run: make build-linux build-linux-arm + - name: Build Linux XGO + uses: crazy-max/ghaction-xgo@v1 + with: + xgo_version: latest + go_version: ${{ matrix.go_version }} + dest: build + prefix: statping + targets: linux/386,linux/amd64 + v: true + x: false + buildmode: default + ldflags: -s -w -X main.VERSION=$VERSION + + - name: Build Linux ARM XGO + uses: crazy-max/ghaction-xgo@v1 + with: + xgo_version: latest + go_version: ${{ matrix.go_version }} + dest: build + prefix: statping + targets: linux/arm-7,linux/arm64 + v: true + x: false + buildmode: default + ldflags: -s -w -extldflags -static -X main.VERSION=$VERSION - name: Upload Builds uses: actions/upload-artifact@v1 @@ -360,13 +380,20 @@ jobs: uses: actions/download-artifact@v1 with: name: static-rice-box - path: /home/runner/work/statping/statping/source + path: ./source - - name: Build Windows Binaries - env: - VERSION: ${{ env.VERSION }} - COMMIT: $GITHUB_SHA - run: make build-win + - name: Build Linux ARM XGO + uses: crazy-max/ghaction-xgo@v1 + with: + xgo_version: latest + go_version: ${{ matrix.go_version }} + dest: build + prefix: statping + targets: windows-6.0/386,windows-6.0/amd64 + v: true + x: false + buildmode: default + ldflags: -s -w -X main.VERSION=$VERSION - name: Upload Builds uses: actions/upload-artifact@v1 @@ -398,13 +425,20 @@ jobs: uses: actions/download-artifact@v1 with: name: static-rice-box - path: /home/runner/work/statping/statping/source + path: ./source - - name: Build MacOSX Binaries - env: - VERSION: ${{ env.VERSION }} - COMMIT: $GITHUB_SHA - run: make build-darwin + - name: Build MacOSX ARM XGO + uses: crazy-max/ghaction-xgo@v1 + with: + xgo_version: latest + go_version: ${{ matrix.go_version }} + dest: build + prefix: statping + targets: darwin/386,darwin/amd64 + v: true + x: false + buildmode: default + ldflags: -s -w -X main.VERSION=$VERSION - name: Upload Builds uses: actions/upload-artifact@v1 From 21b037ab8c4fce55ec6e5796a3543f46f98ee157 Mon Sep 17 00:00:00 2001 From: hunterlong Date: Wed, 20 May 2020 18:29:23 -0700 Subject: [PATCH 24/49] attempt to use GH actions and xgo to build binaries --- .github/workflows/master.yml | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/.github/workflows/master.yml b/.github/workflows/master.yml index 02f7dd5c..5ac03bed 100644 --- a/.github/workflows/master.yml +++ b/.github/workflows/master.yml @@ -328,9 +328,10 @@ jobs: uses: crazy-max/ghaction-xgo@v1 with: xgo_version: latest - go_version: ${{ matrix.go_version }} + go_version: 1.14.2 dest: build prefix: statping + pkg: cmd targets: linux/386,linux/amd64 v: true x: false @@ -341,9 +342,10 @@ jobs: uses: crazy-max/ghaction-xgo@v1 with: xgo_version: latest - go_version: ${{ matrix.go_version }} + go_version: 1.14.2 dest: build prefix: statping + pkg: cmd targets: linux/arm-7,linux/arm64 v: true x: false @@ -382,13 +384,14 @@ jobs: name: static-rice-box path: ./source - - name: Build Linux ARM XGO + - name: Build Windows XGO uses: crazy-max/ghaction-xgo@v1 with: xgo_version: latest - go_version: ${{ matrix.go_version }} + go_version: 1.14.2 dest: build prefix: statping + pkg: cmd targets: windows-6.0/386,windows-6.0/amd64 v: true x: false @@ -427,13 +430,14 @@ jobs: name: static-rice-box path: ./source - - name: Build MacOSX ARM XGO + - name: Build MacOSX XGO uses: crazy-max/ghaction-xgo@v1 with: xgo_version: latest - go_version: ${{ matrix.go_version }} + go_version: 1.14.2 dest: build prefix: statping + pkg: cmd targets: darwin/386,darwin/amd64 v: true x: false From a8bae268ea6e7ebea2fb093e39f938763a4f25de Mon Sep 17 00:00:00 2001 From: hunterlong Date: Wed, 20 May 2020 19:53:09 -0700 Subject: [PATCH 25/49] TCP service fix for services that are not using TLS (different packages) --- .github/workflows/master.yml | 170 +++++++---------------------------- CHANGELOG.md | 3 + Makefile | 33 +++---- frontend/public/base.gohtml | 3 +- frontend/public/favicon.ico | Bin 3019 -> 1150 bytes frontend/public/index.html | 1 + types/services/routine.go | 34 +++---- version.txt | 2 +- 8 files changed, 72 insertions(+), 174 deletions(-) diff --git a/.github/workflows/master.yml b/.github/workflows/master.yml index 5ac03bed..1e85a347 100644 --- a/.github/workflows/master.yml +++ b/.github/workflows/master.yml @@ -298,7 +298,7 @@ jobs: timeoutRequest: 15000 delayRequest: 500 - build-linux: + build-binaries: needs: compile runs-on: ubuntu-latest steps: @@ -307,6 +307,30 @@ jobs: go-version: '1.14.2' - uses: actions/checkout@v2 + - name: Install cross compiling libraries + run: | + sudo apt-get update + sudo apt-get install -y automake autogen build-essential ca-certificates libsqlite3-dev \ + gcc-5-arm-linux-gnueabi g++-5-arm-linux-gnueabi libc6-dev-armel-cross linux-headers-generic \ + gcc-5-arm-linux-gnueabihf g++-5-arm-linux-gnueabihf libc6-dev-armhf-cross \ + gcc-5-aarch64-linux-gnu g++-5-aarch64-linux-gnu libc6-dev-arm64-cross \ + gcc-5-mips-linux-gnu g++-5-mips-linux-gnu libc6-dev-mips-cross \ + gcc-5-mipsel-linux-gnu g++-5-mipsel-linux-gnu libc6-dev-mipsel-cross \ + gcc-5-mips64-linux-gnuabi64 g++-5-mips64-linux-gnuabi64 libc6-dev-mips64-cross \ + gcc-5-mips64el-linux-gnuabi64 g++-5-mips64el-linux-gnuabi64 libc6-dev-mips64el-cross \ + gcc-5-multilib g++-5-multilib gcc-mingw-w64 g++-mingw-w64 clang llvm-dev \ + gcc-6-arm-linux-gnueabi g++-6-arm-linux-gnueabi libc6-dev-armel-cross \ + gcc-6-arm-linux-gnueabihf g++-6-arm-linux-gnueabihf libc6-dev-armhf-cross \ + gcc-6-aarch64-linux-gnu g++-6-aarch64-linux-gnu libc6-dev-arm64-cross \ + gcc-6-mips-linux-gnu g++-6-mips-linux-gnu libc6-dev-mips-cross \ + gcc-6-mipsel-linux-gnu g++-6-mipsel-linux-gnu libc6-dev-mipsel-cross \ + gcc-6-mips64-linux-gnuabi64 g++-6-mips64-linux-gnuabi64 libc6-dev-mips64-cross \ + gcc-6-mips64el-linux-gnuabi64 g++-6-mips64el-linux-gnuabi64 libc6-dev-mips64el-cross \ + gcc-6-multilib gcc-7-multilib g++-6-multilib gcc-mingw-w64 g++-mingw-w64 clang llvm-dev \ + libtool libxml2-dev uuid-dev libssl-dev swig openjdk-8-jdk pkg-config patch \ + make xz-utils cpio wget zip unzip p7zip git mercurial bzr texinfo help2man cmake --no-install-recommends + sudo ln -s /usr/include/asm-generic/ /usr/include/asm + - name: Setting ENV's run: | echo "::add-path::$(go env GOPATH)/bin" @@ -324,134 +348,20 @@ jobs: name: static-rice-box path: ./source - - name: Build Linux XGO - uses: crazy-max/ghaction-xgo@v1 - with: - xgo_version: latest - go_version: 1.14.2 - dest: build - prefix: statping - pkg: cmd - targets: linux/386,linux/amd64 - v: true - x: false - buildmode: default - ldflags: -s -w -X main.VERSION=$VERSION - - - name: Build Linux ARM XGO - uses: crazy-max/ghaction-xgo@v1 - with: - xgo_version: latest - go_version: 1.14.2 - dest: build - prefix: statping - pkg: cmd - targets: linux/arm-7,linux/arm64 - v: true - x: false - buildmode: default - ldflags: -s -w -extldflags -static -X main.VERSION=$VERSION + - name: Build Binaries + env: + VERSION: ${{ env.VERSION }} + COMMIT: $GITHUB_SHA + run: make build-folders build-linux build-linux-arm build-darwin build-win compress-folders - name: Upload Builds uses: actions/upload-artifact@v1 with: - name: builds-linux - path: ./build - - build-windows: - needs: compile - runs-on: ubuntu-latest - steps: - - uses: actions/setup-go@v2 - with: - go-version: '1.14.2' - - uses: actions/checkout@v2 - - - name: Setting ENV's - run: | - echo "::add-path::$(go env GOPATH)/bin" - echo "::add-path::/opt/hostedtoolcache/node/10.20.1/x64/bin" - echo ::set-env name=VERSION::$(cat version.txt) - shell: bash - - - name: Download Go mods - run: | - make test-deps - - - name: Download Compiled Frontend (rice-box.go) - uses: actions/download-artifact@v1 - with: - name: static-rice-box - path: ./source - - - name: Build Windows XGO - uses: crazy-max/ghaction-xgo@v1 - with: - xgo_version: latest - go_version: 1.14.2 - dest: build - prefix: statping - pkg: cmd - targets: windows-6.0/386,windows-6.0/amd64 - v: true - x: false - buildmode: default - ldflags: -s -w -X main.VERSION=$VERSION - - - name: Upload Builds - uses: actions/upload-artifact@v1 - with: - name: builds-windows - path: ./build - - build-mac: - needs: compile - runs-on: ubuntu-latest - steps: - - uses: actions/setup-go@v2 - with: - go-version: '1.14.2' - - uses: actions/checkout@v2 - - - name: Setting ENV's - run: | - echo "::add-path::$(go env GOPATH)/bin" - echo "::add-path::/opt/hostedtoolcache/node/10.20.1/x64/bin" - echo ::set-env name=VERSION::$(cat version.txt) - shell: bash - - - name: Download Go mods - run: | - make test-deps - - - name: Download Compiled Frontend (rice-box.go) - uses: actions/download-artifact@v1 - with: - name: static-rice-box - path: ./source - - - name: Build MacOSX XGO - uses: crazy-max/ghaction-xgo@v1 - with: - xgo_version: latest - go_version: 1.14.2 - dest: build - prefix: statping - pkg: cmd - targets: darwin/386,darwin/amd64 - v: true - x: false - buildmode: default - ldflags: -s -w -X main.VERSION=$VERSION - - - name: Upload Builds - uses: actions/upload-artifact@v1 - with: - name: builds-mac + name: builds path: ./build upload-release: - needs: [test, test-postman-sqlite, test-postman-mysql, test-postman-postgres, build-linux, build-windows, build-mac] + needs: [test, test-postman-sqlite, test-postman-mysql, test-postman-postgres, build-binaries] runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 @@ -463,22 +373,10 @@ jobs: echo ::set-env name=VERSION::$(cat version.txt) shell: bash - - name: Download Linux Builds + - name: Download Builds uses: actions/download-artifact@v1 with: - name: builds-linux - path: ./builds - - - name: Download Windows Builds - uses: actions/download-artifact@v1 - with: - name: builds-windows - path: ./builds - - - name: Download MacOSX Builds - uses: actions/download-artifact@v1 - with: - name: builds-mac + name: builds path: ./builds - name: Upload Releases diff --git a/CHANGELOG.md b/CHANGELOG.md index 9e8b9f0f..c1b82933 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,6 @@ +# 0.90.42 (05-20-2020) +- Fixed TCP services that dont use TLS. + # 0.90.41 (05-20-2020) - Added TLS Client Cert/Key feature for HTTP and TCP/UDP services - Replaced environment variable ADMIN_PASS to ADMIN_PASSWORD. diff --git a/Makefile b/Makefile index 61b604af..d9f3c8be 100644 --- a/Makefile +++ b/Makefile @@ -50,14 +50,13 @@ cypress: clean test-api: DB_CONN=sqlite DB_HOST=localhost DB_DATABASE=sqlite DB_PASS=none DB_USER=none statping & - sleep 5000 && newman run dev/postman.json -e dev/postman_environment_sqlite.json --delay-request 500 + sleep 5000 && newman run source/tmpl/postman.json -e dev/postman_environment.json --delay-request 500 test-deps: go get golang.org/x/tools/cmd/cover go get github.com/mattn/goveralls go get github.com/GeertJohan/go.rice/rice go get github.com/mattn/go-sqlite3 - go get github.com/crazy-max/xgo go install github.com/mattn/go-sqlite3 deps: @@ -157,29 +156,25 @@ generate: build-all: clean compile build-folders build-linux build-linux-arm build-darwin build-win compress-folders build-win: - xgo --go=1.14.2 --dest=build --targets="windows-6.0/386,windows-6.0/amd64" -out statping -ldflags="-s -w -extldflags -static -X main.VERSION=${VERSION}" --pkg cmd /home/runner/work/statping/statping -# CGO_ENABLED=1 CC=x86_64-w64-mingw32-gcc-posix CXX=x86_64-w64-mingw32-g++-posix GO111MODULE="on" GOOS=windows GOARCH=amd64 \ -# go build -a -ldflags "-s -w -extldflags -static -X main.VERSION=${VERSION}" -o releases/statping-windows-amd64/statping.exe ./cmd -# CGO_ENABLED=1 CC=i686-w64-mingw32-gcc-posix CXX=i686-w64-mingw32-g++-posix GO111MODULE="on" GOOS=windows GOARCH=386 \ -# go build -a -ldflags "-s -w -extldflags -static -X main.VERSION=${VERSION}" -o releases/statping-windows-386/statping.exe ./cmd + CGO_ENABLED=1 CC=x86_64-w64-mingw32-gcc-posix CXX=x86_64-w64-mingw32-g++-posix GO111MODULE="on" GOOS=windows GOARCH=amd64 \ + go build -a -ldflags "-s -w -extldflags -static -X main.VERSION=${VERSION}" -o releases/statping-windows-amd64/statping.exe ./cmd + CGO_ENABLED=1 CC=i686-w64-mingw32-gcc-posix CXX=i686-w64-mingw32-g++-posix GO111MODULE="on" GOOS=windows GOARCH=386 \ + go build -a -ldflags "-s -w -extldflags -static -X main.VERSION=${VERSION}" -o releases/statping-windows-386/statping.exe ./cmd build-darwin: - xgo --go=1.14.2 --dest=build --targets="darwin/386,darwin/amd64" -out statping -ldflags="-s -w -X main.VERSION=${VERSION}" --pkg cmd /home/runner/work/statping/statping -# GO111MODULE="on" GOOS=darwin GOARCH=amd64 go build -a -ldflags "-s -w -X main.VERSION=${VERSION}" -o releases/statping-darwin-amd64/statping --tags "darwin" ./cmd + GO111MODULE="on" GOOS=darwin GOARCH=amd64 go build -a -ldflags "-s -w -X main.VERSION=${VERSION}" -o releases/statping-darwin-amd64/statping --tags "darwin" ./cmd build-linux: - xgo --go=1.14.2 --dest=build --targets="linux/386,linux/amd64" -out statping -ldflags="-s -w -extldflags -static -X main.VERSION=${VERSION}" --pkg cmd /home/runner/work/statping/statping -# CGO_ENABLED=1 GO111MODULE="on" GOOS=linux GOARCH=amd64 \ -# go build -a -ldflags "-s -w -extldflags -static -X main.VERSION=${VERSION}" -o releases/statping-linux-amd64/statping --tags "linux" ./cmd -# CGO_ENABLED=1 GO111MODULE="on" GOOS=linux GOARCH=386 \ -# go build -a -ldflags "-s -w -extldflags -static -X main.VERSION=${VERSION}" -o releases/statping-linux-386/statping --tags "linux" ./cmd + CGO_ENABLED=1 GO111MODULE="on" GOOS=linux GOARCH=amd64 \ + go build -a -ldflags "-s -w -extldflags -static -X main.VERSION=${VERSION}" -o releases/statping-linux-amd64/statping --tags "linux" ./cmd + CGO_ENABLED=1 GO111MODULE="on" GOOS=linux GOARCH=386 \ + go build -a -ldflags "-s -w -extldflags -static -X main.VERSION=${VERSION}" -o releases/statping-linux-386/statping --tags "linux" ./cmd build-linux-arm: - xgo --go=1.14.2 --dest=build --targets="linux/arm-7,linux/arm64" -out statping -ldflags="-s -w -extldflags -static -X main.VERSION=${VERSION}" --pkg cmd /home/runner/work/statping/statping -# CGO_ENABLED=1 CC=arm-linux-gnueabihf-gcc-6 CXX=arm-linux-gnueabihf-g++-6 GO111MODULE="on" GOOS=linux GOARCH=arm GOARM=7 \ -# go build -a -ldflags "-s -w -extldflags -static -X main.VERSION=${VERSION}" -o releases/statping-linux-arm/statping ./cmd -# CGO_ENABLED=1 CC=aarch64-linux-gnu-gcc-6 CXX=aarch64-linux-gnu-g++-6 GO111MODULE="on" GOOS=linux GOARCH=arm64 \ -# go build -a -ldflags "-s -w -extldflags -static -X main.VERSION=${VERSION}" -o releases/statping-linux-arm64/statping ./cmd + CGO_ENABLED=1 CC=arm-linux-gnueabihf-gcc-6 CXX=arm-linux-gnueabihf-g++-6 GO111MODULE="on" GOOS=linux GOARCH=arm GOARM=7 \ + go build -a -ldflags "-s -w -extldflags -static -X main.VERSION=${VERSION}" -o releases/statping-linux-arm/statping ./cmd + CGO_ENABLED=1 CC=aarch64-linux-gnu-gcc-6 CXX=aarch64-linux-gnu-g++-6 GO111MODULE="on" GOOS=linux GOARCH=arm64 \ + go build -a -ldflags "-s -w -extldflags -static -X main.VERSION=${VERSION}" -o releases/statping-linux-arm64/statping ./cmd build-folders: mkdir build || true diff --git a/frontend/public/base.gohtml b/frontend/public/base.gohtml index 95564ce7..46e82bfb 100644 --- a/frontend/public/base.gohtml +++ b/frontend/public/base.gohtml @@ -7,14 +7,13 @@ + {{if USE_CDN}} - {{else}} - {{if USING_ASSETS}} diff --git a/frontend/public/favicon.ico b/frontend/public/favicon.ico index e899902927063a6c859ec66179bad0fa4ca958cf..004d10b3c3b3a9661285d68cbe26eead2a55fe6b 100644 GIT binary patch literal 1150 zcmbW1%S+Tz6vxkReh*(%Qs5>-3&GYsmPIxd(O(dnxu`{`D@9r*LDaSq$;x^8N>nOy z5d{^RT0V$`3|C3T7*Y#GCT6sm`Sv~c=ZLiI{5Ze+n{&_S+e7~-|cKFlR|LeBxF$FhVtM<^B`fy=%j`OR?LPM zEri|aLWacnDwC52##Fl(DkQ^o+ig@tD{;L41P=EeMN!8N$OA#3+lALzV0@KPnMh2) zdF{XsduGk5;UMO|&tZLI-4D++msgf?>G@?pMwbgKTX9a0oH6-$>Ptr1ve`07H*<_Q5ay{dnr51D=-Cm-Z9((f7N6()&U_o> zKG%xn8%9}ooHgkRu-;^;7S(QdP%~1CC-YAcUyb9>W^Y?RUN^iGV|~de>y0z-O+FA~ ztcQYug+a5X>2uca^Sht#v8S&D65(E>+$$Mn%RiJudRSZbTIY&-b|RjL8-69Ziu#EL zR18$Y>Ig7L?vpv1T*)X~_qERS!_;5%XN;L&vzz>isr$9jRy4h7+N!_tWxti3Oiscb zV^3H=JH}jCzq2pTA(i&ehxS2bExCrW{{1Gt9q|mKtV-ijBV?H8CtLti1I9QoRDqV+ ztGN5Q4L9d*;rv)NcJ=M%8RQ!DRVF7Xq;P66XzX^_GHnuHY52oSB*61AyN6%x~06;wh( z6(8sas^FNkDi&`0p;QIZm(qlk#E(Ey3Q1q8BG(z5G$i0mX8ah>rVw<{-BneZW-O}8DR*9Ux932g4#A#%_1$KddVZILfPue*k&&>&onMa8-w$jS z0TBfZcMuUogcuD~a0gW(&mC0(I14-sJh;5<4=vnctxGZ2H78)~F}W=S`HYBcH**Td z1$Qq76hWkL*sO5Yz4#fUlVyUL<6b;x=7gXxx%&YT|H8~pTU^Wet{DN7$8^|?gR1&r zcc<{zSDY77M4T9l&ywTmSyjQ!;R3=EF{*+HFS_&Vv%BKouhqQQgn*4l!)7!82CxkT zk;2J@6bV3uknX4eR>%lJ$a5nE?TV7ZHU|EQ*Ilf$HB zhHCM3UbrP?eva*%_a%>qqSf$a8K;&Zk6Gog6vXl+gaZPia#= z+g`T6T>e8pdoi0=d}>tBPM^Oqo7a8uJa=%dqpyQ9mpGx5A5w&g$VY+N1k{dzi6ib@@YHkl_c0*O?HZ^ch()FHUSoW zGHr83lBz_(2q%^f_;g*{Rmf8I`8ea#?v9G!ZSW@KbB>-DeAe-4sh!K}M}Wz23jON7 zZ|1o8wz0>$Bcv|o?ptoMC||Mf3+)q5JOS}Ji2nikv(WliX#R8kK&#E1x7?&5T7;x` z)@8w`2pWQXY3wm>KDWnf<$x;UDLE2f@jEe2Vt$fbrab3+CY;RMezJc+U#M%l_AW5? zRsCV#CfS@4p-7n!DU;Sys``yGR#JQ=R4R)QU)op!kR{6{;#N-KOE_)|!eP{}a?F;9gW-r_c1gjkhyMMc^pDPya8SO?d*$ibf|zPp77Dy8E|4 z9t}Yr3PFyadRKcbe7q=Dr3Vb{(_6A@-C&Iz-dcUjhT7?aT2i5K^>3v1jMps2w3MGPSkw4Nq)n|bp zsLEGF_|nYI`0uNoa}}#5V0>SHBhT7@#b&=PyGqc@1eD5}FBPJqi7E3%dM4?9)z6A3 zDwa#}%*yXa^E`ff?q;4??c8CFG{K>JrD1{3_Fb;O#iXGd1sMkV%IZ+Hn}Dk5*|lWs z!YE49EM>D!-Z&%@_MX0}J-?c{uc<7);bXEZ8`0nQA>Xc-fs6w~PByG7HD_1X2$iO$ zniHU^C?{w~8%&8)gs0uP^~`RYsXOO2KNpa@(80m5n}**V2KBZ$7#lhQIwph>!TX)C zp_IzgUpz%c=NzEZV|eQMyHp?%CB{gW1>F5R&8F{MxW#If+?VudY&aQqJG=YyWH zD~w7*hJg)^i~s`=1_ck@5wKESN|`HCO#yU~5$@?{@mYCvCb;wY(>KN6>~${xD+FAK z;k}Z%%XU=u$bi3B8ge6}t~v@jDaaT|@ahh*k|5nBErpY_yW$&q9s4JOfD18nuWWMU z1G0gS=&0Nfu7q$ENa!xFFDRBUv&+xy_MUcxH6dX9amhsFI#ss1Gk^Lfdu%Q20t|jE z?3OV<*td->;fi7jn2`=kD@rtgzhicn{ZlXYdsc)t9+hF$a7Uion^a}1n{O4BEoR>6 z9BCg0){KC~FT}%x_vpLqMfpd$+^?3<-AF;17(>u;dQ``I)&t@+*O>9AB7D-_-!Cd# zMWj)v!j75WIC)GPz1qDP77y4dJL~(%%Suq_R*21vJdZv5)AI}Vyo}RM#Y@@M6=#Bi z2!k7a}aA^8oDIDJ(%T}$m;DF5+O4Gt+AI%yTRQBQwR)#gO{X;nCy!;<)UkgdCXa+2v2v6aIk4V+yT{E_&#>mXbvhvD|2;{FiJ}rM<%a=MY0StXo@66uBA7`(xUWT&H zQ8_Eip=@cHcK0uf@Mxa%^tnAh+QUyC%Ld(Tn>)MQ`9)QEd-|?wvly#$U#JbOXMDnO@RI?+3=R|j9%|=%{B_|(jlNoQpE+xQs}H)ZlV(*bHEJHG9wf5agYf> zV=PH?5ZQ0HN-S0PS!4OWE6G zfi^!ULm>Uh(eg4=*{meRx4aivsyvX|+fpr)6^B#QWLbyF9PDMV@5ynWlb@g8Ur!B! zRT2O&`ZN9i(4MnlUt$M+5QYSY74;@Lo(M@-T*@6os?7|Ei1bczzF2H~ZjLX2y$JTa z9GCNY^ZfpNRre59O~BHVIeqW&Z?L2bvM9S_%T+Uw21unYfKnk&TV?SbB&W-&PN)i} zssc-3uRwer;>$ej3v&DX{`{5I&VNnyfZ>ma9X{ZHq?fTx#({As8y4sn2;FLMLbY~C z=ZI#-Z4g>QK5uXi>@;vjrftE02eU&9_pi;I*IW=8yoXFf_DkNdy*kKt858JtWCO*& z21tNT)eJ&$wC>;ro`WqpK3`mgVIEkJleWYIu^qqIe1KJ*16+tpst66;tJkBvPx@si z%8ed;T>3gB^a+lm0W1fPpe|U`@ir|Y|K`gaCh|AS%l7T~#d_D^UJE}qNo?>Q$g*s+ zyKDj9WM&gM0}h!*Z)%Wv5jksSFEkf@$`A1qb&+Bn>sZG+*71K4{{ + Statping diff --git a/types/services/routine.go b/types/services/routine.go index 43aa2c7d..d4351172 100644 --- a/types/services/routine.go +++ b/types/services/routine.go @@ -188,24 +188,26 @@ func CheckTcp(s *Service, record bool) *Service { log.Errorln(err) } - dialer := &net.Dialer{ - KeepAlive: time.Duration(s.Timeout) * time.Second, - Timeout: time.Duration(s.Timeout) * time.Second, + if s.TLSCert.String == "" { + conn, err := net.Dial(s.Type, domain) + if err != nil { + if record { + recordFailure(s, fmt.Sprintf("Dial Error: %v", err)) + } + return s + } + defer conn.Close() + } else { + conn, err := tls.DialWithDialer(&net.Dialer{Timeout: time.Duration(s.Timeout) * time.Second}, s.Type, domain, tlsConfig) + if err != nil { + if record { + recordFailure(s, fmt.Sprintf("Dial Error: %v", err)) + } + return s + } + defer conn.Close() } - conn, err := tls.DialWithDialer(dialer, s.Type, domain, tlsConfig) - if err != nil { - if record { - recordFailure(s, fmt.Sprintf("Dial Error %v", err)) - } - return s - } - if err := conn.Close(); err != nil { - if record { - recordFailure(s, fmt.Sprintf("%v Socket Close Error %v", strings.ToUpper(s.Type), err)) - } - return s - } t2 := utils.Now() s.Latency = t2.Sub(t1).Microseconds() s.LastResponse = "" diff --git a/version.txt b/version.txt index fb82a5d2..991fa778 100644 --- a/version.txt +++ b/version.txt @@ -1 +1 @@ -0.90.41 +0.90.42 From bfd173d7d78994b456a0ece51016492931a15763 Mon Sep 17 00:00:00 2001 From: hunterlong Date: Thu, 21 May 2020 00:10:35 -0700 Subject: [PATCH 26/49] updated ICMP to use system ping command (doesnt need root), added tests for TCP/HTTP TLS and non-TLS service checks --- .github/workflows/master.yml | 2 +- go.mod | 11 +- go.sum | 50 ++----- types/services/methods.go | 27 ++-- types/services/routine.go | 74 +++++------ types/services/services_test.go | 227 ++++++++++++++++++++++++++++++++ utils/utils_custom.go | 27 ++-- utils/utils_windows.go | 25 ++++ 8 files changed, 333 insertions(+), 110 deletions(-) diff --git a/.github/workflows/master.yml b/.github/workflows/master.yml index 1e85a347..cdfb43d6 100644 --- a/.github/workflows/master.yml +++ b/.github/workflows/master.yml @@ -101,7 +101,7 @@ jobs: env: VERSION: ${{ env.VERSION }} run: | - make build + make build certs chmod +x statping mv statping $(go env GOPATH)/bin/ diff --git a/go.mod b/go.mod index fcc3797b..cd267f11 100644 --- a/go.mod +++ b/go.mod @@ -12,24 +12,16 @@ require ( github.com/fsnotify/fsnotify v1.4.9 // indirect github.com/getsentry/sentry-go v0.5.1 github.com/go-mail/mail v2.3.1+incompatible - github.com/gogo/protobuf v1.3.1 // indirect github.com/golang/protobuf v1.3.5 github.com/gorilla/mux v1.7.4 - github.com/gorilla/securecookie v1.1.1 - github.com/gorilla/sessions v1.2.0 github.com/jinzhu/gorm v1.9.12 - github.com/joho/godotenv v1.3.0 - github.com/kataras/iris/v12 v12.0.1 github.com/magiconair/properties v1.8.1 github.com/mattn/go-sqlite3 v2.0.3+incompatible github.com/mitchellh/mapstructure v1.2.2 // indirect github.com/pelletier/go-toml v1.7.0 // indirect github.com/pkg/errors v0.9.1 - github.com/prometheus/common v0.9.1 - github.com/rendon/testcli v0.0.0-20161027181003-6283090d169f github.com/russross/blackfriday/v2 v2.0.1 github.com/sirupsen/logrus v1.4.2 - github.com/skratchdot/open-golang v0.0.0-20200116055534-eef842397966 // indirect github.com/spf13/afero v1.2.2 // indirect github.com/spf13/cast v1.3.1 // indirect github.com/spf13/cobra v1.0.0 @@ -38,12 +30,11 @@ require ( github.com/spf13/viper v1.6.3 github.com/stretchr/testify v1.5.1 github.com/t-tiger/gorm-bulk-insert/v2 v2.0.1 - github.com/tatsushid/go-fastping v0.0.0-20160109021039-d7bb493dee3e golang.org/x/crypto v0.0.0-20200406173513-056763e48d71 + golang.org/x/net v0.0.0-20200226121028-0de0cce0169b // indirect golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be golang.org/x/sys v0.0.0-20200413165638-669c56c373c4 // indirect golang.org/x/text v0.3.2 // indirect - golang.org/x/tools v0.0.0-20200321014904-268ba720d32c // indirect google.golang.org/grpc v1.28.0 gopkg.in/alexcesaro/quotedprintable.v3 v3.0.0-20150716171945-2caba252f4dc // indirect gopkg.in/ini.v1 v1.55.0 // indirect diff --git a/go.sum b/go.sum index 315b77f5..4c7af747 100755 --- a/go.sum +++ b/go.sum @@ -5,6 +5,7 @@ github.com/BurntSushi/toml v0.3.1 h1:WXkYYl6Yr3qBf1K79EBnL4mak0OimBfB0XUf9Vl28OQ github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= github.com/CloudyKit/fastprinter v0.0.0-20170127035650-74b38d55f37a/go.mod h1:EFZQ978U7x8IRnstaskI3IysnWY5Ao3QgZUKOXlsAdw= github.com/CloudyKit/jet v2.1.3-0.20180809161101-62edd43e4f88+incompatible/go.mod h1:HPYO+50pSWkPoj9Q/eq0aRGByCL6ScRlUmiEX5Zgm+w= +github.com/DATA-DOG/go-sqlmock v1.4.1 h1:ThlnYciV1iM/V0OSF/dtkqWb6xo5qITT1TJBG1MRDJM= github.com/DATA-DOG/go-sqlmock v1.4.1/go.mod h1:f/Ixk793poVmq4qj/V1dPUg2JEAKC73Q5eFN3EC/SaM= github.com/GeertJohan/go.incremental v1.0.0 h1:7AH+pY1XUgQE4Y1HcXYaMqAI0m9yrFqo/jt0CW30vsg= github.com/GeertJohan/go.incremental v1.0.0/go.mod h1:6fAjUhbVuX1KcMD3c8TEgVUqmo4seqhv0i0kdATSkM0= @@ -19,11 +20,7 @@ github.com/ajg/form v1.5.1/go.mod h1:uL1WgH+h2mgNtvBq0339dVnzXdBETtL2LeUXaIv25UY github.com/akavel/rsrc v0.8.0 h1:zjWn7ukO9Kc5Q62DOJCcxGpXC18RawVtYAGdz2aLlfw= github.com/akavel/rsrc v0.8.0/go.mod h1:uLoCtb9J+EyAqh+26kdrTgmzRBFPGOolLWKpdxkKq+c= github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc= -github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751 h1:JYp7IbQjafoB+tBA3gMyHYHrpOtNuDiK/uB5uXxq5wM= -github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc= github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0= -github.com/alecthomas/units v0.0.0-20190717042225-c3de453c63f4 h1:Hs82Z41s6SdL1CELW+XaDYmOH4hkBN4/N9og/AsOv7E= -github.com/alecthomas/units v0.0.0-20190717042225-c3de453c63f4/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0= github.com/ararog/timeago v0.0.0-20160328174124-e9969cf18b8d h1:ZX0t+GA3MWiP7LWt5xWOphWRQd5JwL4VW5uLW83KM8g= github.com/ararog/timeago v0.0.0-20160328174124-e9969cf18b8d/go.mod h1:EcJ034SpbWy4heOSDiBZJRn3b5wKJM1b4sFfYeVAkI4= github.com/armon/consul-api v0.0.0-20180202201655-eb2c6b5be1b6/go.mod h1:grANhF5doyWs3UAsr3K4I6qtAmlQcZDesFNEHPZAzj8= @@ -52,6 +49,7 @@ github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/denisenkom/go-mssqldb v0.0.0-20191124224453-732737034ffd h1:83Wprp6ROGeiHFAP8WJdI2RoxALQYgdllERc3N5N2DM= github.com/denisenkom/go-mssqldb v0.0.0-20191124224453-732737034ffd/go.mod h1:xbL0rPBG9cCiLr28tMa8zpbdarY27NDyej4t/EjAShU= +github.com/denisenkom/go-mssqldb v0.0.0-20200206145737-bbfc9a55622e h1:LzwWXEScfcTu7vUZNlDDWDARoSGEtvlDKK2BYHowNeE= github.com/denisenkom/go-mssqldb v0.0.0-20200206145737-bbfc9a55622e/go.mod h1:xbL0rPBG9cCiLr28tMa8zpbdarY27NDyej4t/EjAShU= github.com/dgraph-io/badger v1.6.0/go.mod h1:zwt7syl517jmP8s94KqSxTlM6IMsdhYy6psNgSztDR4= github.com/dgrijalva/jwt-go v3.2.0+incompatible h1:7qlOGliEKZXTDg6OTjfoBKDXWrumCAMpl/TFQ4/5kLM= @@ -85,7 +83,6 @@ github.com/go-check/check v0.0.0-20180628173108-788fd7840127/go.mod h1:9ES+weclK github.com/go-errors/errors v1.0.1 h1:LUHzmkK3GUKUrL/1gfBUxAHzcev3apQlezX/+O7ma6w= github.com/go-errors/errors v1.0.1/go.mod h1:f4zRHt4oKfwPJE5k8C9vpYG+aDHdBFUsgrm6/TyX73Q= github.com/go-kit/kit v0.8.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as= -github.com/go-kit/kit v0.9.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as= github.com/go-logfmt/logfmt v0.3.0/go.mod h1:Qt1PoO58o5twSAckw1HlFXLmHsOX5/0LbT9GBnD5lWE= github.com/go-logfmt/logfmt v0.4.0/go.mod h1:3RMwSq7FuexP4Kalkev3ejPJsZTpXXBr9+V4qmtdjCk= github.com/go-mail/mail v2.3.1+incompatible h1:UzNOn0k5lpfVtO31cK3hn6I4VEVGhe3lX8AJBAxXExM= @@ -102,8 +99,6 @@ github.com/gobwas/ws v1.0.2/go.mod h1:szmBTxLgaFppYjEmNtny/v3w89xOydFnnZMcgRRu/E github.com/gogo/protobuf v1.1.1 h1:72R+M5VuhED/KujmZVcIquuo8mBgX4oVda//DQb3PXo= github.com/gogo/protobuf v1.1.1/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ= github.com/gogo/protobuf v1.2.1/go.mod h1:hp+jE20tsWTFYpLwKvXlhS1hjn+gTNwPg2I6zVXpSg4= -github.com/gogo/protobuf v1.3.1 h1:DqDEcV5aeaTmdFBePNpYsp3FlcVH/2ISVVM9Qf8PSls= -github.com/gogo/protobuf v1.3.1/go.mod h1:SlYgWuQ5SjCEi6WLHjHCa1yvBfUnHcTbrrZtXPKa29o= github.com/golang-sql/civil v0.0.0-20190719163853-cb61b32ac6fe h1:lXe2qZdvpiX5WZkZR4hgp4KJVfY3nMkvmwbVkpv1rVY= github.com/golang-sql/civil v0.0.0-20190719163853-cb61b32ac6fe/go.mod h1:8vg3r2VgvsThLBIFL93Qb5yWzgyZWhEmBwUJWevAkK0= github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q= @@ -123,13 +118,10 @@ github.com/google/go-cmp v0.4.0 h1:xsAVV57WRhGj6kEIi8ReJzQlHHqcBYCElAvkovg3B/4= github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-querystring v1.0.0/go.mod h1:odCYkC5MyYFN7vkCjXpyrEuKhc/BUO6wN/zVPAxq5ck= github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= +github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1 h1:EGx4pi6eqNxGaHF6qqu48+N2wcFQ5qg5FXgOdqsJ5d8= github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY= github.com/gorilla/mux v1.7.4 h1:VuZ8uybHlWmqV03+zRzdwKL4tUnIp1MAQtp1mIFE1bc= github.com/gorilla/mux v1.7.4/go.mod h1:DVbg23sWSpFRCP0SfiEN6jmj59UnW/n46BH5rLB71So= -github.com/gorilla/securecookie v1.1.1 h1:miw7JPhV+b/lAHSXz4qd/nN9jRiAFV5FwjeKyCS8BvQ= -github.com/gorilla/securecookie v1.1.1/go.mod h1:ra0sb63/xPlUeL+yeDciTfxMRAA+MP+HVt/4epWDjd4= -github.com/gorilla/sessions v1.2.0 h1:S7P+1Hm5V/AT9cjEcUD5uDaQSX0OE577aCXgoaKpYbQ= -github.com/gorilla/sessions v1.2.0/go.mod h1:dk2InVEVJ0sfLlnXv9EAgkf6ecYs/i80K/zI+bUmuGM= github.com/gorilla/websocket v1.4.0/go.mod h1:E7qHFY5m1UJ88s3WnNqhKjPHQ0heANvMoAMk2YaljkQ= github.com/grpc-ecosystem/go-grpc-middleware v1.0.0/go.mod h1:FiyG127CGDf3tlThmgyCl78X/SZQqEOJBCDaAfeWzPs= github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0/go.mod h1:8NvIoxWQoOIhqOTXgfV/d3M/q6VIi02HzZEHgUlZvzk= @@ -156,13 +148,13 @@ github.com/jinzhu/inflection v1.0.0 h1:K317FqzuhWc8YvSVlFMCCUb36O/S9MCKRDI7QkRKD github.com/jinzhu/inflection v1.0.0/go.mod h1:h+uFLlag+Qp1Va5pdKtLDYj+kHp5pxUVkryuEj+Srlc= github.com/jinzhu/now v1.0.1 h1:HjfetcXq097iXP0uoPCdnM4Efp5/9MsM0/M+XOTeR3M= github.com/jinzhu/now v1.0.1/go.mod h1:d3SSVoowX0Lcu0IBviAWJpolVfI5UJVZZ7cO71lE/z8= +github.com/jinzhu/now v1.1.1 h1:g39TucaRWyV3dwDO++eEc6qf8TVIQ/Da48WmqjZ3i7E= github.com/jinzhu/now v1.1.1/go.mod h1:d3SSVoowX0Lcu0IBviAWJpolVfI5UJVZZ7cO71lE/z8= -github.com/joho/godotenv v1.3.0 h1:Zjp+RcGpHhGlrMbJzXTrZZPrWj+1vfm90La1wgB6Bhc= -github.com/joho/godotenv v1.3.0/go.mod h1:7hK45KPybAkOC6peb+G5yklZfMxEjkZhHbwpqxOKXbg= github.com/jonboulle/clockwork v0.1.0/go.mod h1:Ii8DK3G1RaLaWxj9trq07+26W01tbo22gdxWY5EU2bo= github.com/json-iterator/go v1.1.6 h1:MrUvLMLTMxbqFJ9kzlvat/rYZqZnW3u4wkLzWTaFwKs= github.com/json-iterator/go v1.1.6/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU= github.com/json-iterator/go v1.1.9/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4= +github.com/jtolds/gls v4.20.0+incompatible h1:xdiiI2gbIgH/gLH7ADydsJ1uDOEzR8yvV7C0MuV77Wo= github.com/jtolds/gls v4.20.0+incompatible/go.mod h1:QJZ7F/aHp+rZTRtaJ1ow/lLfFfVYBRgL+9YlvaHOwJU= github.com/juju/errors v0.0.0-20181118221551-089d3ea4e4d5/go.mod h1:W54LbzXuIE0boCoNJfwqpmkKJ1O4TCTZMetAt6jGk7Q= github.com/juju/loggo v0.0.0-20180524022052-584905176618/go.mod h1:vgyd7OREkbtVEN/8IXZe5Ooef3LQePvuBm9UWj6ZL8U= @@ -177,7 +169,6 @@ github.com/kataras/neffos v0.0.10/go.mod h1:ZYmJC07hQPW67eKuzlfY7SO3bC0mw83A3j6i github.com/kataras/pio v0.0.0-20190103105442-ea782b38602d h1:V5Rs9ztEWdp58oayPq/ulmlqJJZeJP6pP79uP3qjcao= github.com/kataras/pio v0.0.0-20190103105442-ea782b38602d/go.mod h1:NV88laa9UiiDuX9AhMbDPkGYSPugBOV6yTZB1l2K9Z0= github.com/kisielk/errcheck v1.1.0/go.mod h1:EZBBE59ingxPouuu3KfxchcWSUPOHkagtvWXihfKN4Q= -github.com/kisielk/errcheck v1.2.0/go.mod h1:/BMXB+zMLi60iA8Vv6Ksmxu/1UDYcXs4uQLJ+jE2L00= github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= github.com/klauspost/compress v1.8.2/go.mod h1:RyIbtBH6LamlWaDj8nUwkbUhJ87Yi3uG0guNDohfE1A= github.com/klauspost/compress v1.9.0 h1:GhthINjveNZAdFUD8QoQYfjxnOONZgztK/Yr6M23UTY= @@ -189,6 +180,7 @@ github.com/kr/logfmt v0.0.0-20140226030751-b84e30acd515/go.mod h1:+0opPa2QZZtGFB github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= +github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= github.com/labstack/echo/v4 v4.1.11/go.mod h1:i541M3Fj6f76NZtHSj7TXnyM8n2gaodfvfxNnFqi74g= github.com/labstack/gommon v0.3.0/go.mod h1:MULnywXg0yavhxWKc+lOruYdAhDwPK9wf0OL7NoOu+k= @@ -230,6 +222,7 @@ github.com/mwitkow/go-conntrack v0.0.0-20161129095857-cc309e4a2223/go.mod h1:qRW github.com/nats-io/nats.go v1.8.1/go.mod h1:BrFz9vVn0fU3AcH9Vn4Kd7W0NpJ651tD5omQ3M8LwxM= github.com/nats-io/nkeys v0.0.2/go.mod h1:dab7URMsZm6Z/jp9Z5UGa87Uutgc2mVpXLC4B7TDb/4= github.com/nats-io/nuid v1.0.1/go.mod h1:19wcPz3Ph3q0Jbyiqsd0kePYG7A95tJPxeL+1OSON2c= +github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e h1:fD57ERR4JtEqsWbfPhv4DMiApHyliiK5xCTNVSPiaAs= github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e/go.mod h1:zD1mROLANZcx1PVRCS0qkT7pwLkGfwJo4zjcN/Tysno= github.com/nkovacs/streamquote v0.0.0-20170412213628-49af9bddb229 h1:E2B8qYyeSgv5MXpmzZXRNp8IAQ4vjxIjhpAf5hv/tAg= github.com/nkovacs/streamquote v0.0.0-20170412213628-49af9bddb229/go.mod h1:0aYXnNPJ8l7uZxf45rWW1a/uME32OF0rhiYGNQ2oF2E= @@ -251,22 +244,14 @@ github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZb github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/prometheus/client_golang v0.9.1/go.mod h1:7SWBe2y4D6OKWSNQJUaRYU/AaXPKyh/dDVn+NZz0KFw= github.com/prometheus/client_golang v0.9.3/go.mod h1:/TN21ttK/J9q6uSwhBd54HahCDft0ttaMvbicHlPoso= -github.com/prometheus/client_golang v1.0.0/go.mod h1:db9x61etRT2tGnBNRi70OPL5FsnadC4Ky3P0J6CfImo= github.com/prometheus/client_model v0.0.0-20180712105110-5c3871d89910/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo= github.com/prometheus/client_model v0.0.0-20190129233127-fd36f4220a90/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= -github.com/prometheus/client_model v0.2.0/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= github.com/prometheus/common v0.0.0-20181113130724-41aa239b4cce/go.mod h1:daVV7qP5qjZbuso7PdcryaAu0sAZbrN9i7WWcTMWvro= github.com/prometheus/common v0.4.0/go.mod h1:TNfzLD0ON7rHzMJeJkieUDPYmFC7Snx/y86RQel1bk4= -github.com/prometheus/common v0.4.1/go.mod h1:TNfzLD0ON7rHzMJeJkieUDPYmFC7Snx/y86RQel1bk4= -github.com/prometheus/common v0.9.1 h1:KOMtN28tlbam3/7ZKEYKHhKoJZYYj3gMH4uc62x7X7U= -github.com/prometheus/common v0.9.1/go.mod h1:yhUN8i9wzaXS3w1O07YhxHEBxD+W35wd8bs7vj7HSQ4= github.com/prometheus/procfs v0.0.0-20181005140218-185b4288413d/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk= github.com/prometheus/procfs v0.0.0-20190507164030-5867b95ac084/go.mod h1:TjEm7ze935MbeOT/UhFTIMYKhuLP4wbCsTZCD3I8kEA= -github.com/prometheus/procfs v0.0.2/go.mod h1:TjEm7ze935MbeOT/UhFTIMYKhuLP4wbCsTZCD3I8kEA= github.com/prometheus/tsdb v0.7.1/go.mod h1:qhTCs0VvXwvX/y3TZrWD7rabWM+ijKTux40TwIPHuXU= -github.com/rendon/testcli v0.0.0-20161027181003-6283090d169f h1:onGP+qmYmjKs7pkmi9j0mwyr97/D5wki80e74aKIOxg= -github.com/rendon/testcli v0.0.0-20161027181003-6283090d169f/go.mod h1:cq57a4l475CeMvE7RRpSui1MEqCmhirIt1E7kl8BC2Q= github.com/rogpeppe/fastuuid v0.0.0-20150106093220-6724a57986af/go.mod h1:XWv6SoW27p1b0cqNHllgS5HIMJraePCO15w5zCzIWYg= github.com/russross/blackfriday v1.5.2 h1:HyvC0ARfnZBqnXwABFeSZHpKvJHJJfPz81GNueLj0oo= github.com/russross/blackfriday v1.5.2/go.mod h1:JO/DiYxRf+HjHt06OyowR9PTA263kcR/rfWxYHBV53g= @@ -279,9 +264,9 @@ github.com/shurcooL/sanitized_anchor_name v1.0.0/go.mod h1:1NzhyTcUVG4SuEtjjoZeV github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo= github.com/sirupsen/logrus v1.4.2 h1:SPIRibHv4MatM3XXNO2BJeFLZwZ2LvZgfQ5+UNI2im4= github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE= -github.com/skratchdot/open-golang v0.0.0-20200116055534-eef842397966 h1:JIAuq3EEf9cgbU6AtGPK4CTG3Zf6CKMNqf0MHTggAUA= -github.com/skratchdot/open-golang v0.0.0-20200116055534-eef842397966/go.mod h1:sUM3LWHvSMaG192sy56D9F7CNvL7jUJVXoqM1QKLnog= +github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d h1:zE9ykElWQ6/NYmHa3jpm/yHnI4xSofP+UP6SpjHcSeM= github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d/go.mod h1:OnSkiWE9lh6wB0YB77sQom3nweQdgAjqCqsofrRNTgc= +github.com/smartystreets/goconvey v1.6.4 h1:fv0U8FUIMPNf1L9lnHLvLhgicrIVChEkdzIKYqbNC9s= github.com/smartystreets/goconvey v1.6.4/go.mod h1:syvi0/a8iFYH4r/RixwvyeAJjdLS9QV7WQ/tjFTllLA= github.com/soheilhy/cmux v0.1.4/go.mod h1:IM3LyeVVIOuxMH7sFAkER9+bJ4dT7Ms6E4xg4kGIyLM= github.com/spaolacci/murmur3 v0.0.0-20180118202830-f09979ecbc72/go.mod h1:JwIasOWyU6f++ZhiEuf87xNszmSA2myDM2Kzu9HwQUA= @@ -318,11 +303,8 @@ github.com/stretchr/testify v1.5.1 h1:nOGnQDM7FYENwehXlg/kFVnos3rEvtKTjRvOWSzb6H github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA= github.com/subosito/gotenv v1.2.0 h1:Slr1R9HxAlEKefgq5jn9U+DnETlIUa6HfgEzj0g5d7s= github.com/subosito/gotenv v1.2.0/go.mod h1:N0PQaV/YGNqwC0u51sEeR/aUtSLEXKX9iv69rRypqCw= -github.com/t-tiger/gorm-bulk-insert v1.3.0 h1:9k7BaVEhw/3fsvh6GTOBwJ2RXk3asc5xs5m6hwozq20= github.com/t-tiger/gorm-bulk-insert/v2 v2.0.1 h1:HGVkRrwDCbmSP6h1CoBDj6l/mhnvsP5JbYaQ4ss0R6o= github.com/t-tiger/gorm-bulk-insert/v2 v2.0.1/go.mod h1:I3xbaE9ud9/TEXzehwkHx86SyJwqeSNsX2X5oV61jIg= -github.com/tatsushid/go-fastping v0.0.0-20160109021039-d7bb493dee3e h1:nt2877sKfojlHCTOBXbpWjBkuWKritFaGIfgQwbQUls= -github.com/tatsushid/go-fastping v0.0.0-20160109021039-d7bb493dee3e/go.mod h1:B4+Kq1u5FlULTjFSM707Q6e/cOHFv0z/6QRoxubDIQ8= github.com/tmc/grpc-websocket-proxy v0.0.0-20190109142713-0ad062ec5ee5/go.mod h1:ncp9v5uamzpCO7NfCPTXjqaC+bZgJeR0sMTm6dMHP7U= github.com/ugorji/go v1.1.4/go.mod h1:uQMGLiO92mf5W77hV/PUCpI3pbzQx3CRekS0kk+RGrc= github.com/ugorji/go v1.1.7/go.mod h1:kZn38zHttfInRq0xu/PH0az30d+z6vm202qpg1oXVMw= @@ -344,7 +326,6 @@ github.com/yalp/jsonpath v0.0.0-20180802001716-5cc68e5049a0/go.mod h1:/LWChgwKmv github.com/yudai/gojsondiff v1.0.0/go.mod h1:AY32+k2cwILAkW1fbgxQ5mUmMiZFgLIV+FBNExI05xg= github.com/yudai/golcs v0.0.0-20170316035057-ecda9a501e82/go.mod h1:lgjkn3NuSvDfVJdfcVVdX+jpBxNmX4rDAzaS45IcYoM= github.com/yudai/pp v2.0.1+incompatible/go.mod h1:PuxR/8QJ7cyCkFp/aUDS+JY727OFEZkTdatxwunjIkc= -github.com/yuin/goldmark v1.1.25/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= go.etcd.io/bbolt v1.3.2/go.mod h1:IbVyRI1SCnLcuJnV2u8VeU0CEYM7e686BmAb1XKL+uU= go.uber.org/atomic v1.4.0/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE= go.uber.org/multierr v1.1.0/go.mod h1:wR5kodmAFQ0UK8QlbwjlSNy0Z68gJhDJUG5sjR94q/0= @@ -354,17 +335,13 @@ golang.org/x/crypto v0.0.0-20181203042331-505ab145d0a9/go.mod h1:6SG95UA2DQfeDnf golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20190325154230-a5d413f7728c/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20190701094942-4def268fd1a4/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= -golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20191205180655-e7c4368fe9dd/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= -golang.org/x/crypto v0.0.0-20200320181102-891825fb96df h1:lDWgvUvNnaTnNBc/dwOty86cFeKoKWbwy2wQj0gIxbU= -golang.org/x/crypto v0.0.0-20200320181102-891825fb96df/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20200406173513-056763e48d71 h1:DOmugCavvUtnUD114C1Wh+UgTgQZ4pMLzXxi1pSt+/Y= golang.org/x/crypto v0.0.0-20200406173513-056763e48d71/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU= golang.org/x/lint v0.0.0-20190313153728-d0100b6bd8b3/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= -golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= @@ -376,7 +353,6 @@ golang.org/x/net v0.0.0-20190327091125-710a502c58a2/go.mod h1:t9HGtf8HONx5eT2rtn golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190503192946-f4e77d36d62c/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190522155817-f3200d17e092/go.mod h1:HSz+uSET+XFnRR8LxR5pz3Of3rY3CfYBVs4xY44aLks= -golang.org/x/net v0.0.0-20190613194153-d28f0bde5980/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20190827160401-ba9fcec4b297 h1:k7pJ2yAPLPgbskkFdhRCsA77k2fySZ1zf2zCjvQCiIM= golang.org/x/net v0.0.0-20190827160401-ba9fcec4b297/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= @@ -388,7 +364,6 @@ golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJ golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= @@ -412,7 +387,6 @@ golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/tools v0.0.0-20180221164845-07fd8470d635/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= -golang.org/x/tools v0.0.0-20181030221726-6c7e314b6563/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20181221001348-537d06c36207/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20190226205152-f727befe758c/go.mod h1:9Yl7xja0Znq3iFh3HoIrodX9oNMXvdceNzlUR8zjMvY= @@ -420,11 +394,6 @@ golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3 golang.org/x/tools v0.0.0-20190327201419-c70d86f8b7cf/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= golang.org/x/tools v0.0.0-20190328211700-ab21143f2384/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= golang.org/x/tools v0.0.0-20190524140312-2c0ae7006135/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= -golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= -golang.org/x/tools v0.0.0-20200321014904-268ba720d32c h1:Qp5jXmUCqMiVq4676uW7bY2oskIR1ivTboSMn8qgeX0= -golang.org/x/tools v0.0.0-20200321014904-268ba720d32c/go.mod h1:Sl4aGygMT6LrqrWclx+PTx3U+LnKx/seiNR+3G19Ar8= -golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543 h1:E7g+9GITq07hpfrRu66IVDexMakfv52eLZ2CXBWiKr4= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM= @@ -446,6 +415,7 @@ gopkg.in/alexcesaro/quotedprintable.v3 v3.0.0-20150716171945-2caba252f4dc/go.mod gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f h1:BLraFXnmrev5lT+xlilqcH8XK9/i0At2xKjWk4p6zsU= gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys= gopkg.in/go-playground/assert.v1 v1.2.1/go.mod h1:9RXL0bg/zibRAgZUYszZSwO/z8Y/a8bDuhia5mkpMnE= diff --git a/types/services/methods.go b/types/services/methods.go index 471f58f9..286f876b 100644 --- a/types/services/methods.go +++ b/types/services/methods.go @@ -20,7 +20,7 @@ import ( const limitedFailures = 25 func (s *Service) LoadTLSCert() (*tls.Config, error) { - if !s.TLSCert.Valid && !s.TLSCertKey.Valid { + if s.TLSCert.String == "" || s.TLSCertKey.String == "" { return nil, nil } @@ -38,22 +38,27 @@ func (s *Service) LoadTLSCert() (*tls.Config, error) { return nil, errors.Wrap(err, "issue loading X509KeyPair") } - // create Root CA pool or use Root CA provided - chainFile := s.TLSCert.String - if s.TLSCertRoot.String != "" { - chainFile = s.TLSCertRoot.String + config := &tls.Config{ + Certificates: []tls.Certificate{cert}, + InsecureSkipVerify: s.TLSCertRoot.String == "", } - caCert, err := ioutil.ReadFile(chainFile) + + if s.TLSCertRoot.String == "" { + return config, nil + } + + // create Root CA pool or use Root CA provided + rootCA := s.TLSCertRoot.String + caCert, err := ioutil.ReadFile(rootCA) if err != nil { - return nil, errors.Wrap(err, "issue reading cert file: "+chainFile) + return nil, errors.Wrap(err, "issue reading root CA file: "+rootCA) } caCertPool := x509.NewCertPool() caCertPool.AppendCertsFromPEM(caCert) - return &tls.Config{ - RootCAs: caCertPool, - Certificates: []tls.Certificate{cert}, - }, nil + config.RootCAs = caCertPool + + return config, nil } func (s *Service) Duration() time.Duration { diff --git a/types/services/routine.go b/types/services/routine.go index d4351172..b9e1f13c 100644 --- a/types/services/routine.go +++ b/types/services/routine.go @@ -15,7 +15,6 @@ import ( "github.com/statping/statping/types/failures" "github.com/statping/statping/types/hits" "github.com/statping/statping/utils" - "github.com/tatsushid/go-fastping" ) // checkServices will start the checking go routine for each service @@ -90,35 +89,23 @@ func isIPv6(address string) bool { } // checkIcmp will send a ICMP ping packet to the service -func CheckIcmp(s *Service, record bool) *Service { +func CheckIcmp(s *Service, record bool) (*Service, error) { defer s.updateLastCheck() - p := fastping.NewPinger() - resolveIP := "ip4:icmp" - if isIPv6(s.Domain) { - resolveIP = "ip6:icmp" - } - ra, err := net.ResolveIPAddr(resolveIP, s.Domain) + err := utils.Ping(s.Domain, s.Timeout) if err != nil { - recordFailure(s, fmt.Sprintf("Could not send ICMP to service %v, %v", s.Domain, err)) - return s - } - p.AddIPAddr(ra) - p.OnRecv = func(addr *net.IPAddr, rtt time.Duration) { - s.Latency = rtt.Microseconds() - recordSuccess(s) - } - err = p.Run() - if err != nil { - recordFailure(s, fmt.Sprintf("Issue running ICMP to service %v, %v", s.Domain, err)) - return s + if record { + recordFailure(s, fmt.Sprintf("Could not send ICMP to service %v, %v", s.Domain, err)) + } + return s, err } s.LastResponse = "" - return s + s.Online = true + return s, nil } // CheckGrpc will check a gRPC service -func CheckGrpc(s *Service, record bool) *Service { +func CheckGrpc(s *Service, record bool) (*Service, error) { defer s.updateLastCheck() dnsLookup, err := dnsCheck(s) @@ -126,7 +113,7 @@ func CheckGrpc(s *Service, record bool) *Service { if record { recordFailure(s, fmt.Sprintf("Could not get IP address for GRPC service %v, %v", s.Domain, err)) } - return s + return s, err } s.PingTime = dnsLookup t1 := utils.Now() @@ -145,25 +132,26 @@ func CheckGrpc(s *Service, record bool) *Service { if record { recordFailure(s, fmt.Sprintf("Dial Error %v", err)) } - return s + return s, err } if err := conn.Close(); err != nil { if record { recordFailure(s, fmt.Sprintf("%v Socket Close Error %v", strings.ToUpper(s.Type), err)) } - return s + return s, err } t2 := utils.Now() s.Latency = t2.Sub(t1).Microseconds() s.LastResponse = "" + s.Online = true if record { recordSuccess(s) } - return s + return s, nil } // checkTcp will check a TCP service -func CheckTcp(s *Service, record bool) *Service { +func CheckTcp(s *Service, record bool) (*Service, error) { defer s.updateLastCheck() dnsLookup, err := dnsCheck(s) @@ -171,7 +159,7 @@ func CheckTcp(s *Service, record bool) *Service { if record { recordFailure(s, fmt.Sprintf("Could not get IP address for TCP service %v, %v", s.Domain, err)) } - return s + return s, err } s.PingTime = dnsLookup t1 := utils.Now() @@ -188,22 +176,28 @@ func CheckTcp(s *Service, record bool) *Service { log.Errorln(err) } + // test TCP connection if there is no TLS Certificate set if s.TLSCert.String == "" { - conn, err := net.Dial(s.Type, domain) + conn, err := net.DialTimeout(s.Type, domain, time.Duration(s.Timeout)*time.Second) if err != nil { if record { recordFailure(s, fmt.Sprintf("Dial Error: %v", err)) } - return s + return s, err } defer conn.Close() } else { - conn, err := tls.DialWithDialer(&net.Dialer{Timeout: time.Duration(s.Timeout) * time.Second}, s.Type, domain, tlsConfig) + // test TCP connection if TLS Certificate was set + dialer := &net.Dialer{ + KeepAlive: time.Duration(s.Timeout) * time.Second, + Timeout: time.Duration(s.Timeout) * time.Second, + } + conn, err := tls.DialWithDialer(dialer, s.Type, domain, tlsConfig) if err != nil { if record { recordFailure(s, fmt.Sprintf("Dial Error: %v", err)) } - return s + return s, err } defer conn.Close() } @@ -211,10 +205,11 @@ func CheckTcp(s *Service, record bool) *Service { t2 := utils.Now() s.Latency = t2.Sub(t1).Microseconds() s.LastResponse = "" + s.Online = true if record { recordSuccess(s) } - return s + return s, nil } func (s *Service) updateLastCheck() { @@ -222,7 +217,7 @@ func (s *Service) updateLastCheck() { } // checkHttp will check a HTTP service -func CheckHttp(s *Service, record bool) *Service { +func CheckHttp(s *Service, record bool) (*Service, error) { defer s.updateLastCheck() dnsLookup, err := dnsCheck(s) @@ -230,7 +225,7 @@ func CheckHttp(s *Service, record bool) *Service { if record { recordFailure(s, fmt.Sprintf("Could not get IP address for domain %v, %v", s.Domain, err)) } - return s + return s, err } s.PingTime = dnsLookup t1 := utils.Now() @@ -282,7 +277,7 @@ func CheckHttp(s *Service, record bool) *Service { if record { recordFailure(s, fmt.Sprintf("HTTP Error %v", err)) } - return s + return s, err } t2 := utils.Now() s.Latency = t2.Sub(t1).Microseconds() @@ -298,19 +293,20 @@ func CheckHttp(s *Service, record bool) *Service { if record { recordFailure(s, fmt.Sprintf("HTTP Response Body did not match '%v'", s.Expected)) } - return s + return s, err } } if s.ExpectedStatus != res.StatusCode { if record { recordFailure(s, fmt.Sprintf("HTTP Status Code %v did not match %v", res.StatusCode, s.ExpectedStatus)) } - return s + return s, err } if record { recordSuccess(s) } - return s + s.Online = true + return s, err } // recordSuccess will create a new 'hit' record in the database for a successful/online service diff --git a/types/services/services_test.go b/types/services/services_test.go index 73b2e0b6..a69727ed 100644 --- a/types/services/services_test.go +++ b/types/services/services_test.go @@ -1,7 +1,10 @@ package services import ( + "context" + "crypto/tls" "fmt" + "github.com/gorilla/mux" "github.com/statping/statping/database" "github.com/statping/statping/types/checkins" "github.com/statping/statping/types/failures" @@ -10,6 +13,10 @@ import ( "github.com/statping/statping/utils" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" + "google.golang.org/grpc" + pb "google.golang.org/grpc/examples/route_guide/routeguide" + "net" + "net/http" "testing" "time" ) @@ -77,6 +84,83 @@ var fail2 = &failures.Failure{ CreatedAt: utils.Now().Add(-5 * time.Second), } +type exampleGRPC struct { + pb.UnimplementedRouteGuideServer +} + +func (s *exampleGRPC) GetFeature(ctx context.Context, point *pb.Point) (*pb.Feature, error) { + return &pb.Feature{Location: point}, nil +} + +func TestStartExampleEndpoints(t *testing.T) { + // root CA for Linux: /etc/ssl/certs/ca-certificates.crt + // root CA for MacOSX: /opt/local/share/curl/curl-ca-bundle.crt + + tlsCert := utils.Params.GetString("STATPING_DIR") + "/cert.pem" + tlsCertKey := utils.Params.GetString("STATPING_DIR") + "/key.pem" + + require.FileExists(t, tlsCert) + require.FileExists(t, tlsCertKey) + + h := func(w http.ResponseWriter, r *http.Request) { + w.WriteHeader(http.StatusOK) + w.Write([]byte("ok")) + } + + r := mux.NewRouter() + r.HandleFunc("/", h) + + // start example HTTP server + go func(t *testing.T) { + require.Nil(t, http.ListenAndServe(":15000", r)) + }(t) + + // start example TLS HTTP server + go func(t *testing.T) { + require.Nil(t, http.ListenAndServeTLS(":15001", tlsCert, tlsCertKey, r)) + }(t) + + tcpHandle := func(conn net.Conn) { + defer conn.Close() + conn.Write([]byte("ok")) + } + + // start TCP server + go func(t *testing.T, hdl func(conn net.Conn)) { + ln, err := net.Listen("tcp", ":15002") + require.Nil(t, err) + for { + conn, err := ln.Accept() + require.Nil(t, err) + go hdl(conn) + } + }(t, tcpHandle) + + // start TLS TCP server + go func(t *testing.T, hdl func(conn net.Conn)) { + cer, err := tls.LoadX509KeyPair(tlsCert, tlsCertKey) + require.Nil(t, err) + ln, err := tls.Listen("tcp", ":15003", &tls.Config{Certificates: []tls.Certificate{cer}}) + require.Nil(t, err) + for { + conn, err := ln.Accept() + require.Nil(t, err) + go hdl(conn) + } + }(t, tcpHandle) + + // start GRPC server + go func(t *testing.T) { + list, err := net.Listen("tcp", ":15004") + require.Nil(t, err) + grpcServer := grpc.NewServer() + pb.RegisterRouteGuideServer(grpcServer, &exampleGRPC{}) + require.Nil(t, grpcServer.Serve(list)) + }(t) + + time.Sleep(15 * time.Second) +} + func TestServices(t *testing.T) { db, err := database.OpenTester() require.Nil(t, err) @@ -93,6 +177,9 @@ func TestServices(t *testing.T) { hits.SetDB(db) SetDB(db) + tlsCert := utils.Params.GetString("STATPING_DIR") + "/cert.pem" + tlsCertKey := utils.Params.GetString("STATPING_DIR") + "/key.pem" + t.Run("Test Find service", func(t *testing.T) { item, err := Find(1) require.Nil(t, err) @@ -102,6 +189,146 @@ func TestServices(t *testing.T) { assert.NotZero(t, item.LastCheck) }) + t.Run("Test HTTP Check", func(t *testing.T) { + e := &Service{ + Name: "Example HTTP", + Domain: "http://localhost:15000", + ExpectedStatus: 200, + Type: "http", + Method: "GET", + Timeout: 5, + VerifySSL: null.NewNullBool(false), + } + e, err = CheckHttp(e, false) + require.Nil(t, err) + assert.True(t, e.Online) + assert.False(t, e.LastCheck.IsZero()) + assert.NotEqual(t, 0, e.PingTime) + assert.NotEqual(t, 0, e.Latency) + }) + + t.Run("Test Load TLS Certificates", func(t *testing.T) { + e := &Service{ + Name: "Example TLS", + Domain: "http://localhost:15001", + ExpectedStatus: 200, + Type: "http", + Method: "GET", + Timeout: 5, + VerifySSL: null.NewNullBool(false), + TLSCert: null.NewNullString(tlsCert), + TLSCertKey: null.NewNullString(tlsCertKey), + } + customTLS, err := e.LoadTLSCert() + require.Nil(t, err) + + require.NotNil(t, customTLS) + assert.Nil(t, customTLS.RootCAs) + assert.NotNil(t, customTLS.Certificates) + assert.Equal(t, 1, len(customTLS.Certificates)) + }) + + t.Run("Test TLS HTTP Check", func(t *testing.T) { + e := &Service{ + Name: "Example TLS HTTP", + Domain: "https://localhost:15001", + ExpectedStatus: 200, + Type: "http", + Method: "GET", + Timeout: 15, + VerifySSL: null.NewNullBool(false), + TLSCert: null.NewNullString(tlsCert), + TLSCertKey: null.NewNullString(tlsCertKey), + } + e, err = CheckHttp(e, false) + require.Nil(t, err) + assert.True(t, e.Online) + assert.False(t, e.LastCheck.IsZero()) + assert.NotEqual(t, 0, e.PingTime) + assert.NotEqual(t, 0, e.Latency) + }) + + t.Run("Test TCP Check", func(t *testing.T) { + e := &Service{ + Name: "Example TCP", + Domain: "localhost", + Port: 15002, + Type: "tcp", + Timeout: 5, + } + e, err = CheckTcp(e, false) + require.Nil(t, err) + assert.True(t, e.Online) + assert.False(t, e.LastCheck.IsZero()) + assert.NotEqual(t, 0, e.PingTime) + assert.NotEqual(t, 0, e.Latency) + }) + + t.Run("Test TLS TCP Check", func(t *testing.T) { + e := &Service{ + Name: "Example TLS TCP", + Domain: "localhost", + Port: 15003, + Type: "tcp", + Timeout: 15, + TLSCert: null.NewNullString(tlsCert), + TLSCertKey: null.NewNullString(tlsCertKey), + } + e, err = CheckTcp(e, false) + require.Nil(t, err) + assert.True(t, e.Online) + assert.False(t, e.LastCheck.IsZero()) + assert.NotEqual(t, 0, e.PingTime) + assert.NotEqual(t, 0, e.Latency) + }) + + t.Run("Test UDP Check", func(t *testing.T) { + e := &Service{ + Name: "Example UDP", + Domain: "localhost", + Port: 15003, + Type: "udp", + Timeout: 5, + } + e, err = CheckTcp(e, false) + require.Nil(t, err) + assert.True(t, e.Online) + assert.False(t, e.LastCheck.IsZero()) + assert.NotEqual(t, 0, e.PingTime) + assert.NotEqual(t, 0, e.Latency) + }) + + t.Run("Test gRPC Check", func(t *testing.T) { + e := &Service{ + Name: "Example gRPC", + Domain: "localhost", + Port: 15004, + Type: "grpc", + Timeout: 5, + } + e, err = CheckGrpc(e, false) + require.Nil(t, err) + assert.True(t, e.Online) + assert.False(t, e.LastCheck.IsZero()) + assert.NotEqual(t, 0, e.PingTime) + assert.NotEqual(t, 0, e.Latency) + }) + + t.Run("Test ICMP Check", func(t *testing.T) { + e := &Service{ + Name: "Example ICMP", + Domain: "localhost", + Type: "icmp", + Timeout: 5, + } + e, err = CheckIcmp(e, false) + require.Nil(t, err) + assert.True(t, e.Online) + assert.False(t, e.LastCheck.IsZero()) + assert.NotEqual(t, 0, e.PingTime) + assert.NotEqual(t, 0, e.Latency) + }) + t.Run("Test All", func(t *testing.T) { items := All() assert.Len(t, items, 1) diff --git a/utils/utils_custom.go b/utils/utils_custom.go index 66252068..ffa6e8e0 100644 --- a/utils/utils_custom.go +++ b/utils/utils_custom.go @@ -4,8 +4,10 @@ package utils import ( "errors" + "fmt" "os" - "syscall" + "os/exec" + "strings" ) func DirWritable(path string) (bool, error) { @@ -22,13 +24,20 @@ func DirWritable(path string) (bool, error) { return false, errors.New("write permission bit is not set on this file for user") } - var stat syscall.Stat_t - if err = syscall.Stat(path, &stat); err != nil { - return false, errors.New("unable to get stat") - } - - if uint32(os.Geteuid()) != stat.Uid { - return false, errors.New("user doesn't have permission to write to this directory") - } return true, nil } + +func Ping(address string, secondsTimeout int) error { + ping, err := exec.LookPath("ping") + if err != nil { + return err + } + out, _, err := Command(ping, address, "-c 1", fmt.Sprintf("-W %v", secondsTimeout)) + if err != nil { + return err + } + if strings.Contains(out, "Destination Host Unreachable") { + return errors.New("destination host unreachable") + } + return nil +} diff --git a/utils/utils_windows.go b/utils/utils_windows.go index 3082b113..4119c0eb 100644 --- a/utils/utils_windows.go +++ b/utils/utils_windows.go @@ -1,3 +1,5 @@ +// +build windows + package utils import ( @@ -19,5 +21,28 @@ func DirWritable(path string) (bool, error) { return false, errors.New("write permission bit is not set on this file for user") } + var stat syscall.Stat_t + if err = syscall.Stat(path, &stat); err != nil { + return false, errors.New("unable to get stat") + } + + if uint32(os.Geteuid()) != stat.Uid { + return false, errors.New("user doesn't have permission to write to this directory") + } return true, nil } + +func Ping(address string, secondsTimeout int) error { + ping, err := exec.LookPath("ping") + if err != nil { + return err + } + out, _, err := Command(ping, address, "-n 1", fmt.Sprintf("-w %v", timeout*1000)) + if err != nil { + return err + } + if strings.Contains(out, "Destination Host Unreachable") { + return errors.New("destination host unreachable") + } + return nil +} From ad03ef545d1976bc4c6e150139af427473409e7e Mon Sep 17 00:00:00 2001 From: hunterlong Date: Thu, 21 May 2020 05:04:45 -0700 Subject: [PATCH 27/49] patch --- CHANGELOG.md | 3 +++ frontend/src/forms/Service.vue | 18 +++++++++--------- types/services/services_test.go | 6 +++--- version.txt | 2 +- 4 files changed, 16 insertions(+), 13 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c1b82933..722273a9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,6 @@ +# 0.90.43 (05-21-2020) +- Fixed service form loading + # 0.90.42 (05-20-2020) - Fixed TCP services that dont use TLS. diff --git a/frontend/src/forms/Service.vue b/frontend/src/forms/Service.vue index e3f2a267..33881e3d 100644 --- a/frontend/src/forms/Service.vue +++ b/frontend/src/forms/Service.vue @@ -271,9 +271,9 @@ notify_after: 2, public: true, use_tls: false, - tls_cert: "", - tls_cert_key: "", - tls_cert_root: "", + tls_cert: "", + tls_cert_key: "", + tls_cert_root: "", }, groups: [], } @@ -284,11 +284,10 @@ } }, watch: { - in_service () { - this.service = this.in_service - if (this.service.tls_cert) { - this.service.use_tls = true - } + in_service: function(n, o) { + if (this.service.tls_cert) { + this.service.use_tls = true + } } }, async mounted () { @@ -296,8 +295,9 @@ const groups = await Api.groups() this.$store.commit('setGroups', groups) } + this.service = this.in_service }, - methods: { + methods: { updatePermalink() { const a = 'àáâäæãåāăąçćčđďèéêëēėęěğǵḧîïíīįìłḿñńǹňôöòóœøōõőṕŕřßśšşșťțûüùúūǘůűųẃẍÿýžźż·/_,:;' const b = 'aaaaaaaaaacccddeeeeeeeegghiiiiiilmnnnnoooooooooprrsssssttuuuuuuuuuwxyyzzz------' diff --git a/types/services/services_test.go b/types/services/services_test.go index a69727ed..331e4792 100644 --- a/types/services/services_test.go +++ b/types/services/services_test.go @@ -399,10 +399,10 @@ func TestServices(t *testing.T) { item, err := Find(1) require.Nil(t, err) - count := item.HitsSince(utils.Now().Add(-30 * time.Second)) + count := item.HitsSince(utils.Now().Add(-60 * time.Second)) assert.Equal(t, 1, count.Count()) - count = item.HitsSince(utils.Now().Add(-180 * time.Second)) + count = item.HitsSince(utils.Now().Add(-360 * time.Second)) assert.Equal(t, 3, count.Count()) }) @@ -432,7 +432,7 @@ func TestServices(t *testing.T) { item, err := Find(1) require.Nil(t, err) - count := item.FailuresSince(utils.Now().Add(-6 * time.Second)) + count := item.FailuresSince(utils.Now().Add(-30 * time.Second)) assert.Equal(t, 1, count.Count()) count = item.FailuresSince(utils.Now().Add(-180 * time.Second)) diff --git a/version.txt b/version.txt index 991fa778..c51f8fca 100644 --- a/version.txt +++ b/version.txt @@ -1 +1 @@ -0.90.42 +0.90.43 From 8e3e5a8bae4b0612427017fab48fb678ebefb731 Mon Sep 17 00:00:00 2001 From: hunterlong Date: Thu, 21 May 2020 07:56:32 -0700 Subject: [PATCH 28/49] TLS form fix --- CHANGELOG.md | 2 +- frontend/src/forms/Service.vue | 43 ++++++++++++++++++++-------------- frontend/src/mixin.js | 3 +++ 3 files changed, 29 insertions(+), 19 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 722273a9..9afe9389 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,5 @@ # 0.90.43 (05-21-2020) -- Fixed service form loading +- Fixed service TLS checkbox form for edit and create # 0.90.42 (05-20-2020) - Fixed TCP services that dont use TLS. diff --git a/frontend/src/forms/Service.vue b/frontend/src/forms/Service.vue index 33881e3d..c4ef8a48 100644 --- a/frontend/src/forms/Service.vue +++ b/frontend/src/forms/Service.vue @@ -1,5 +1,5 @@