2017-07-06 16:28:13 +02:00
package integration
2015-09-27 15:59:51 +02:00
import (
"net/http"
"time"
2017-05-17 15:22:44 +02:00
"github.com/containous/traefik/integration/try"
2016-04-02 12:40:21 +02:00
"github.com/go-check/check"
2015-09-27 15:59:51 +02:00
checker "github.com/vdemeester/shakers"
)
2016-03-27 16:27:56 +02:00
// File test suites
type FileSuite struct { BaseSuite }
func ( s * FileSuite ) SetUpSuite ( c * check . C ) {
s . createComposeProject ( c , "file" )
2016-04-02 12:40:21 +02:00
s . composeProject . Start ( c )
2016-03-27 16:27:56 +02:00
}
2015-09-27 15:59:51 +02:00
func ( s * FileSuite ) TestSimpleConfiguration ( c * check . C ) {
2017-09-13 10:34:04 +02:00
cmd , display := s . traefikCmd ( withConfigFile ( "fixtures/file/simple.toml" ) )
defer display ( c )
2015-09-27 15:59:51 +02:00
err := cmd . Start ( )
c . Assert ( err , checker . IsNil )
2015-11-03 23:06:31 +01:00
defer cmd . Process . Kill ( )
2015-09-27 15:59:51 +02:00
2015-10-17 14:46:31 +02:00
// Expected a 404 as we did not configure anything
2017-05-26 14:32:03 +01:00
err = try . GetRequest ( "http://127.0.0.1:8000/" , 1000 * time . Millisecond , try . StatusCodeIs ( http . StatusNotFound ) )
2015-10-17 14:46:31 +02:00
c . Assert ( err , checker . IsNil )
}
// #56 regression test, make sure it does not fail
func ( s * FileSuite ) TestSimpleConfigurationNoPanic ( c * check . C ) {
2017-09-13 10:34:04 +02:00
cmd , display := s . traefikCmd ( withConfigFile ( "fixtures/file/56-simple-panic.toml" ) )
defer display ( c )
2015-10-17 14:46:31 +02:00
err := cmd . Start ( )
c . Assert ( err , checker . IsNil )
2015-11-03 23:06:31 +01:00
defer cmd . Process . Kill ( )
2015-10-17 14:46:31 +02:00
2015-10-06 21:00:53 +02:00
// Expected a 404 as we did not configure anything
2017-05-26 14:32:03 +01:00
err = try . GetRequest ( "http://127.0.0.1:8000/" , 1000 * time . Millisecond , try . StatusCodeIs ( http . StatusNotFound ) )
c . Assert ( err , checker . IsNil )
}
func ( s * FileSuite ) TestDirectoryConfiguration ( c * check . C ) {
2017-09-13 10:34:04 +02:00
cmd , display := s . traefikCmd ( withConfigFile ( "fixtures/file/directory.toml" ) )
defer display ( c )
2017-05-26 14:32:03 +01:00
err := cmd . Start ( )
c . Assert ( err , checker . IsNil )
defer cmd . Process . Kill ( )
// Expected a 404 as we did not configure anything at /test
err = try . GetRequest ( "http://127.0.0.1:8000/test" , 1000 * time . Millisecond , try . StatusCodeIs ( http . StatusNotFound ) )
c . Assert ( err , checker . IsNil )
// Expected a 502 as there is no backend server
err = try . GetRequest ( "http://127.0.0.1:8000/test2" , 1000 * time . Millisecond , try . StatusCodeIs ( http . StatusBadGateway ) )
2015-09-27 15:59:51 +02:00
c . Assert ( err , checker . IsNil )
}