summaryrefslogtreecommitdiff
path: root/plugins/http/tests/ssl_test.go
diff options
context:
space:
mode:
authorValery Piashchynski <[email protected]>2020-11-19 21:34:22 +0300
committerValery Piashchynski <[email protected]>2020-11-19 21:34:22 +0300
commitbc0be9c17220220ae9b40b65e874701edaecd8ce (patch)
tree6ee032eee330f8bc8824e426bab1846c9479333c /plugins/http/tests/ssl_test.go
parent729c19af8c410a28b7b46c134fd7fe9608cd73b1 (diff)
Add SSL tests
Diffstat (limited to 'plugins/http/tests/ssl_test.go')
-rw-r--r--plugins/http/tests/ssl_test.go178
1 files changed, 178 insertions, 0 deletions
diff --git a/plugins/http/tests/ssl_test.go b/plugins/http/tests/ssl_test.go
new file mode 100644
index 00000000..ee0e6e98
--- /dev/null
+++ b/plugins/http/tests/ssl_test.go
@@ -0,0 +1,178 @@
+package tests
+
+//func Test_SSL_Service_NoRedirect(t *testing.T) {
+// logger, _ := test.NewNullLogger()
+// logger.SetLevel(logrus.DebugLevel)
+//
+// c := service.NewContainer(logger)
+// c.Register(ID, &Service{})
+//
+// assert.NoError(t, c.Init(&testCfg{httpCfg: `{
+// "address": ":6030",
+// "ssl": {
+// "port": 6901,
+// "key": "fixtures/server.key",
+// "cert": "fixtures/server.crt"
+// },
+// "workers":{
+// "command": "php ../../tests/http/client.php echo pipes",
+// "pool": {"numWorkers": 1}
+// }
+// }`}))
+//
+// s, st := c.Get(ID)
+// assert.NotNil(t, s)
+// assert.Equal(t, service.StatusOK, st)
+//
+// // should do nothing
+// s.(*Service).Stop()
+//
+// go func() {
+// err := c.Serve()
+// if err != nil {
+// t.Errorf("error during the Serve: error %v", err)
+// }
+// }()
+//
+// time.Sleep(time.Millisecond * 500)
+//
+// req, err := http.NewRequest("GET", "http://localhost:6030?hello=world", nil)
+// assert.NoError(t, err)
+//
+// r, err := sslClient.Do(req)
+// assert.NoError(t, err)
+//
+// assert.Nil(t, r.TLS)
+//
+// b, err := ioutil.ReadAll(r.Body)
+// assert.NoError(t, err)
+//
+// assert.NoError(t, err)
+// assert.Equal(t, 201, r.StatusCode)
+// assert.Equal(t, "WORLD", string(b))
+//
+// err2 := r.Body.Close()
+// if err2 != nil {
+// t.Errorf("fail to close the Body: error %v", err2)
+// }
+// c.Stop()
+//}
+//
+//func Test_SSL_Service_Redirect(t *testing.T) {
+// logger, _ := test.NewNullLogger()
+// logger.SetLevel(logrus.DebugLevel)
+//
+// c := service.NewContainer(logger)
+// c.Register(ID, &Service{})
+//
+// assert.NoError(t, c.Init(&testCfg{httpCfg: `{
+// "address": ":6831",
+// "ssl": {
+// "port": 6902,
+// "redirect": true,
+// "key": "fixtures/server.key",
+// "cert": "fixtures/server.crt"
+// },
+// "workers":{
+// "command": "php ../../tests/http/client.php echo pipes",
+// "pool": {"numWorkers": 1}
+// }
+// }`}))
+//
+// s, st := c.Get(ID)
+// assert.NotNil(t, s)
+// assert.Equal(t, service.StatusOK, st)
+//
+// // should do nothing
+// s.(*Service).Stop()
+//
+// go func() {
+// err := c.Serve()
+// if err != nil {
+// t.Errorf("error during the Serve: error %v", err)
+// }
+// }()
+//
+// time.Sleep(time.Millisecond * 500)
+//
+// req, err := http.NewRequest("GET", "http://localhost:6831?hello=world", nil)
+// assert.NoError(t, err)
+//
+// r, err := sslClient.Do(req)
+// assert.NoError(t, err)
+// assert.NotNil(t, r.TLS)
+//
+// b, err := ioutil.ReadAll(r.Body)
+// assert.NoError(t, err)
+//
+// assert.NoError(t, err)
+// assert.Equal(t, 201, r.StatusCode)
+// assert.Equal(t, "WORLD", string(b))
+//
+// err2 := r.Body.Close()
+// if err2 != nil {
+// t.Errorf("fail to close the Body: error %v", err2)
+// }
+// c.Stop()
+//}
+//
+//func Test_SSL_Service_Push(t *testing.T) {
+// logger, _ := test.NewNullLogger()
+// logger.SetLevel(logrus.DebugLevel)
+//
+// c := service.NewContainer(logger)
+// c.Register(ID, &Service{})
+//
+// assert.NoError(t, c.Init(&testCfg{httpCfg: `{
+// "address": ":6032",
+// "ssl": {
+// "port": 6903,
+// "redirect": true,
+// "key": "fixtures/server.key",
+// "cert": "fixtures/server.crt"
+// },
+// "workers":{
+// "command": "php ../../tests/http/client.php push pipes",
+// "pool": {"numWorkers": 1}
+// }
+// }`}))
+//
+// s, st := c.Get(ID)
+// assert.NotNil(t, s)
+// assert.Equal(t, service.StatusOK, st)
+//
+// // should do nothing
+// s.(*Service).Stop()
+//
+// go func() {
+// err := c.Serve()
+// if err != nil {
+// t.Errorf("error during the Serve: error %v", err)
+// }
+// }()
+// time.Sleep(time.Millisecond * 500)
+//
+// req, err := http.NewRequest("GET", "https://localhost:6903?hello=world", nil)
+// assert.NoError(t, err)
+//
+// r, err := sslClient.Do(req)
+// assert.NoError(t, err)
+//
+// assert.NotNil(t, r.TLS)
+//
+// b, err := ioutil.ReadAll(r.Body)
+// assert.NoError(t, err)
+//
+// assert.Equal(t, "", r.Header.Get("Http2-Push"))
+//
+// assert.NoError(t, err)
+// assert.Equal(t, 201, r.StatusCode)
+// assert.Equal(t, "WORLD", string(b))
+//
+//
+// err2 := r.Body.Close()
+// if err2 != nil {
+// t.Errorf("fail to close the Body: error %v", err2)
+// }
+// c.Stop()
+//}