testing - removed notifier exports

pull/78/head
Hunter Long 2018-10-05 22:00:40 -07:00
parent c9cf9ecfa1
commit 2b2c08ce40
15 changed files with 121 additions and 538 deletions

View File

@ -84,9 +84,9 @@ coverage:
# generate documentation for Statup functions
docs:
godoc2md github.com/hunterlong/statup > servers/docs/README.md
gocov-html coverage.json > servers/docs/COVERAGE.html
revive -formatter stylish > servers/docs/LINT.md
godoc2md github.com/hunterlong/statup > dev/README.md
gocov-html coverage.json > dev/COVERAGE.html
revive -formatter stylish > dev/LINT.md
#
# Build binary for Statup
@ -191,7 +191,7 @@ dep:
dep ensure -vendor-only
# install all required golang dependecies
dev-deps: dep
dev-deps:
$(GOGET) -u github.com/jinzhu/gorm/...
$(GOGET) github.com/stretchr/testify/assert
$(GOGET) golang.org/x/tools/cmd/cover

View File

@ -394,6 +394,6 @@ func TestSelectCheckinMethods(t *testing.T) {
lastHit := first.Last()
assert.Equal(t, float64(10), first.Period().Seconds())
assert.Equal(t, float64(5), first.Grace().Seconds())
assert.Equal(t, time.Now().UTC().Day(), lastHit.CreatedAt.Day())
assert.Equal(t, time.Now().UTC().Day(), lastHit.CreatedAt.UTC().Day())
assert.Equal(t, "Just now", lastHit.Ago())
}

View File

@ -1,5 +1,5 @@
ARG VERSION
FROM golang:1.10.3-alpine
FROM golang:1.11-alpine
MAINTAINER "Hunter Long (https://github.com/hunterlong)"
# Statup 'test' image for running a full test using the production environment

View File

@ -1,139 +0,0 @@
INSERT INTO core (name,description,config,api_key,api_secret,style,footer,domain,version,migration_id,use_cdn) VALUES ('Awesome Status','This is from the seed file!','config.yml','d2fead3e459bd14f570cf08527175b88b32d7faa','e351393306ea245de5f9588cbe8627c74db007c6','','Created by Hunter Long','','',0,false);
INSERT INTO services (name,domain,check_type,method,port,expected,expected_status,check_interval,post_data,order_id,timeout,created_at) VALUES
('Google','https://google.com','http','GET',0,'',200,10,'',0,10,'2018-08-31 10:42:08'),
('Statup Github','https://github.com/hunterlong/statup','http','GET',0,'',200,30,'',0,20,'2018-08-31 10:42:08'),
('JSON Users Test','https://jsonplaceholder.typicode.com/users','http','GET',0,'',200,60,'',0,30,'2018-08-31 10:42:08'),
('JSON API Tester','https://jsonplaceholder.typicode.com/posts','http','POST',0,'(title)": "((\\"|[statup])*)"',201,30,'{ "title": "statup", "body": "bar", "userId": 19999 }',0,30,'2018-08-31 10:42:08'),
('Google DNS','8.8.8.8','tcp','',53,'',0,20,'',0,120,'2018-08-31 10:42:08'),
('The Bravery - An Honest Mistake','https://www.youtube.com/watch?v=O8vzbezVru4','http','GET',0,'',0,30,'',0,15,'2018-08-31 10:42:14'),
('Upper.io','https://upper.io/db.v3/','http','GET',0,'',0,30,'',0,15,'2018-08-31 10:42:14'),
('CoinApp Status','https://status.coinapp.io','http','GET',0,'',200,1,'',0,30,'2018-08-31 10:42:16'),
('Demo Page','https://demo.statup.io','http','GET',0,'',200,2,'',0,30,'2018-08-31 10:42:16'),
('Golang','https://golang.org','http','GET',0,'',200,3,'',0,30,'2018-08-31 10:42:16'),
('Github','https://github.com/hunterlong','http','GET',0,'',200,4,'',0,30,'2018-08-31 10:42:17'),
('Santa Monica','https://www.santamonica.com','http','GET',0,'',200,5,'',0,30,'2018-08-31 10:42:17'),
('Oeschs Die Dritten','https://www.oeschs-die-dritten.ch/en/','http','GET',0,'',200,6,'',0,30,'2018-08-31 10:42:18'),
('EtherScan.io','https://etherscan.io','http','GET',0,'',200,7,'',0,30,'2018-08-31 10:42:20'),
('Test Service 7','https://www.youtube.com/watch?v=ipvEIZMMILA','http','GET',0,'',200,8,'',0,30,'2018-08-31 10:42:20'),
('Test Service 8','https://www.youtube.com/watch?v=UdaYVxYF1Ok','http','GET',0,'',200,9,'',0,30,'2018-08-31 10:42:20'),
('Test Service 9','https://www.youtube.com/watch?v=yydZbVoCbn0&t=870s','http','GET',0,'',200,10,'',0,30,'2018-08-31 10:42:20'),
('Failing URL','http://failingdomainsarenofunatall.com','http','GET',0,'',200,11,'',0,30,'2018-08-31 10:42:20');
INSERT INTO users (username,password,email,api_key,api_secret,administrator,created_at) VALUES
('admin','$2a$14$Aye3yHae0ml6WRtvdgkRnO19OFze0IKF6IOHrdLpETtwLjnPelMUm','info@statup.io','27aa701119fb561d734eb4469cf13ba2550007e2','29de07014d32fbbbb80053ef3c19b464b2b72f64',1,'2018-08-31 10:42:07');
INSERT INTO hits (service,latency,created_at) VALUES
(5,0.006504081,'2018-08-29 10:42:08'),
(3,0.202164333,'2018-08-29 10:42:08'),
(4,0.376675172,'2018-08-29 10:42:09'),
(1,0.413912204,'2018-08-29 10:42:09'),
(1,0.473912204,'2018-08-29 10:42:09'),
(2,0.528427935,'2018-08-29 10:42:09'),
(6,0.11930188,'2018-08-29 10:42:09'),
(7,0.001062722,'2018-08-29 10:42:09'),
(7,0.004046882,'2018-08-29 10:42:09'),
(6,0.063360069,'2018-08-29 10:42:09'),
(8,0.168951416,'2018-08-29 10:42:16'),
(8,0.069032763,'2018-08-29 10:42:16'),
(9,0.47712966,'2018-08-29 10:42:16'),
(10,0.104510482,'2018-08-29 10:42:17'),
(10,0.062536146,'2018-08-29 10:42:17'),
(9,0.352823197,'2018-08-29 10:42:09'),
(8,0.38226374,'2018-08-29 10:42:09'),
(11,0.857324393,'2018-08-29 10:42:17'),
(12,0.113320285,'2018-08-29 10:42:18'),
(12,0.038532321,'2018-08-29 10:42:18'),
(8,0.123430059,'2018-08-29 10:42:18'),
(11,0.625290389,'2018-08-29 10:42:18'),
(1,0.091823417,'2018-08-29 10:42:18'),
(9,0.246651097,'2018-08-29 10:42:19'),
(8,0.222901604,'2018-08-29 10:42:19'),
(13,1.600367041,'2018-08-29 10:42:20'),
(10,0.050076397,'2018-08-29 10:42:20'),
(14,0.460363958,'2018-08-29 10:42:20'),
(8,0.252590543,'2018-08-29 10:42:20'),
(15,0.144109113,'2018-08-29 10:42:20'),
(15,0.059993314,'2018-08-29 10:42:20'),
(16,0.058810662,'2018-08-29 10:42:20'),
(17,0.061824594,'2018-08-29 10:42:20'),
(16,0.074584583,'2018-08-29 10:42:20'),
(17,0.057086551,'2018-08-29 10:42:20'),
(5,0.006504081,'2018-08-30 10:42:08'),
(3,0.202164333,'2018-08-30 10:42:08'),
(4,0.376675172,'2018-08-30 10:42:09'),
(1,0.413912204,'2018-08-30 10:42:09'),
(2,0.528427935,'2018-08-30 10:42:09'),
(6,0.11930188,'2018-08-30 10:42:14'),
(7,0.001062722,'2018-08-30 10:42:14'),
(7,0.004046882,'2018-08-30 10:42:14'),
(6,0.063360069,'2018-08-30 10:42:14'),
(8,0.168951416,'2018-08-30 10:42:16'),
(8,0.069032763,'2018-08-30 10:42:16'),
(9,0.47712966,'2018-08-30 10:42:16'),
(10,0.104510482,'2018-08-30 10:42:17'),
(10,0.062536146,'2018-08-30 10:42:17'),
(9,0.352823197,'2018-08-30 10:42:17'),
(8,0.38226374,'2018-08-30 10:42:17'),
(11,0.857324393,'2018-08-30 10:42:17'),
(12,0.113320285,'2018-08-30 10:42:18'),
(12,0.038532321,'2018-08-30 10:42:18'),
(8,0.123430059,'2018-08-30 10:42:18'),
(11,0.625290389,'2018-08-30 10:42:18'),
(1,0.091823417,'2018-08-30 10:42:18'),
(9,0.246651097,'2018-08-30 10:42:19'),
(8,0.222901604,'2018-08-30 10:42:19'),
(13,1.600367041,'2018-08-30 10:42:20'),
(10,0.050076397,'2018-08-30 10:42:20'),
(14,0.460363958,'2018-08-30 10:42:20'),
(8,0.252590543,'2018-08-30 10:42:20'),
(15,0.144109113,'2018-08-30 10:42:20'),
(15,0.059993314,'2018-08-30 10:42:20'),
(16,0.058810662,'2018-08-30 10:42:20'),
(17,0.061824594,'2018-08-30 10:42:20'),
(16,0.074584583,'2018-08-30 10:42:20'),
(17,0.057086551,'2018-08-30 10:42:20'),
(5,0.006504081,'2018-08-31 10:42:08'),
(3,0.202164333,'2018-08-31 10:42:08'),
(4,0.376675172,'2018-08-31 10:42:09'),
(1,0.413912204,'2018-08-31 10:42:09'),
(2,0.528427935,'2018-08-31 10:42:09'),
(6,0.11930188,'2018-08-31 10:42:14'),
(7,0.001062722,'2018-08-31 10:42:14'),
(7,0.004046882,'2018-08-31 10:42:14'),
(6,0.063360069,'2018-08-31 10:42:14'),
(8,0.168951416,'2018-08-31 10:42:16'),
(8,0.069032763,'2018-08-31 10:42:16'),
(9,0.47712966,'2018-08-31 10:42:16'),
(10,0.104510482,'2018-08-31 10:42:17'),
(10,0.062536146,'2018-08-31 10:42:17'),
(9,0.352823197,'2018-08-31 10:42:17'),
(8,0.38226374,'2018-08-31 10:42:17'),
(11,0.857324393,'2018-08-31 10:42:17'),
(12,0.113320285,'2018-08-31 10:42:18'),
(12,0.038532321,'2018-08-31 10:42:18'),
(8,0.123430059,'2018-08-31 10:42:18'),
(11,0.625290389,'2018-08-31 10:42:18'),
(1,0.091823417,'2018-08-31 10:42:18'),
(9,0.246651097,'2018-08-31 10:42:19'),
(8,0.222901604,'2018-08-31 10:42:19'),
(13,1.600367041,'2018-08-31 10:42:20'),
(10,0.050076397,'2018-08-31 10:42:20'),
(14,0.460363958,'2018-08-31 10:42:20'),
(8,0.252590543,'2018-08-31 10:42:20'),
(15,0.144109113,'2018-08-31 10:42:20'),
(15,0.059993314,'2018-08-31 10:42:20'),
(16,0.058810662,'2018-08-31 10:42:20'),
(17,0.061824594,'2018-08-31 10:42:20'),
(16,0.074584583,'2018-08-31 10:42:20'),
(17,0.057086551,'2018-08-31 10:42:20');
INSERT INTO failures (issue,method,service,created_at) VALUES
('HTTP Status Code 200 did not match 0','',18,'2018-08-28 10:42:14'),
('HTTP Status Code 200 did not match 0','',6,'2018-08-28 10:42:14'),
('HTTP Status Code 200 did not match 0','',6,'2018-08-29 10:42:14'),
('HTTP Status Code 200 did not match 0','',6,'2018-08-30 10:42:14'),
('Incorrect Response','',1,'2018-08-31 10:40:14'),
('HTTP Status Code 200 did not match 0','',6,'2018-08-31 10:42:14'),
('HTTP Status Code 200 did not match 0','',6,'2018-08-31 10:42:14'),
('HTTP Status Code 200 did not match 0','',18,'2018-08-31 10:42:14');
INSERT INTO notifications (id,method,host,port,username,password,var1,var2,api_key,api_secret,enabled,removable,limits,created_at) VALUES
(1,'email','smtp.emailer.com',587,'exampleuser','password123','info@betatude.com','sendto@gmail.com','','',1,0,7,'2018-08-31 10:42:15'),
(2,'slack','https://webhooksurl.slack.com/***',0,'','','','','','',0,0,3,'2018-08-31 10:42:08'),
(3,'twilio','',0,'','','','','','',0,0,3,'2018-08-31 10:42:08');

View File

@ -1,139 +0,0 @@
INSERT INTO core (name,description,config,api_key,api_secret,style,footer,domain,version,migration_id,use_cdn) VALUES ('Awesome Status','This is from the seed file!','config.yml','d2fead3e459bd14f570cf08527175b88b32d7faa','e351393306ea245de5f9588cbe8627c74db007c6','','Created by Hunter Long','DEV','',0,false);
INSERT INTO services (name,domain,check_type,method,port,expected,expected_status,check_interval,post_data,order_id,timeout,created_at) VALUES
('Google','https://google.com','http','GET',0,'',200,10,'',0,10,'2018-08-31 10:42:08.76390584-07:00'),
('Statup Github','https://github.com/hunterlong/statup','http','GET',0,'',200,30,'',0,20,'2018-08-31 10:42:08.764977938-07:00'),
('JSON Users Test','https://jsonplaceholder.typicode.com/users','http','GET',0,'',200,60,'',0,30,'2018-08-31 10:42:08.765794226-07:00'),
('JSON API Tester','https://jsonplaceholder.typicode.com/posts','http','POST',0,'(title)": "((\\"|[statup])*)"',201,30,'{ "title": "statup", "body": "bar", "userId": 19999 }',0,30,'2018-08-31 10:42:08.766542311-07:00'),
('Google DNS','8.8.8.8','tcp','',53,'',0,20,'',0,120,'2018-08-31 10:42:08.767327346-07:00'),
('The Bravery - An Honest Mistake','https://www.youtube.com/watch?v=O8vzbezVru4','http','GET',0,'',0,30,'',0,15,'2018-08-31 10:42:14.201305666-07:00'),
('Upper.io','https://upper.io/db.v3/','http','GET',0,'',0,30,'',0,15,'2018-08-31 10:42:14.201305666-07:00'),
('CoinApp Status','https://status.coinapp.io','http','GET',0,'',200,1,'',0,30,'2018-08-31 10:42:16.097416218-07:00'),
('Demo Page','https://demo.statup.io','http','GET',0,'',200,2,'',0,30,'2018-08-31 10:42:16.360051225-07:00'),
('Golang','https://golang.org','http','GET',0,'',200,3,'',0,30,'2018-08-31 10:42:16.923478722-07:00'),
('Github','https://github.com/hunterlong','http','GET',0,'',200,4,'',0,30,'2018-08-31 10:42:17.075544885-07:00'),
('Santa Monica','https://www.santamonica.com','http','GET',0,'',200,5,'',0,30,'2018-08-31 10:42:17.946947674-07:00'),
('Oeschs Die Dritten','https://www.oeschs-die-dritten.ch/en/','http','GET',0,'',200,6,'',0,30,'2018-08-31 10:42:18.083709297-07:00'),
('EtherScan.io','https://etherscan.io','http','GET',0,'',200,7,'',0,30,'2018-08-31 10:42:20.020969513-07:00'),
('Test Service 7','https://www.youtube.com/watch?v=ipvEIZMMILA','http','GET',0,'',200,8,'',0,30,'2018-08-31 10:42:20.50135711-07:00'),
('Test Service 8','https://www.youtube.com/watch?v=UdaYVxYF1Ok','http','GET',0,'',200,9,'',0,30,'2018-08-31 10:42:20.651218082-07:00'),
('Test Service 9','https://www.youtube.com/watch?v=yydZbVoCbn0&t=870s','http','GET',0,'',200,10,'',0,30,'2018-08-31 10:42:20.725479695-07:00'),
('Failing URL','http://failingdomainsarenofunatall.com','http','GET',0,'',200,11,'',0,30,'2018-08-31 10:42:20.799471402-07:00');
INSERT INTO users (username,password,email,api_key,api_secret,administrator,created_at) VALUES
('admin','$2a$14$Aye3yHae0ml6WRtvdgkRnO19OFze0IKF6IOHrdLpETtwLjnPelMUm','info@statup.io','27aa701119fb561d734eb4469cf13ba2550007e2','29de07014d32fbbbb80053ef3c19b464b2b72f64',true,'2018-08-31 10:42:07.684406458-07:00');
INSERT INTO hits (service,latency,created_at) VALUES
(5,0.006504081,'2018-08-29 10:42:08.779875117-07:00'),
(3,0.202164333,'2018-08-29 10:42:08.977187173-07:00'),
(4,0.376675172,'2018-08-29 10:42:09.151858662-07:00'),
(1,0.413912204,'2018-08-29 10:42:09.188850317-07:00'),
(1,0.473912204,'2018-08-29 10:42:10.118850317-07:00'),
(2,0.528427935,'2018-08-29 10:42:09.310642068-07:00'),
(6,0.11930188,'2018-08-29 10:42:14.133392018-07:00'),
(7,0.001062722,'2018-08-29 10:42:14.148258553-07:00'),
(7,0.004046882,'2018-08-29 10:42:14.156087817-07:00'),
(6,0.063360069,'2018-08-29 10:42:14.205383358-07:00'),
(8,0.168951416,'2018-08-29 10:42:16.346340211-07:00'),
(8,0.069032763,'2018-08-29 10:42:16.421634189-07:00'),
(9,0.47712966,'2018-08-29 10:42:16.91309317-07:00'),
(10,0.104510482,'2018-08-29 10:42:17.065673146-07:00'),
(10,0.062536146,'2018-08-29 10:42:17.134754949-07:00'),
(9,0.352823197,'2018-08-29 10:42:17.272174866-07:00'),
(8,0.38226374,'2018-08-29 10:42:17.738731999-07:00'),
(11,0.857324393,'2018-08-29 10:42:17.939738264-07:00'),
(12,0.113320285,'2018-08-29 10:42:18.073586363-07:00'),
(12,0.038532321,'2018-08-29 10:42:18.119730063-07:00'),
(8,0.123430059,'2018-08-29 10:42:18.479407581-07:00'),
(11,0.625290389,'2018-08-29 10:42:18.5715553-07:00'),
(1,0.091823417,'2018-08-29 10:42:18.868788983-07:00'),
(9,0.246651097,'2018-08-29 10:42:19.165697332-07:00'),
(8,0.222901604,'2018-08-29 10:42:19.57929225-07:00'),
(13,1.600367041,'2018-08-29 10:42:20.010203546-07:00'),
(10,0.050076397,'2018-08-29 10:42:20.12391038-07:00'),
(14,0.460363958,'2018-08-29 10:42:20.495937751-07:00'),
(8,0.252590543,'2018-08-29 10:42:20.609139136-07:00'),
(15,0.144109113,'2018-08-29 10:42:20.64756516-07:00'),
(15,0.059993314,'2018-08-29 10:42:20.710322678-07:00'),
(16,0.058810662,'2018-08-29 10:42:20.712087274-07:00'),
(17,0.061824594,'2018-08-29 10:42:20.791266761-07:00'),
(16,0.074584583,'2018-08-29 10:42:20.797581163-07:00'),
(17,0.057086551,'2018-08-29 10:42:20.854020864-07:00'),
(5,0.006504081,'2018-08-30 10:42:08.779875117-07:00'),
(3,0.202164333,'2018-08-30 10:42:08.977187173-07:00'),
(4,0.376675172,'2018-08-30 10:42:09.151858662-07:00'),
(1,0.413912204,'2018-08-30 10:42:09.188850317-07:00'),
(2,0.528427935,'2018-08-30 10:42:09.310642068-07:00'),
(6,0.11930188,'2018-08-30 10:42:14.133392018-07:00'),
(7,0.001062722,'2018-08-30 10:42:14.148258553-07:00'),
(7,0.004046882,'2018-08-30 10:42:14.156087817-07:00'),
(6,0.063360069,'2018-08-30 10:42:14.205383358-07:00'),
(8,0.168951416,'2018-08-30 10:42:16.346340211-07:00'),
(8,0.069032763,'2018-08-30 10:42:16.421634189-07:00'),
(9,0.47712966,'2018-08-30 10:42:16.91309317-07:00'),
(10,0.104510482,'2018-08-30 10:42:17.065673146-07:00'),
(10,0.062536146,'2018-08-30 10:42:17.134754949-07:00'),
(9,0.352823197,'2018-08-30 10:42:17.272174866-07:00'),
(8,0.38226374,'2018-08-30 10:42:17.738731999-07:00'),
(11,0.857324393,'2018-08-30 10:42:17.939738264-07:00'),
(12,0.113320285,'2018-08-30 10:42:18.073586363-07:00'),
(12,0.038532321,'2018-08-30 10:42:18.119730063-07:00'),
(8,0.123430059,'2018-08-30 10:42:18.479407581-07:00'),
(11,0.625290389,'2018-08-30 10:42:18.5715553-07:00'),
(1,0.091823417,'2018-08-30 10:42:18.868788983-07:00'),
(9,0.246651097,'2018-08-30 10:42:19.165697332-07:00'),
(8,0.222901604,'2018-08-30 10:42:19.57929225-07:00'),
(13,1.600367041,'2018-08-30 10:42:20.010203546-07:00'),
(10,0.050076397,'2018-08-30 10:42:20.12391038-07:00'),
(14,0.460363958,'2018-08-30 10:42:20.495937751-07:00'),
(8,0.252590543,'2018-08-30 10:42:20.609139136-07:00'),
(15,0.144109113,'2018-08-30 10:42:20.64756516-07:00'),
(15,0.059993314,'2018-08-30 10:42:20.710322678-07:00'),
(16,0.058810662,'2018-08-30 10:42:20.712087274-07:00'),
(17,0.061824594,'2018-08-30 10:42:20.791266761-07:00'),
(16,0.074584583,'2018-08-30 10:42:20.797581163-07:00'),
(17,0.057086551,'2018-08-30 10:42:20.854020864-07:00'),
(5,0.006504081,'2018-08-31 10:42:08.779875117-07:00'),
(3,0.202164333,'2018-08-31 10:42:08.977187173-07:00'),
(4,0.376675172,'2018-08-31 10:42:09.151858662-07:00'),
(1,0.413912204,'2018-08-31 10:42:09.188850317-07:00'),
(2,0.528427935,'2018-08-31 10:42:09.310642068-07:00'),
(6,0.11930188,'2018-08-31 10:42:14.133392018-07:00'),
(7,0.001062722,'2018-08-31 10:42:14.148258553-07:00'),
(7,0.004046882,'2018-08-31 10:42:14.156087817-07:00'),
(6,0.063360069,'2018-08-31 10:42:14.205383358-07:00'),
(8,0.168951416,'2018-08-31 10:42:16.346340211-07:00'),
(8,0.069032763,'2018-08-31 10:42:16.421634189-07:00'),
(9,0.47712966,'2018-08-31 10:42:16.91309317-07:00'),
(10,0.104510482,'2018-08-31 10:42:17.065673146-07:00'),
(10,0.062536146,'2018-08-31 10:42:17.134754949-07:00'),
(9,0.352823197,'2018-08-31 10:42:17.272174866-07:00'),
(8,0.38226374,'2018-08-31 10:42:17.738731999-07:00'),
(11,0.857324393,'2018-08-31 10:42:17.939738264-07:00'),
(12,0.113320285,'2018-08-31 10:42:18.073586363-07:00'),
(12,0.038532321,'2018-08-31 10:42:18.119730063-07:00'),
(8,0.123430059,'2018-08-31 10:42:18.479407581-07:00'),
(11,0.625290389,'2018-08-31 10:42:18.5715553-07:00'),
(1,0.091823417,'2018-08-31 10:42:18.868788983-07:00'),
(9,0.246651097,'2018-08-31 10:42:19.165697332-07:00'),
(8,0.222901604,'2018-08-31 10:42:19.57929225-07:00'),
(13,1.600367041,'2018-08-31 10:42:20.010203546-07:00'),
(10,0.050076397,'2018-08-31 10:42:20.12391038-07:00'),
(14,0.460363958,'2018-08-31 10:42:20.495937751-07:00'),
(8,0.252590543,'2018-08-31 10:42:20.609139136-07:00'),
(15,0.144109113,'2018-08-31 10:42:20.64756516-07:00'),
(15,0.059993314,'2018-08-31 10:42:20.710322678-07:00'),
(16,0.058810662,'2018-08-31 10:42:20.712087274-07:00'),
(17,0.061824594,'2018-08-31 10:42:20.791266761-07:00'),
(16,0.074584583,'2018-08-31 10:42:20.797581163-07:00'),
(17,0.057086551,'2018-08-31 10:42:20.854020864-07:00');
INSERT INTO failures (issue,method,service,created_at) VALUES
('HTTP Status Code 200 did not match 0','',18,'2018-08-28 10:42:14.271162743-07:00'),
('HTTP Status Code 200 did not match 0','',6,'2018-08-28 10:42:14.271162743-07:00'),
('HTTP Status Code 200 did not match 0','',6,'2018-08-29 10:42:14.271162743-07:00'),
('HTTP Status Code 200 did not match 0','',6,'2018-08-30 10:42:14.271162743-07:00'),
('Incorrect Response','',1,'2018-08-31 10:40:14.272209564-07:00'),
('HTTP Status Code 200 did not match 0','',6,'2018-08-31 10:42:14.271162743-07:00'),
('HTTP Status Code 200 did not match 0','',6,'2018-08-31 10:42:14.272209564-07:00'),
('HTTP Status Code 200 did not match 0','',18,'2018-08-31 10:42:14.271162743-07:00');
INSERT INTO notifications (id,method,host,port,username,password,var1,var2,api_key,api_secret,enabled,removable,limits,created_at) VALUES
(1,'email','smtp.emailer.com',587,'exampleuser','password123','info@betatude.com','sendto@gmail.com','','',true,false,7,'2018-08-31 10:42:15.000829706-07:00'),
(2,'slack','https://webhooksurl.slack.com/***',0,'','','','','','',false,false,3,'2018-08-31 10:42:08.775366824-07:00'),
(3,'twilio','',0,'','','','','','',false,false,3,'2018-08-31 10:42:08.776944923-07:00');

View File

@ -1,139 +0,0 @@
INSERT INTO core (name,description,config,api_key,api_secret,style,footer,domain,version,migration_id,use_cdn) VALUES ('Awesome Status','This is from the seed file!','config.yml','d2fead3e459bd14f570cf08527175b88b32d7faa','e351393306ea245de5f9588cbe8627c74db007c6','','Created by Hunter Long','','',0,0);
INSERT INTO services (id,name,domain,check_type,method,port,expected,expected_status,check_interval,post_data,order_id,timeout,created_at) VALUES
(1,'Google','https://google.com','http','GET',0,'',200,10,'',0,10,'2018-08-31 10:42:08.76390584-07:00'),
(2,'Statup Github','https://github.com/hunterlong/statup','http','GET',0,'',200,30,'',0,20,'2018-08-31 10:42:08.764977938-07:00'),
(3,'JSON Users Test','https://jsonplaceholder.typicode.com/users','http','GET',0,'',200,60,'',0,30,'2018-08-31 10:42:08.765794226-07:00'),
(4,'JSON API Tester','https://jsonplaceholder.typicode.com/posts','http','POST',0,'(title)": "((\\"|[statup])*)"',201,30,'{ "title": "statup", "body": "bar", "userId": 19999 }',0,30,'2018-08-31 10:42:08.766542311-07:00'),
(5,'Google DNS','8.8.8.8','tcp','',53,'',0,20,'',0,120,'2018-08-31 10:42:08.767327346-07:00'),
(6,'The Bravery - An Honest Mistake','https://www.youtube.com/watch?v=O8vzbezVru4','http','GET',0,'',0,30,'',0,15,'2018-08-31 10:42:14.201305666-07:00'),
(7,'Upper.io','https://upper.io/db.v3/','http','GET',0,'',0,30,'',0,15,'2018-08-31 10:42:14.201305666-07:00'),
(8,'CoinApp Status','https://status.coinapp.io','http','GET',0,'',200,1,'',0,30,'2018-08-31 10:42:16.097416218-07:00'),
(9,'Demo Page','https://demo.statup.io','http','GET',0,'',200,2,'',0,30,'2018-08-31 10:42:16.360051225-07:00'),
(10,'Golang','https://golang.org','http','GET',0,'',200,3,'',0,30,'2018-08-31 10:42:16.923478722-07:00'),
(11,'Github','https://github.com/hunterlong','http','GET',0,'',200,4,'',0,30,'2018-08-31 10:42:17.075544885-07:00'),
(12,'Santa Monica','https://www.santamonica.com','http','GET',0,'',200,5,'',0,30,'2018-08-31 10:42:17.946947674-07:00'),
(13,'Oeschs Die Dritten','https://www.oeschs-die-dritten.ch/en/','http','GET',0,'',200,6,'',0,30,'2018-08-31 10:42:18.083709297-07:00'),
(14,'EtherScan.io','https://etherscan.io','http','GET',0,'',200,7,'',0,30,'2018-08-31 10:42:20.020969513-07:00'),
(15,'Test Service 7','https://www.youtube.com/watch?v=ipvEIZMMILA','http','GET',0,'',200,8,'',0,30,'2018-08-31 10:42:20.50135711-07:00'),
(16,'Test Service 8','https://www.youtube.com/watch?v=UdaYVxYF1Ok','http','GET',0,'',200,9,'',0,30,'2018-08-31 10:42:20.651218082-07:00'),
(17,'Test Service 9','https://www.youtube.com/watch?v=yydZbVoCbn0&t=870s','http','GET',0,'',200,10,'',0,30,'2018-08-31 10:42:20.725479695-07:00'),
(18,'Failing URL','http://failingdomainsarenofunatall.com','http','GET',0,'',200,11,'',0,30,'2018-08-31 10:42:20.799471402-07:00');
INSERT INTO users (username,password,email,api_key,api_secret,administrator,created_at) VALUES
('admin','$2a$14$Aye3yHae0ml6WRtvdgkRnO19OFze0IKF6IOHrdLpETtwLjnPelMUm','info@statup.io','27aa701119fb561d734eb4469cf13ba2550007e2','29de07014d32fbbbb80053ef3c19b464b2b72f64',1,'2018-08-31 10:42:07.684406458-07:00');
INSERT INTO hits (service,latency,created_at) VALUES
(5,0.006504081,'2018-08-29 10:42:08.779875117-07:00'),
(3,0.202164333,'2018-08-29 10:42:08.977187173-07:00'),
(4,0.376675172,'2018-08-29 10:42:09.151858662-07:00'),
(1,0.413912204,'2018-08-29 10:42:09.188850317-07:00'),
(1,0.473912204,'2018-08-29 10:42:10.118850317-07:00'),
(2,0.528427935,'2018-08-29 10:42:09.310642068-07:00'),
(6,0.11930188,'2018-08-29 10:42:14.133392018-07:00'),
(7,0.001062722,'2018-08-29 10:42:14.148258553-07:00'),
(7,0.004046882,'2018-08-29 10:42:14.156087817-07:00'),
(6,0.063360069,'2018-08-29 10:42:14.205383358-07:00'),
(8,0.168951416,'2018-08-29 10:42:16.346340211-07:00'),
(8,0.069032763,'2018-08-29 10:42:16.421634189-07:00'),
(9,0.47712966,'2018-08-29 10:42:16.91309317-07:00'),
(10,0.104510482,'2018-08-29 10:42:17.065673146-07:00'),
(10,0.062536146,'2018-08-29 10:42:17.134754949-07:00'),
(9,0.352823197,'2018-08-29 10:42:17.272174866-07:00'),
(8,0.38226374,'2018-08-29 10:42:17.738731999-07:00'),
(11,0.857324393,'2018-08-29 10:42:17.939738264-07:00'),
(12,0.113320285,'2018-08-29 10:42:18.073586363-07:00'),
(12,0.038532321,'2018-08-29 10:42:18.119730063-07:00'),
(8,0.123430059,'2018-08-29 10:42:18.479407581-07:00'),
(11,0.625290389,'2018-08-29 10:42:18.5715553-07:00'),
(1,0.091823417,'2018-08-29 10:42:18.868788983-07:00'),
(9,0.246651097,'2018-08-29 10:42:19.165697332-07:00'),
(8,0.222901604,'2018-08-29 10:42:19.57929225-07:00'),
(13,1.600367041,'2018-08-29 10:42:20.010203546-07:00'),
(10,0.050076397,'2018-08-29 10:42:20.12391038-07:00'),
(14,0.460363958,'2018-08-29 10:42:20.495937751-07:00'),
(8,0.252590543,'2018-08-29 10:42:20.609139136-07:00'),
(15,0.144109113,'2018-08-29 10:42:20.64756516-07:00'),
(15,0.059993314,'2018-08-29 10:42:20.710322678-07:00'),
(16,0.058810662,'2018-08-29 10:42:20.712087274-07:00'),
(17,0.061824594,'2018-08-29 10:42:20.791266761-07:00'),
(16,0.074584583,'2018-08-29 10:42:20.797581163-07:00'),
(17,0.057086551,'2018-08-29 10:42:20.854020864-07:00'),
(5,0.006504081,'2018-08-30 10:42:08.779875117-07:00'),
(3,0.202164333,'2018-08-30 10:42:08.977187173-07:00'),
(4,0.376675172,'2018-08-30 10:42:09.151858662-07:00'),
(1,0.413912204,'2018-08-30 10:42:09.188850317-07:00'),
(2,0.528427935,'2018-08-30 10:42:09.310642068-07:00'),
(6,0.11930188,'2018-08-30 10:42:14.133392018-07:00'),
(7,0.001062722,'2018-08-30 10:42:14.148258553-07:00'),
(7,0.004046882,'2018-08-30 10:42:14.156087817-07:00'),
(6,0.063360069,'2018-08-30 10:42:14.205383358-07:00'),
(8,0.168951416,'2018-08-30 10:42:16.346340211-07:00'),
(8,0.069032763,'2018-08-30 10:42:16.421634189-07:00'),
(9,0.47712966,'2018-08-30 10:42:16.91309317-07:00'),
(10,0.104510482,'2018-08-30 10:42:17.065673146-07:00'),
(10,0.062536146,'2018-08-30 10:42:17.134754949-07:00'),
(9,0.352823197,'2018-08-30 10:42:17.272174866-07:00'),
(8,0.38226374,'2018-08-30 10:42:17.738731999-07:00'),
(11,0.857324393,'2018-08-30 10:42:17.939738264-07:00'),
(12,0.113320285,'2018-08-30 10:42:18.073586363-07:00'),
(12,0.038532321,'2018-08-30 10:42:18.119730063-07:00'),
(8,0.123430059,'2018-08-30 10:42:18.479407581-07:00'),
(11,0.625290389,'2018-08-30 10:42:18.5715553-07:00'),
(1,0.091823417,'2018-08-30 10:42:18.868788983-07:00'),
(9,0.246651097,'2018-08-30 10:42:19.165697332-07:00'),
(8,0.222901604,'2018-08-30 10:42:19.57929225-07:00'),
(13,1.600367041,'2018-08-30 10:42:20.010203546-07:00'),
(10,0.050076397,'2018-08-30 10:42:20.12391038-07:00'),
(14,0.460363958,'2018-08-30 10:42:20.495937751-07:00'),
(8,0.252590543,'2018-08-30 10:42:20.609139136-07:00'),
(15,0.144109113,'2018-08-30 10:42:20.64756516-07:00'),
(15,0.059993314,'2018-08-30 10:42:20.710322678-07:00'),
(16,0.058810662,'2018-08-30 10:42:20.712087274-07:00'),
(17,0.061824594,'2018-08-30 10:42:20.791266761-07:00'),
(16,0.074584583,'2018-08-30 10:42:20.797581163-07:00'),
(17,0.057086551,'2018-08-30 10:42:20.854020864-07:00'),
(5,0.006504081,'2018-08-31 10:42:08.779875117-07:00'),
(3,0.202164333,'2018-08-31 10:42:08.977187173-07:00'),
(4,0.376675172,'2018-08-31 10:42:09.151858662-07:00'),
(1,0.413912204,'2018-08-31 10:42:09.188850317-07:00'),
(2,0.528427935,'2018-08-31 10:42:09.310642068-07:00'),
(6,0.11930188,'2018-08-31 10:42:14.133392018-07:00'),
(7,0.001062722,'2018-08-31 10:42:14.148258553-07:00'),
(7,0.004046882,'2018-08-31 10:42:14.156087817-07:00'),
(6,0.063360069,'2018-08-31 10:42:14.205383358-07:00'),
(8,0.168951416,'2018-08-31 10:42:16.346340211-07:00'),
(8,0.069032763,'2018-08-31 10:42:16.421634189-07:00'),
(9,0.47712966,'2018-08-31 10:42:16.91309317-07:00'),
(10,0.104510482,'2018-08-31 10:42:17.065673146-07:00'),
(10,0.062536146,'2018-08-31 10:42:17.134754949-07:00'),
(9,0.352823197,'2018-08-31 10:42:17.272174866-07:00'),
(8,0.38226374,'2018-08-31 10:42:17.738731999-07:00'),
(11,0.857324393,'2018-08-31 10:42:17.939738264-07:00'),
(12,0.113320285,'2018-08-31 10:42:18.073586363-07:00'),
(12,0.038532321,'2018-08-31 10:42:18.119730063-07:00'),
(8,0.123430059,'2018-08-31 10:42:18.479407581-07:00'),
(11,0.625290389,'2018-08-31 10:42:18.5715553-07:00'),
(1,0.091823417,'2018-08-31 10:42:18.868788983-07:00'),
(9,0.246651097,'2018-08-31 10:42:19.165697332-07:00'),
(8,0.222901604,'2018-08-31 10:42:19.57929225-07:00'),
(13,1.600367041,'2018-08-31 10:42:20.010203546-07:00'),
(10,0.050076397,'2018-08-31 10:42:20.12391038-07:00'),
(14,0.460363958,'2018-08-31 10:42:20.495937751-07:00'),
(8,0.252590543,'2018-08-31 10:42:20.609139136-07:00'),
(15,0.144109113,'2018-08-31 10:42:20.64756516-07:00'),
(15,0.059993314,'2018-08-31 10:42:20.710322678-07:00'),
(16,0.058810662,'2018-08-31 10:42:20.712087274-07:00'),
(17,0.061824594,'2018-08-31 10:42:20.791266761-07:00'),
(16,0.074584583,'2018-08-31 10:42:20.797581163-07:00'),
(17,0.057086551,'2018-08-31 10:42:20.854020864-07:00');
INSERT INTO failures (issue,method,service,created_at) VALUES
('HTTP Status Code 200 did not match 0','',18,'2018-08-28 10:42:14.271162743-07:00'),
('HTTP Status Code 200 did not match 0','',6,'2018-08-28 10:42:14.271162743-07:00'),
('HTTP Status Code 200 did not match 0','',6,'2018-08-29 10:42:14.271162743-07:00'),
('HTTP Status Code 200 did not match 0','',6,'2018-08-30 10:42:14.271162743-07:00'),
('Incorrect Response','',1,'2018-08-31 10:40:14.272209564-07:00'),
('HTTP Status Code 200 did not match 0','',6,'2018-08-31 10:42:14.271162743-07:00'),
('HTTP Status Code 200 did not match 0','',6,'2018-08-31 10:42:14.272209564-07:00'),
('HTTP Status Code 200 did not match 0','',18,'2018-08-31 10:42:14.271162743-07:00');
INSERT INTO notifications (id,method,host,port,username,password,var1,var2,api_key,api_secret,enabled,removable,limits,created_at) VALUES
(1,'email','smtp.emailer.com',587,'exampleuser','password123','info@betatude.com','sendto@gmail.com','','',1,0,7,'2018-08-31 10:42:15.000829706-07:00'),
(2,'slack','https://webhooksurl.slack.com/***',0,'','','','','','',0,0,3,'2018-08-31 10:42:08.775366824-07:00'),
(3,'twilio','',0,'','','','','','',0,0,3,'2018-08-31 10:42:08.776944923-07:00');

View File

@ -27,27 +27,27 @@ import (
"time"
)
type Discord struct {
type discord struct {
*notifier.Notification
}
var discorder = &Discord{&notifier.Notification{
var discorder = &discord{&notifier.Notification{
Method: "discord",
Title: "Discord",
Description: "Send notifications to your discord channel using discord webhooks. Insert your Discord channel webhook URL to receive notifications. Based on the <a href=\"https://discordapp.com/developers/docs/resources/webhook\">Discord Webhook API</a>.",
Title: "discord",
Description: "Send notifications to your discord channel using discord webhooks. Insert your discord channel webhook URL to receive notifications. Based on the <a href=\"https://discordapp.com/developers/docs/resources/webhook\">discord webhooker API</a>.",
Author: "Hunter Long",
AuthorUrl: "https://github.com/hunterlong",
Delay: time.Duration(5 * time.Second),
Host: "https://discordapp.com/api/webhooks/****/*****",
Form: []notifier.NotificationForm{{
Type: "text",
Title: "Discord Webhook URL",
Title: "discord webhooker URL",
Placeholder: "Insert your webhook URL here",
DbField: "host",
}}},
}
// init the Discord notifier
// init the discord notifier
func init() {
err := notifier.AddNotifier(discorder)
if err != nil {
@ -55,8 +55,8 @@ func init() {
}
}
// Send will send a HTTP Post to the Discord API. It accepts type: []byte
func (u *Discord) Send(msg interface{}) error {
// Send will send a HTTP Post to the discord API. It accepts type: []byte
func (u *discord) Send(msg interface{}) error {
message := msg.(string)
req, _ := http.NewRequest("POST", discorder.GetValue("host"), bytes.NewBuffer([]byte(message)))
req.Header.Set("Content-Type", "application/json")
@ -68,19 +68,19 @@ func (u *Discord) Send(msg interface{}) error {
return resp.Body.Close()
}
func (u *Discord) Select() *notifier.Notification {
func (u *discord) Select() *notifier.Notification {
return u.Notification
}
// OnFailure will trigger failing service
func (u *Discord) OnFailure(s *types.Service, f *types.Failure) {
func (u *discord) OnFailure(s *types.Service, f *types.Failure) {
msg := fmt.Sprintf(`{"content": "Your service '%v' is currently failing! Reason: %v"}`, s.Name, f.Issue)
u.AddQueue(msg)
u.Online = false
}
// OnSuccess will trigger successful service
func (u *Discord) OnSuccess(s *types.Service) {
func (u *discord) OnSuccess(s *types.Service) {
if !u.Online {
msg := fmt.Sprintf(`{"content": "Your service '%v' is back online!"}`, s.Name)
u.AddQueue(msg)
@ -89,16 +89,16 @@ func (u *Discord) OnSuccess(s *types.Service) {
}
// OnSave triggers when this notifier has been saved
func (u *Discord) OnSave() error {
msg := fmt.Sprintf(`{"content": "The Discord notifier on Statup was just updated."}`)
func (u *discord) OnSave() error {
msg := fmt.Sprintf(`{"content": "The discord notifier on Statup was just updated."}`)
u.AddQueue(msg)
return nil
}
// OnSave triggers when this notifier has been saved
func (u *Discord) OnTest() error {
outError := errors.New("Incorrect Discord URL, please confirm URL is correct")
message := `{"content": "Testing the Discord notifier"}`
func (u *discord) OnTest() error {
outError := errors.New("Incorrect discord URL, please confirm URL is correct")
message := `{"content": "Testing the discord notifier"}`
req, _ := http.NewRequest("POST", discorder.Host, bytes.NewBuffer([]byte(message)))
req.Header.Set("Content-Type", "application/json")
client := &http.Client{}

View File

@ -25,7 +25,7 @@ import (
var (
DISCORD_URL = os.Getenv("DISCORD_URL")
discordMessage = `{"content": "The Discord notifier on Statup has been tested!"}`
discordMessage = `{"content": "The discord notifier on Statup has been tested!"}`
)
func init() {
@ -36,12 +36,12 @@ func init() {
func TestDiscordNotifier(t *testing.T) {
t.Parallel()
if DISCORD_URL == "" {
t.Log("Discord notifier testing skipped, missing DISCORD_URL environment variable")
t.Log("discord notifier testing skipped, missing DISCORD_URL environment variable")
t.SkipNow()
}
currentCount = CountNotifiers()
t.Run("Load Discord", func(t *testing.T) {
t.Run("Load discord", func(t *testing.T) {
discorder.Host = DISCORD_URL
discorder.Delay = time.Duration(100 * time.Millisecond)
err := notifier.AddNotifier(discorder)
@ -50,49 +50,49 @@ func TestDiscordNotifier(t *testing.T) {
assert.Equal(t, DISCORD_URL, discorder.Host)
})
t.Run("Load Discord Notifier", func(t *testing.T) {
t.Run("Load discord Notifier", func(t *testing.T) {
notifier.Load()
})
t.Run("Discord Notifier Tester", func(t *testing.T) {
t.Run("discord Notifier Tester", func(t *testing.T) {
assert.True(t, discorder.CanTest())
})
t.Run("Discord Within Limits", func(t *testing.T) {
t.Run("discord Within Limits", func(t *testing.T) {
ok, err := discorder.WithinLimits()
assert.Nil(t, err)
assert.True(t, ok)
})
t.Run("Discord OnFailure", func(t *testing.T) {
t.Run("discord OnFailure", func(t *testing.T) {
discorder.OnFailure(TestService, TestFailure)
assert.Len(t, discorder.Queue, 1)
})
t.Run("Discord Check Offline", func(t *testing.T) {
t.Run("discord Check Offline", func(t *testing.T) {
assert.False(t, discorder.Online)
})
t.Run("Discord OnSuccess", func(t *testing.T) {
t.Run("discord OnSuccess", func(t *testing.T) {
discorder.OnSuccess(TestService)
assert.Len(t, discorder.Queue, 2)
})
t.Run("Discord Check Back Online", func(t *testing.T) {
t.Run("discord Check Back Online", func(t *testing.T) {
assert.True(t, discorder.Online)
})
t.Run("Discord OnSuccess Again", func(t *testing.T) {
t.Run("discord OnSuccess Again", func(t *testing.T) {
discorder.OnSuccess(TestService)
assert.Len(t, discorder.Queue, 2)
})
t.Run("Discord Send", func(t *testing.T) {
t.Run("discord Send", func(t *testing.T) {
err := discorder.Send(discordMessage)
assert.Nil(t, err)
})
t.Run("Discord Queue", func(t *testing.T) {
t.Run("discord Queue", func(t *testing.T) {
go notifier.Queue(discorder)
time.Sleep(1 * time.Second)
assert.Equal(t, DISCORD_URL, discorder.Host)

View File

@ -33,7 +33,7 @@ const (
<head>
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Statup Email</title>
<title>Statup email</title>
</head>
<body style="-webkit-text-size-adjust: none; box-sizing: border-box; color: #74787E; font-family: Arial, 'Helvetica Neue', Helvetica, sans-serif; height: 100%; line-height: 1.4; margin: 0; width: 100% !important;" bgcolor="#F2F4F6">
<style type="text/css">
@ -107,13 +107,13 @@ var (
mailer *mail.Dialer
)
type Email struct {
type email struct {
*notifier.Notification
}
var emailer = &Email{&notifier.Notification{
var emailer = &email{&notifier.Notification{
Method: "email",
Title: "Email",
Title: "email",
Description: "Send emails via SMTP when services are online or offline.",
Author: "Hunter Long",
AuthorUrl: "https://github.com/hunterlong",
@ -139,13 +139,13 @@ var emailer = &Email{&notifier.Notification{
DbField: "Port",
}, {
Type: "text",
Title: "Outgoing Email Address",
Placeholder: "Insert your Outgoing Email Address",
Title: "Outgoing email Address",
Placeholder: "Insert your Outgoing email Address",
DbField: "Var1",
}, {
Type: "email",
Title: "Send Alerts To",
Placeholder: "Email Address",
Placeholder: "email Address",
DbField: "Var2",
}},
}}
@ -158,11 +158,11 @@ func init() {
}
// Send will send the SMTP email with your authentication It accepts type: *EmailOutgoing
func (u *Email) Send(msg interface{}) error {
func (u *email) Send(msg interface{}) error {
email := msg.(*EmailOutgoing)
err := u.dialSend(email)
if err != nil {
utils.Log(3, fmt.Sprintf("Email Notifier could not send email: %v", err))
utils.Log(3, fmt.Sprintf("email Notifier could not send email: %v", err))
return err
}
return nil
@ -179,7 +179,7 @@ type EmailOutgoing struct {
}
// OnFailure will trigger failing service
func (u *Email) OnFailure(s *types.Service, f *types.Failure) {
func (u *email) OnFailure(s *types.Service, f *types.Failure) {
email := &EmailOutgoing{
To: emailer.GetValue("var2"),
Subject: fmt.Sprintf("Service %v is Failing", s.Name),
@ -192,7 +192,7 @@ func (u *Email) OnFailure(s *types.Service, f *types.Failure) {
}
// OnSuccess will trigger successful service
func (u *Email) OnSuccess(s *types.Service) {
func (u *email) OnSuccess(s *types.Service) {
if !u.Online {
email := &EmailOutgoing{
To: emailer.GetValue("var2"),
@ -206,19 +206,19 @@ func (u *Email) OnSuccess(s *types.Service) {
u.Online = true
}
func (u *Email) Select() *notifier.Notification {
func (u *email) Select() *notifier.Notification {
return u.Notification
}
// OnSave triggers when this notifier has been saved
func (u *Email) OnSave() error {
func (u *email) OnSave() error {
utils.Log(1, fmt.Sprintf("Notification %v is receiving updated information.", u.Method))
// Do updating stuff here
return nil
}
// OnTest triggers when this notifier has been saved
func (u *Email) OnTest() error {
func (u *email) OnTest() error {
host := fmt.Sprintf("%v:%v", u.Host, u.Port)
dial, err := smtp.Dial(host)
if err != nil {
@ -229,7 +229,7 @@ func (u *Email) OnTest() error {
return dial.Auth(auth)
}
func (u *Email) dialSend(email *EmailOutgoing) error {
func (u *email) dialSend(email *EmailOutgoing) error {
mailer = mail.NewDialer(emailer.Host, emailer.Port, emailer.Username, emailer.Password)
mailer.TLSConfig = &tls.Config{InsecureSkipVerify: true}
emailSource(email)
@ -239,7 +239,7 @@ func (u *Email) dialSend(email *EmailOutgoing) error {
m.SetHeader("Subject", email.Subject)
m.SetBody("text/html", email.Source)
if err := mailer.DialAndSend(m); err != nil {
utils.Log(3, fmt.Sprintf("Email '%v' sent to: %v using the %v template (size: %v) %v", email.Subject, email.To, email.Template, len([]byte(email.Source)), err))
utils.Log(3, fmt.Sprintf("email '%v' sent to: %v using the %v template (size: %v) %v", email.Subject, email.To, email.Template, len([]byte(email.Source)), err))
return err
}
return nil

View File

@ -55,7 +55,7 @@ func init() {
func TestEmailNotifier(t *testing.T) {
t.Parallel()
if EMAIL_HOST == "" || EMAIL_USER == "" || EMAIL_PASS == "" {
t.Log("Email notifier testing skipped, missing EMAIL_ environment variables")
t.Log("email notifier testing skipped, missing EMAIL_ environment variables")
t.SkipNow()
}
currentCount = CountNotifiers()
@ -78,7 +78,7 @@ func TestEmailNotifier(t *testing.T) {
}
})
t.Run("Add Email Notifier", func(t *testing.T) {
t.Run("Add email Notifier", func(t *testing.T) {
err := notifier.AddNotifier(emailer)
assert.Nil(t, err)
assert.Equal(t, "Hunter Long", emailer.Author)
@ -89,46 +89,46 @@ func TestEmailNotifier(t *testing.T) {
notifier.Load()
})
t.Run("Email Within Limits", func(t *testing.T) {
t.Run("email Within Limits", func(t *testing.T) {
ok, err := emailer.WithinLimits()
assert.Nil(t, err)
assert.True(t, ok)
})
t.Run("Email Test Source", func(t *testing.T) {
t.Run("email Test Source", func(t *testing.T) {
emailSource(testEmail)
assert.NotEmpty(t, testEmail.Source)
})
t.Run("Email OnFailure", func(t *testing.T) {
t.Run("email OnFailure", func(t *testing.T) {
emailer.OnFailure(TestService, TestFailure)
assert.Len(t, emailer.Queue, 1)
})
t.Run("Email Check Offline", func(t *testing.T) {
t.Run("email Check Offline", func(t *testing.T) {
assert.False(t, emailer.Online)
})
t.Run("Email OnSuccess", func(t *testing.T) {
t.Run("email OnSuccess", func(t *testing.T) {
emailer.OnSuccess(TestService)
assert.Len(t, emailer.Queue, 2)
})
t.Run("Email Check Back Online", func(t *testing.T) {
t.Run("email Check Back Online", func(t *testing.T) {
assert.True(t, emailer.Online)
})
t.Run("Email OnSuccess Again", func(t *testing.T) {
t.Run("email OnSuccess Again", func(t *testing.T) {
emailer.OnSuccess(TestService)
assert.Len(t, emailer.Queue, 2)
})
t.Run("Email Send", func(t *testing.T) {
t.Run("email Send", func(t *testing.T) {
err := emailer.Send(testEmail)
assert.Nil(t, err)
})
t.Run("Email Run Queue", func(t *testing.T) {
t.Run("email Run Queue", func(t *testing.T) {
go notifier.Queue(emailer)
time.Sleep(5 * time.Second)
assert.Equal(t, EMAIL_HOST, emailer.Host)

View File

@ -29,11 +29,11 @@ const (
LINE_NOTIFY_METHOD = "line notify"
)
type LineNotify struct {
type lineNotifier struct {
*notifier.Notification
}
var lineNotify = &LineNotify{&notifier.Notification{
var lineNotify = &lineNotifier{&notifier.Notification{
Method: LINE_NOTIFY_METHOD,
Title: "LINE Notify",
Description: "LINE Notify will send notifications to your LINE Notify account when services are offline or online. Baed on the <a href=\"https://notify-bot.line.me/doc/en/\">LINE Notify API</a>.",
@ -56,7 +56,7 @@ func init() {
}
// Send will send a HTTP Post with the Authorization to the notify-api.line.me server. It accepts type: string
func (u *LineNotify) Send(msg interface{}) error {
func (u *lineNotifier) Send(msg interface{}) error {
message := msg.(string)
client := new(http.Client)
v := url.Values{}
@ -72,19 +72,19 @@ func (u *LineNotify) Send(msg interface{}) error {
return nil
}
func (u *LineNotify) Select() *notifier.Notification {
func (u *lineNotifier) Select() *notifier.Notification {
return u.Notification
}
// OnFailure will trigger failing service
func (u *LineNotify) OnFailure(s *types.Service, f *types.Failure) {
func (u *lineNotifier) OnFailure(s *types.Service, f *types.Failure) {
msg := fmt.Sprintf("Your service '%v' is currently offline!", s.Name)
u.AddQueue(msg)
u.Online = false
}
// OnSuccess will trigger successful service
func (u *LineNotify) OnSuccess(s *types.Service) {
func (u *lineNotifier) OnSuccess(s *types.Service) {
if !u.Online {
msg := fmt.Sprintf("Your service '%v' is back online!", s.Name)
u.AddQueue(msg)
@ -93,7 +93,7 @@ func (u *LineNotify) OnSuccess(s *types.Service) {
}
// OnSave triggers when this notifier has been saved
func (u *LineNotify) OnSave() error {
func (u *lineNotifier) OnSave() error {
utils.Log(1, fmt.Sprintf("Notification %v is receiving updated information.", u.Method))
// Do updating stuff here
return nil

View File

@ -34,23 +34,23 @@ const (
SLACK_TEXT = `{"text":"{{.}}"}`
)
type Slack struct {
type slack struct {
*notifier.Notification
}
var slacker = &Slack{&notifier.Notification{
var slacker = &slack{&notifier.Notification{
Method: SLACK_METHOD,
Title: "Slack",
Description: "Send notifications to your Slack channel when a service is offline. Insert your Incoming Webhook URL for your channel to receive notifications. Based on the <a href=\"https://api.slack.com/incoming-webhooks\">Slack API</a>.",
Title: "slack",
Description: "Send notifications to your slack channel when a service is offline. Insert your Incoming webhooker URL for your channel to receive notifications. Based on the <a href=\"https://api.slack.com/incoming-webhooks\">slack API</a>.",
Author: "Hunter Long",
AuthorUrl: "https://github.com/hunterlong",
Delay: time.Duration(10 * time.Second),
Host: "https://webhooksurl.slack.com/***",
Form: []notifier.NotificationForm{{
Type: "text",
Title: "Incoming Webhook Url",
Placeholder: "Insert your Slack webhook URL here.",
SmallText: "Incoming Webhook URL from <a href=\"https://api.slack.com/apps\" target=\"_blank\">Slack Apps</a>",
Title: "Incoming webhooker Url",
Placeholder: "Insert your slack webhook URL here.",
SmallText: "Incoming webhooker URL from <a href=\"https://api.slack.com/apps\" target=\"_blank\">slack Apps</a>",
DbField: "Host",
Required: true,
}}},
@ -81,8 +81,8 @@ func init() {
}
}
// Send will send a HTTP Post to the Slack Webhook API. It accepts type: string
func (u *Slack) Send(msg interface{}) error {
// Send will send a HTTP Post to the slack webhooker API. It accepts type: string
func (u *slack) Send(msg interface{}) error {
message := msg.(string)
client := new(http.Client)
res, err := client.Post(u.Host, "application/json", bytes.NewBuffer([]byte(message)))
@ -94,11 +94,11 @@ func (u *Slack) Send(msg interface{}) error {
return nil
}
func (u *Slack) Select() *notifier.Notification {
func (u *slack) Select() *notifier.Notification {
return u.Notification
}
func (u *Slack) OnTest() error {
func (u *slack) OnTest() error {
client := new(http.Client)
res, err := client.Post(u.Host, "application/json", bytes.NewBuffer([]byte(`{"text":"testing message"}`)))
if err != nil {
@ -107,13 +107,13 @@ func (u *Slack) OnTest() error {
defer res.Body.Close()
contents, _ := ioutil.ReadAll(res.Body)
if string(contents) != "ok" {
return errors.New("The Slack response was incorrect, check the URL")
return errors.New("The slack response was incorrect, check the URL")
}
return err
}
// OnFailure will trigger failing service
func (u *Slack) OnFailure(s *types.Service, f *types.Failure) {
func (u *slack) OnFailure(s *types.Service, f *types.Failure) {
message := SlackMessage{
Service: s,
Template: FAILING_TEMPLATE,
@ -124,7 +124,7 @@ func (u *Slack) OnFailure(s *types.Service, f *types.Failure) {
}
// OnSuccess will trigger successful service
func (u *Slack) OnSuccess(s *types.Service) {
func (u *slack) OnSuccess(s *types.Service) {
if !u.Online {
message := SlackMessage{
Service: s,
@ -137,7 +137,7 @@ func (u *Slack) OnSuccess(s *types.Service) {
}
// OnSave triggers when this notifier has been saved
func (u *Slack) OnSave() error {
func (u *slack) OnSave() error {
message := fmt.Sprintf("Notification %v is receiving updated information.", u.Method)
u.AddQueue(message)
return nil

View File

@ -25,7 +25,7 @@ import (
var (
SLACK_URL string
slackMessage = `{"text":"this is a test from the Slack notifier!"}`
slackMessage = `{"text":"this is a test from the slack notifier!"}`
)
func init() {
@ -38,12 +38,12 @@ func TestSlackNotifier(t *testing.T) {
SLACK_URL = os.Getenv("SLACK_URL")
slacker.Host = SLACK_URL
if SLACK_URL == "" {
t.Log("Slack notifier testing skipped, missing SLACK_URL environment variable")
t.Log("slack notifier testing skipped, missing SLACK_URL environment variable")
t.SkipNow()
}
currentCount = CountNotifiers()
t.Run("Load Slack", func(t *testing.T) {
t.Run("Load slack", func(t *testing.T) {
slacker.Host = SLACK_URL
slacker.Delay = time.Duration(100 * time.Millisecond)
err := notifier.AddNotifier(slacker)
@ -52,56 +52,56 @@ func TestSlackNotifier(t *testing.T) {
assert.Equal(t, SLACK_URL, slacker.Host)
})
t.Run("Load Slack Notifier", func(t *testing.T) {
t.Run("Load slack Notifier", func(t *testing.T) {
notifier.Load()
})
t.Run("Slack Notifier Tester", func(t *testing.T) {
t.Run("slack Notifier Tester", func(t *testing.T) {
assert.True(t, slacker.CanTest())
})
t.Run("Slack parse message", func(t *testing.T) {
t.Run("slack parse message", func(t *testing.T) {
err := parseSlackMessage(SLACK_TEXT, "this is a test!")
assert.Nil(t, err)
assert.Equal(t, 1, len(slacker.Queue))
})
t.Run("Slack Within Limits", func(t *testing.T) {
t.Run("slack Within Limits", func(t *testing.T) {
ok, err := slacker.WithinLimits()
assert.Nil(t, err)
assert.True(t, ok)
})
t.Run("Slack OnFailure", func(t *testing.T) {
t.Run("slack OnFailure", func(t *testing.T) {
slacker.OnFailure(TestService, TestFailure)
assert.Len(t, slacker.Queue, 2)
})
t.Run("Slack Check Offline", func(t *testing.T) {
t.Run("slack Check Offline", func(t *testing.T) {
assert.False(t, slacker.Online)
})
t.Run("Slack OnSuccess", func(t *testing.T) {
t.Run("slack OnSuccess", func(t *testing.T) {
slacker.OnSuccess(TestService)
assert.Len(t, slacker.Queue, 3)
})
t.Run("Slack Check Back Online", func(t *testing.T) {
t.Run("slack Check Back Online", func(t *testing.T) {
assert.True(t, slacker.Online)
})
t.Run("Slack OnSuccess Again", func(t *testing.T) {
t.Run("slack OnSuccess Again", func(t *testing.T) {
slacker.OnSuccess(TestService)
assert.Len(t, slacker.Queue, 3)
})
t.Run("Slack Send", func(t *testing.T) {
t.Run("slack Send", func(t *testing.T) {
err := slacker.Send(slackMessage)
assert.Nil(t, err)
assert.Len(t, slacker.Queue, 3)
})
t.Run("Slack Queue", func(t *testing.T) {
t.Run("slack Queue", func(t *testing.T) {
go notifier.Queue(slacker)
time.Sleep(4 * time.Second)
assert.Equal(t, SLACK_URL, slacker.Host)

View File

@ -31,13 +31,13 @@ const (
WEBHOOK_METHOD = "webhook"
)
type Webhook struct {
type webhooker struct {
*notifier.Notification
}
var webhook = &Webhook{&notifier.Notification{
var webhook = &webhooker{&notifier.Notification{
Method: WEBHOOK_METHOD,
Title: "HTTP Webhook",
Title: "HTTP webhooker",
Description: "Send a custom HTTP request to a specific URL with your own body, headers, and parameters",
Author: "Hunter Long",
AuthorUrl: "https://github.com/hunterlong",
@ -85,8 +85,8 @@ func init() {
}
}
// Send will send a HTTP Post to the Webhook API. It accepts type: string
func (w *Webhook) Send(msg interface{}) error {
// Send will send a HTTP Post to the webhooker API. It accepts type: string
func (w *webhooker) Send(msg interface{}) error {
resp, err := w.run(msg.(string))
if err == nil {
resp.Body.Close()
@ -94,7 +94,7 @@ func (w *Webhook) Send(msg interface{}) error {
return err
}
func (w *Webhook) Select() *notifier.Notification {
func (w *webhooker) Select() *notifier.Notification {
return w.Notification
}
@ -110,7 +110,7 @@ func replaceBodyText(body string, s *types.Service, f *types.Failure) string {
return body
}
func (w *Webhook) run(body string) (*http.Response, error) {
func (w *webhooker) run(body string) (*http.Response, error) {
utils.Log(1, fmt.Sprintf("sending body: '%v' to %v as a %v request", body, w.Host, w.Var1))
client := new(http.Client)
client.Timeout = time.Duration(10 * time.Second)
@ -140,7 +140,7 @@ func (w *Webhook) run(body string) (*http.Response, error) {
return resp, err
}
func (w *Webhook) OnTest() error {
func (w *webhooker) OnTest() error {
service := &types.Service{
Id: 1,
Name: "Interpol - All The Rage Back Home",
@ -167,14 +167,14 @@ func (w *Webhook) OnTest() error {
}
// OnFailure will trigger failing service
func (w *Webhook) OnFailure(s *types.Service, f *types.Failure) {
func (w *webhooker) OnFailure(s *types.Service, f *types.Failure) {
msg := replaceBodyText(w.Var2, s, f)
webhook.AddQueue(msg)
w.Online = false
}
// OnSuccess will trigger successful service
func (w *Webhook) OnSuccess(s *types.Service) {
func (w *webhooker) OnSuccess(s *types.Service) {
if !w.Online {
msg := replaceBodyText(w.Var2, s, nil)
webhook.AddQueue(msg)
@ -183,6 +183,6 @@ func (w *Webhook) OnSuccess(s *types.Service) {
}
// OnSave triggers when this notifier has been saved
func (w *Webhook) OnSave() error {
func (w *webhooker) OnSave() error {
return nil
}

View File

@ -38,7 +38,7 @@ func TestWebhookNotifier(t *testing.T) {
t.Parallel()
currentCount = CountNotifiers()
t.Run("Load Webhook", func(t *testing.T) {
t.Run("Load webhooker", func(t *testing.T) {
webhook.Host = WEBHOOK_URL
webhook.Delay = time.Duration(100 * time.Millisecond)
err := notifier.AddNotifier(webhook)
@ -47,55 +47,55 @@ func TestWebhookNotifier(t *testing.T) {
assert.Equal(t, WEBHOOK_URL, webhook.Host)
})
t.Run("Load Webhook Notifier", func(t *testing.T) {
t.Run("Load webhooker Notifier", func(t *testing.T) {
notifier.Load()
})
t.Run("Webhook Notifier Tester", func(t *testing.T) {
t.Run("webhooker Notifier Tester", func(t *testing.T) {
assert.True(t, webhook.CanTest())
})
t.Run("Webhook Replace Body Text", func(t *testing.T) {
t.Run("webhooker Replace Body Text", func(t *testing.T) {
fullMsg = replaceBodyText(webhookMessage, TestService, TestFailure)
assert.Equal(t, "{ \"title\": \"1\", \"body\": \"Interpol - All The Rage Back Home\", \"online\": false, \"userId\": 19999 }", fullMsg)
})
t.Run("Webhook Within Limits", func(t *testing.T) {
t.Run("webhooker Within Limits", func(t *testing.T) {
ok, err := webhook.WithinLimits()
assert.Nil(t, err)
assert.True(t, ok)
})
t.Run("Webhook OnFailure", func(t *testing.T) {
t.Run("webhooker OnFailure", func(t *testing.T) {
webhook.OnFailure(TestService, TestFailure)
assert.Len(t, webhook.Queue, 1)
})
t.Run("Webhook Check Offline", func(t *testing.T) {
t.Run("webhooker Check Offline", func(t *testing.T) {
assert.False(t, webhook.Online)
})
t.Run("Webhook OnSuccess", func(t *testing.T) {
t.Run("webhooker OnSuccess", func(t *testing.T) {
webhook.OnSuccess(TestService)
assert.Len(t, webhook.Queue, 2)
})
t.Run("Webhook Check Back Online", func(t *testing.T) {
t.Run("webhooker Check Back Online", func(t *testing.T) {
assert.True(t, webhook.Online)
})
t.Run("Webhook OnSuccess Again", func(t *testing.T) {
t.Run("webhooker OnSuccess Again", func(t *testing.T) {
webhook.OnSuccess(TestService)
assert.Len(t, webhook.Queue, 2)
})
t.Run("Webhook Send", func(t *testing.T) {
t.Run("webhooker Send", func(t *testing.T) {
err := webhook.Send(fullMsg)
assert.Nil(t, err)
assert.Len(t, webhook.Queue, 2)
})
t.Run("Webhook Queue", func(t *testing.T) {
t.Run("webhooker Queue", func(t *testing.T) {
go notifier.Queue(webhook)
time.Sleep(8 * time.Second)
assert.Equal(t, WEBHOOK_URL, webhook.Host)