"Fossies" - the Fresh Open Source Software Archive

Member "gin-1.7.7/gin_integration_test.go" (24 Nov 2021, 21846 Bytes) of package /linux/www/gin-1.7.7.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) Go source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. See also the latest Fossies "Diffs" side-by-side code changes report for "gin_integration_test.go": 1.7.6_vs_1.7.7.

    1 // Copyright 2017 Manu Martinez-Almeida.  All rights reserved.
    2 // Use of this source code is governed by a MIT style
    3 // license that can be found in the LICENSE file.
    4 
    5 package gin
    6 
    7 import (
    8     "bufio"
    9     "crypto/tls"
   10     "fmt"
   11     "html/template"
   12     "io/ioutil"
   13     "net"
   14     "net/http"
   15     "net/http/httptest"
   16     "os"
   17     "path/filepath"
   18     "sync"
   19     "testing"
   20     "time"
   21 
   22     "github.com/stretchr/testify/assert"
   23 )
   24 
   25 // params[0]=url example:http://127.0.0.1:8080/index (cannot be empty)
   26 // params[1]=response status (custom compare status) default:"200 OK"
   27 // params[2]=response body (custom compare content)  default:"it worked"
   28 func testRequest(t *testing.T, params ...string) {
   29 
   30     if len(params) == 0 {
   31         t.Fatal("url cannot be empty")
   32     }
   33 
   34     tr := &http.Transport{
   35         TLSClientConfig: &tls.Config{
   36             InsecureSkipVerify: true,
   37         },
   38     }
   39     client := &http.Client{Transport: tr}
   40 
   41     resp, err := client.Get(params[0])
   42     assert.NoError(t, err)
   43     defer resp.Body.Close()
   44 
   45     body, ioerr := ioutil.ReadAll(resp.Body)
   46     assert.NoError(t, ioerr)
   47 
   48     var responseStatus = "200 OK"
   49     if len(params) > 1 && params[1] != "" {
   50         responseStatus = params[1]
   51     }
   52 
   53     var responseBody = "it worked"
   54     if len(params) > 2 && params[2] != "" {
   55         responseBody = params[2]
   56     }
   57 
   58     assert.Equal(t, responseStatus, resp.Status, "should get a "+responseStatus)
   59     if responseStatus == "200 OK" {
   60         assert.Equal(t, responseBody, string(body), "resp body should match")
   61     }
   62 }
   63 
   64 func TestRunEmpty(t *testing.T) {
   65     os.Setenv("PORT", "")
   66     router := New()
   67     go func() {
   68         router.GET("/example", func(c *Context) { c.String(http.StatusOK, "it worked") })
   69         assert.NoError(t, router.Run())
   70     }()
   71     // have to wait for the goroutine to start and run the server
   72     // otherwise the main thread will complete
   73     time.Sleep(5 * time.Millisecond)
   74 
   75     assert.Error(t, router.Run(":8080"))
   76     testRequest(t, "http://localhost:8080/example")
   77 }
   78 
   79 func TestBadTrustedCIDRs(t *testing.T) {
   80     router := New()
   81     assert.Error(t, router.SetTrustedProxies([]string{"hello/world"}))
   82 }
   83 
   84 /* legacy tests
   85 func TestBadTrustedCIDRsForRun(t *testing.T) {
   86     os.Setenv("PORT", "")
   87     router := New()
   88     router.TrustedProxies = []string{"hello/world"}
   89     assert.Error(t, router.Run(":8080"))
   90 }
   91 
   92 func TestBadTrustedCIDRsForRunUnix(t *testing.T) {
   93     router := New()
   94     router.TrustedProxies = []string{"hello/world"}
   95 
   96     unixTestSocket := filepath.Join(os.TempDir(), "unix_unit_test")
   97 
   98     defer os.Remove(unixTestSocket)
   99 
  100     go func() {
  101         router.GET("/example", func(c *Context) { c.String(http.StatusOK, "it worked") })
  102         assert.Error(t, router.RunUnix(unixTestSocket))
  103     }()
  104     // have to wait for the goroutine to start and run the server
  105     // otherwise the main thread will complete
  106     time.Sleep(5 * time.Millisecond)
  107 }
  108 
  109 func TestBadTrustedCIDRsForRunFd(t *testing.T) {
  110     router := New()
  111     router.TrustedProxies = []string{"hello/world"}
  112 
  113     addr, err := net.ResolveTCPAddr("tcp", "localhost:0")
  114     assert.NoError(t, err)
  115     listener, err := net.ListenTCP("tcp", addr)
  116     assert.NoError(t, err)
  117     socketFile, err := listener.File()
  118     assert.NoError(t, err)
  119 
  120     go func() {
  121         router.GET("/example", func(c *Context) { c.String(http.StatusOK, "it worked") })
  122         assert.Error(t, router.RunFd(int(socketFile.Fd())))
  123     }()
  124     // have to wait for the goroutine to start and run the server
  125     // otherwise the main thread will complete
  126     time.Sleep(5 * time.Millisecond)
  127 }
  128 
  129 func TestBadTrustedCIDRsForRunListener(t *testing.T) {
  130     router := New()
  131     router.TrustedProxies = []string{"hello/world"}
  132 
  133     addr, err := net.ResolveTCPAddr("tcp", "localhost:0")
  134     assert.NoError(t, err)
  135     listener, err := net.ListenTCP("tcp", addr)
  136     assert.NoError(t, err)
  137     go func() {
  138         router.GET("/example", func(c *Context) { c.String(http.StatusOK, "it worked") })
  139         assert.Error(t, router.RunListener(listener))
  140     }()
  141     // have to wait for the goroutine to start and run the server
  142     // otherwise the main thread will complete
  143     time.Sleep(5 * time.Millisecond)
  144 }
  145 
  146 func TestBadTrustedCIDRsForRunTLS(t *testing.T) {
  147     os.Setenv("PORT", "")
  148     router := New()
  149     router.TrustedProxies = []string{"hello/world"}
  150     assert.Error(t, router.RunTLS(":8080", "./testdata/certificate/cert.pem", "./testdata/certificate/key.pem"))
  151 }
  152 */
  153 
  154 func TestRunTLS(t *testing.T) {
  155     router := New()
  156     go func() {
  157         router.GET("/example", func(c *Context) { c.String(http.StatusOK, "it worked") })
  158 
  159         assert.NoError(t, router.RunTLS(":8443", "./testdata/certificate/cert.pem", "./testdata/certificate/key.pem"))
  160     }()
  161 
  162     // have to wait for the goroutine to start and run the server
  163     // otherwise the main thread will complete
  164     time.Sleep(5 * time.Millisecond)
  165 
  166     assert.Error(t, router.RunTLS(":8443", "./testdata/certificate/cert.pem", "./testdata/certificate/key.pem"))
  167     testRequest(t, "https://localhost:8443/example")
  168 }
  169 
  170 func TestPusher(t *testing.T) {
  171     var html = template.Must(template.New("https").Parse(`
  172 <html>
  173 <head>
  174   <title>Https Test</title>
  175   <script src="/assets/app.js"></script>
  176 </head>
  177 <body>
  178   <h1 style="color:red;">Welcome, Ginner!</h1>
  179 </body>
  180 </html>
  181 `))
  182 
  183     router := New()
  184     router.Static("./assets", "./assets")
  185     router.SetHTMLTemplate(html)
  186 
  187     go func() {
  188         router.GET("/pusher", func(c *Context) {
  189             if pusher := c.Writer.Pusher(); pusher != nil {
  190                 err := pusher.Push("/assets/app.js", nil)
  191                 assert.NoError(t, err)
  192             }
  193             c.String(http.StatusOK, "it worked")
  194         })
  195 
  196         assert.NoError(t, router.RunTLS(":8449", "./testdata/certificate/cert.pem", "./testdata/certificate/key.pem"))
  197     }()
  198 
  199     // have to wait for the goroutine to start and run the server
  200     // otherwise the main thread will complete
  201     time.Sleep(5 * time.Millisecond)
  202 
  203     assert.Error(t, router.RunTLS(":8449", "./testdata/certificate/cert.pem", "./testdata/certificate/key.pem"))
  204     testRequest(t, "https://localhost:8449/pusher")
  205 }
  206 
  207 func TestRunEmptyWithEnv(t *testing.T) {
  208     os.Setenv("PORT", "3123")
  209     router := New()
  210     go func() {
  211         router.GET("/example", func(c *Context) { c.String(http.StatusOK, "it worked") })
  212         assert.NoError(t, router.Run())
  213     }()
  214     // have to wait for the goroutine to start and run the server
  215     // otherwise the main thread will complete
  216     time.Sleep(5 * time.Millisecond)
  217 
  218     assert.Error(t, router.Run(":3123"))
  219     testRequest(t, "http://localhost:3123/example")
  220 }
  221 
  222 func TestRunTooMuchParams(t *testing.T) {
  223     router := New()
  224     assert.Panics(t, func() {
  225         assert.NoError(t, router.Run("2", "2"))
  226     })
  227 }
  228 
  229 func TestRunWithPort(t *testing.T) {
  230     router := New()
  231     go func() {
  232         router.GET("/example", func(c *Context) { c.String(http.StatusOK, "it worked") })
  233         assert.NoError(t, router.Run(":5150"))
  234     }()
  235     // have to wait for the goroutine to start and run the server
  236     // otherwise the main thread will complete
  237     time.Sleep(5 * time.Millisecond)
  238 
  239     assert.Error(t, router.Run(":5150"))
  240     testRequest(t, "http://localhost:5150/example")
  241 }
  242 
  243 func TestUnixSocket(t *testing.T) {
  244     router := New()
  245 
  246     unixTestSocket := filepath.Join(os.TempDir(), "unix_unit_test")
  247 
  248     defer os.Remove(unixTestSocket)
  249 
  250     go func() {
  251         router.GET("/example", func(c *Context) { c.String(http.StatusOK, "it worked") })
  252         assert.NoError(t, router.RunUnix(unixTestSocket))
  253     }()
  254     // have to wait for the goroutine to start and run the server
  255     // otherwise the main thread will complete
  256     time.Sleep(5 * time.Millisecond)
  257 
  258     c, err := net.Dial("unix", unixTestSocket)
  259     assert.NoError(t, err)
  260 
  261     fmt.Fprint(c, "GET /example HTTP/1.0\r\n\r\n")
  262     scanner := bufio.NewScanner(c)
  263     var response string
  264     for scanner.Scan() {
  265         response += scanner.Text()
  266     }
  267     assert.Contains(t, response, "HTTP/1.0 200", "should get a 200")
  268     assert.Contains(t, response, "it worked", "resp body should match")
  269 }
  270 
  271 func TestBadUnixSocket(t *testing.T) {
  272     router := New()
  273     assert.Error(t, router.RunUnix("#/tmp/unix_unit_test"))
  274 }
  275 
  276 func TestFileDescriptor(t *testing.T) {
  277     router := New()
  278 
  279     addr, err := net.ResolveTCPAddr("tcp", "localhost:0")
  280     assert.NoError(t, err)
  281     listener, err := net.ListenTCP("tcp", addr)
  282     assert.NoError(t, err)
  283     socketFile, err := listener.File()
  284     assert.NoError(t, err)
  285 
  286     go func() {
  287         router.GET("/example", func(c *Context) { c.String(http.StatusOK, "it worked") })
  288         assert.NoError(t, router.RunFd(int(socketFile.Fd())))
  289     }()
  290     // have to wait for the goroutine to start and run the server
  291     // otherwise the main thread will complete
  292     time.Sleep(5 * time.Millisecond)
  293 
  294     c, err := net.Dial("tcp", listener.Addr().String())
  295     assert.NoError(t, err)
  296 
  297     fmt.Fprintf(c, "GET /example HTTP/1.0\r\n\r\n")
  298     scanner := bufio.NewScanner(c)
  299     var response string
  300     for scanner.Scan() {
  301         response += scanner.Text()
  302     }
  303     assert.Contains(t, response, "HTTP/1.0 200", "should get a 200")
  304     assert.Contains(t, response, "it worked", "resp body should match")
  305 }
  306 
  307 func TestBadFileDescriptor(t *testing.T) {
  308     router := New()
  309     assert.Error(t, router.RunFd(0))
  310 }
  311 
  312 func TestListener(t *testing.T) {
  313     router := New()
  314     addr, err := net.ResolveTCPAddr("tcp", "localhost:0")
  315     assert.NoError(t, err)
  316     listener, err := net.ListenTCP("tcp", addr)
  317     assert.NoError(t, err)
  318     go func() {
  319         router.GET("/example", func(c *Context) { c.String(http.StatusOK, "it worked") })
  320         assert.NoError(t, router.RunListener(listener))
  321     }()
  322     // have to wait for the goroutine to start and run the server
  323     // otherwise the main thread will complete
  324     time.Sleep(5 * time.Millisecond)
  325 
  326     c, err := net.Dial("tcp", listener.Addr().String())
  327     assert.NoError(t, err)
  328 
  329     fmt.Fprintf(c, "GET /example HTTP/1.0\r\n\r\n")
  330     scanner := bufio.NewScanner(c)
  331     var response string
  332     for scanner.Scan() {
  333         response += scanner.Text()
  334     }
  335     assert.Contains(t, response, "HTTP/1.0 200", "should get a 200")
  336     assert.Contains(t, response, "it worked", "resp body should match")
  337 }
  338 
  339 func TestBadListener(t *testing.T) {
  340     router := New()
  341     addr, err := net.ResolveTCPAddr("tcp", "localhost:10086")
  342     assert.NoError(t, err)
  343     listener, err := net.ListenTCP("tcp", addr)
  344     assert.NoError(t, err)
  345     listener.Close()
  346     assert.Error(t, router.RunListener(listener))
  347 }
  348 
  349 func TestWithHttptestWithAutoSelectedPort(t *testing.T) {
  350     router := New()
  351     router.GET("/example", func(c *Context) { c.String(http.StatusOK, "it worked") })
  352 
  353     ts := httptest.NewServer(router)
  354     defer ts.Close()
  355 
  356     testRequest(t, ts.URL+"/example")
  357 }
  358 
  359 func TestConcurrentHandleContext(t *testing.T) {
  360     router := New()
  361     router.GET("/", func(c *Context) {
  362         c.Request.URL.Path = "/example"
  363         router.HandleContext(c)
  364     })
  365     router.GET("/example", func(c *Context) { c.String(http.StatusOK, "it worked") })
  366 
  367     var wg sync.WaitGroup
  368     iterations := 200
  369     wg.Add(iterations)
  370     for i := 0; i < iterations; i++ {
  371         go func() {
  372             testGetRequestHandler(t, router, "/")
  373             wg.Done()
  374         }()
  375     }
  376     wg.Wait()
  377 }
  378 
  379 // func TestWithHttptestWithSpecifiedPort(t *testing.T) {
  380 //  router := New()
  381 //  router.GET("/example", func(c *Context) { c.String(http.StatusOK, "it worked") })
  382 
  383 //  l, _ := net.Listen("tcp", ":8033")
  384 //  ts := httptest.Server{
  385 //      Listener: l,
  386 //      Config:   &http.Server{Handler: router},
  387 //  }
  388 //  ts.Start()
  389 //  defer ts.Close()
  390 
  391 //  testRequest(t, "http://localhost:8033/example")
  392 // }
  393 
  394 func testGetRequestHandler(t *testing.T, h http.Handler, url string) {
  395     req, err := http.NewRequest(http.MethodGet, url, nil)
  396     assert.NoError(t, err)
  397 
  398     w := httptest.NewRecorder()
  399     h.ServeHTTP(w, req)
  400 
  401     assert.Equal(t, "it worked", w.Body.String(), "resp body should match")
  402     assert.Equal(t, 200, w.Code, "should get a 200")
  403 }
  404 
  405 func TestTreeRunDynamicRouting(t *testing.T) {
  406     router := New()
  407     router.GET("/aa/*xx", func(c *Context) { c.String(http.StatusOK, "/aa/*xx") })
  408     router.GET("/ab/*xx", func(c *Context) { c.String(http.StatusOK, "/ab/*xx") })
  409     router.GET("/", func(c *Context) { c.String(http.StatusOK, "home") })
  410     router.GET("/:cc", func(c *Context) { c.String(http.StatusOK, "/:cc") })
  411     router.GET("/c1/:dd/e", func(c *Context) { c.String(http.StatusOK, "/c1/:dd/e") })
  412     router.GET("/c1/:dd/e1", func(c *Context) { c.String(http.StatusOK, "/c1/:dd/e1") })
  413     router.GET("/c1/:dd/f1", func(c *Context) { c.String(http.StatusOK, "/c1/:dd/f1") })
  414     router.GET("/c1/:dd/f2", func(c *Context) { c.String(http.StatusOK, "/c1/:dd/f2") })
  415     router.GET("/:cc/cc", func(c *Context) { c.String(http.StatusOK, "/:cc/cc") })
  416     router.GET("/:cc/:dd/ee", func(c *Context) { c.String(http.StatusOK, "/:cc/:dd/ee") })
  417     router.GET("/:cc/:dd/f", func(c *Context) { c.String(http.StatusOK, "/:cc/:dd/f") })
  418     router.GET("/:cc/:dd/:ee/ff", func(c *Context) { c.String(http.StatusOK, "/:cc/:dd/:ee/ff") })
  419     router.GET("/:cc/:dd/:ee/:ff/gg", func(c *Context) { c.String(http.StatusOK, "/:cc/:dd/:ee/:ff/gg") })
  420     router.GET("/:cc/:dd/:ee/:ff/:gg/hh", func(c *Context) { c.String(http.StatusOK, "/:cc/:dd/:ee/:ff/:gg/hh") })
  421     router.GET("/get/test/abc/", func(c *Context) { c.String(http.StatusOK, "/get/test/abc/") })
  422     router.GET("/get/:param/abc/", func(c *Context) { c.String(http.StatusOK, "/get/:param/abc/") })
  423     router.GET("/something/:paramname/thirdthing", func(c *Context) { c.String(http.StatusOK, "/something/:paramname/thirdthing") })
  424     router.GET("/something/secondthing/test", func(c *Context) { c.String(http.StatusOK, "/something/secondthing/test") })
  425     router.GET("/get/abc", func(c *Context) { c.String(http.StatusOK, "/get/abc") })
  426     router.GET("/get/:param", func(c *Context) { c.String(http.StatusOK, "/get/:param") })
  427     router.GET("/get/abc/123abc", func(c *Context) { c.String(http.StatusOK, "/get/abc/123abc") })
  428     router.GET("/get/abc/:param", func(c *Context) { c.String(http.StatusOK, "/get/abc/:param") })
  429     router.GET("/get/abc/123abc/xxx8", func(c *Context) { c.String(http.StatusOK, "/get/abc/123abc/xxx8") })
  430     router.GET("/get/abc/123abc/:param", func(c *Context) { c.String(http.StatusOK, "/get/abc/123abc/:param") })
  431     router.GET("/get/abc/123abc/xxx8/1234", func(c *Context) { c.String(http.StatusOK, "/get/abc/123abc/xxx8/1234") })
  432     router.GET("/get/abc/123abc/xxx8/:param", func(c *Context) { c.String(http.StatusOK, "/get/abc/123abc/xxx8/:param") })
  433     router.GET("/get/abc/123abc/xxx8/1234/ffas", func(c *Context) { c.String(http.StatusOK, "/get/abc/123abc/xxx8/1234/ffas") })
  434     router.GET("/get/abc/123abc/xxx8/1234/:param", func(c *Context) { c.String(http.StatusOK, "/get/abc/123abc/xxx8/1234/:param") })
  435     router.GET("/get/abc/123abc/xxx8/1234/kkdd/12c", func(c *Context) { c.String(http.StatusOK, "/get/abc/123abc/xxx8/1234/kkdd/12c") })
  436     router.GET("/get/abc/123abc/xxx8/1234/kkdd/:param", func(c *Context) { c.String(http.StatusOK, "/get/abc/123abc/xxx8/1234/kkdd/:param") })
  437     router.GET("/get/abc/:param/test", func(c *Context) { c.String(http.StatusOK, "/get/abc/:param/test") })
  438     router.GET("/get/abc/123abd/:param", func(c *Context) { c.String(http.StatusOK, "/get/abc/123abd/:param") })
  439     router.GET("/get/abc/123abddd/:param", func(c *Context) { c.String(http.StatusOK, "/get/abc/123abddd/:param") })
  440     router.GET("/get/abc/123/:param", func(c *Context) { c.String(http.StatusOK, "/get/abc/123/:param") })
  441     router.GET("/get/abc/123abg/:param", func(c *Context) { c.String(http.StatusOK, "/get/abc/123abg/:param") })
  442     router.GET("/get/abc/123abf/:param", func(c *Context) { c.String(http.StatusOK, "/get/abc/123abf/:param") })
  443     router.GET("/get/abc/123abfff/:param", func(c *Context) { c.String(http.StatusOK, "/get/abc/123abfff/:param") })
  444 
  445     ts := httptest.NewServer(router)
  446     defer ts.Close()
  447 
  448     testRequest(t, ts.URL+"/", "", "home")
  449     testRequest(t, ts.URL+"/aa/aa", "", "/aa/*xx")
  450     testRequest(t, ts.URL+"/ab/ab", "", "/ab/*xx")
  451     testRequest(t, ts.URL+"/all", "", "/:cc")
  452     testRequest(t, ts.URL+"/all/cc", "", "/:cc/cc")
  453     testRequest(t, ts.URL+"/a/cc", "", "/:cc/cc")
  454     testRequest(t, ts.URL+"/c1/d/e", "", "/c1/:dd/e")
  455     testRequest(t, ts.URL+"/c1/d/e1", "", "/c1/:dd/e1")
  456     testRequest(t, ts.URL+"/c1/d/ee", "", "/:cc/:dd/ee")
  457     testRequest(t, ts.URL+"/c1/d/f", "", "/:cc/:dd/f")
  458     testRequest(t, ts.URL+"/c/d/ee", "", "/:cc/:dd/ee")
  459     testRequest(t, ts.URL+"/c/d/e/ff", "", "/:cc/:dd/:ee/ff")
  460     testRequest(t, ts.URL+"/c/d/e/f/gg", "", "/:cc/:dd/:ee/:ff/gg")
  461     testRequest(t, ts.URL+"/c/d/e/f/g/hh", "", "/:cc/:dd/:ee/:ff/:gg/hh")
  462     testRequest(t, ts.URL+"/cc/dd/ee/ff/gg/hh", "", "/:cc/:dd/:ee/:ff/:gg/hh")
  463     testRequest(t, ts.URL+"/a", "", "/:cc")
  464     testRequest(t, ts.URL+"/d", "", "/:cc")
  465     testRequest(t, ts.URL+"/ad", "", "/:cc")
  466     testRequest(t, ts.URL+"/dd", "", "/:cc")
  467     testRequest(t, ts.URL+"/aa", "", "/:cc")
  468     testRequest(t, ts.URL+"/aaa", "", "/:cc")
  469     testRequest(t, ts.URL+"/aaa/cc", "", "/:cc/cc")
  470     testRequest(t, ts.URL+"/ab", "", "/:cc")
  471     testRequest(t, ts.URL+"/abb", "", "/:cc")
  472     testRequest(t, ts.URL+"/abb/cc", "", "/:cc/cc")
  473     testRequest(t, ts.URL+"/dddaa", "", "/:cc")
  474     testRequest(t, ts.URL+"/allxxxx", "", "/:cc")
  475     testRequest(t, ts.URL+"/alldd", "", "/:cc")
  476     testRequest(t, ts.URL+"/cc/cc", "", "/:cc/cc")
  477     testRequest(t, ts.URL+"/ccc/cc", "", "/:cc/cc")
  478     testRequest(t, ts.URL+"/deedwjfs/cc", "", "/:cc/cc")
  479     testRequest(t, ts.URL+"/acllcc/cc", "", "/:cc/cc")
  480     testRequest(t, ts.URL+"/get/test/abc/", "", "/get/test/abc/")
  481     testRequest(t, ts.URL+"/get/testaa/abc/", "", "/get/:param/abc/")
  482     testRequest(t, ts.URL+"/get/te/abc/", "", "/get/:param/abc/")
  483     testRequest(t, ts.URL+"/get/xx/abc/", "", "/get/:param/abc/")
  484     testRequest(t, ts.URL+"/get/tt/abc/", "", "/get/:param/abc/")
  485     testRequest(t, ts.URL+"/get/a/abc/", "", "/get/:param/abc/")
  486     testRequest(t, ts.URL+"/get/t/abc/", "", "/get/:param/abc/")
  487     testRequest(t, ts.URL+"/get/aa/abc/", "", "/get/:param/abc/")
  488     testRequest(t, ts.URL+"/get/abas/abc/", "", "/get/:param/abc/")
  489     testRequest(t, ts.URL+"/something/secondthing/test", "", "/something/secondthing/test")
  490     testRequest(t, ts.URL+"/something/secondthingaaaa/thirdthing", "", "/something/:paramname/thirdthing")
  491     testRequest(t, ts.URL+"/something/abcdad/thirdthing", "", "/something/:paramname/thirdthing")
  492     testRequest(t, ts.URL+"/something/se/thirdthing", "", "/something/:paramname/thirdthing")
  493     testRequest(t, ts.URL+"/something/s/thirdthing", "", "/something/:paramname/thirdthing")
  494     testRequest(t, ts.URL+"/something/secondthing/thirdthing", "", "/something/:paramname/thirdthing")
  495     testRequest(t, ts.URL+"/get/abc", "", "/get/abc")
  496     testRequest(t, ts.URL+"/get/a", "", "/get/:param")
  497     testRequest(t, ts.URL+"/get/abz", "", "/get/:param")
  498     testRequest(t, ts.URL+"/get/12a", "", "/get/:param")
  499     testRequest(t, ts.URL+"/get/abcd", "", "/get/:param")
  500     testRequest(t, ts.URL+"/get/abc/123abc", "", "/get/abc/123abc")
  501     testRequest(t, ts.URL+"/get/abc/12", "", "/get/abc/:param")
  502     testRequest(t, ts.URL+"/get/abc/123ab", "", "/get/abc/:param")
  503     testRequest(t, ts.URL+"/get/abc/xyz", "", "/get/abc/:param")
  504     testRequest(t, ts.URL+"/get/abc/123abcddxx", "", "/get/abc/:param")
  505     testRequest(t, ts.URL+"/get/abc/123abc/xxx8", "", "/get/abc/123abc/xxx8")
  506     testRequest(t, ts.URL+"/get/abc/123abc/x", "", "/get/abc/123abc/:param")
  507     testRequest(t, ts.URL+"/get/abc/123abc/xxx", "", "/get/abc/123abc/:param")
  508     testRequest(t, ts.URL+"/get/abc/123abc/abc", "", "/get/abc/123abc/:param")
  509     testRequest(t, ts.URL+"/get/abc/123abc/xxx8xxas", "", "/get/abc/123abc/:param")
  510     testRequest(t, ts.URL+"/get/abc/123abc/xxx8/1234", "", "/get/abc/123abc/xxx8/1234")
  511     testRequest(t, ts.URL+"/get/abc/123abc/xxx8/1", "", "/get/abc/123abc/xxx8/:param")
  512     testRequest(t, ts.URL+"/get/abc/123abc/xxx8/123", "", "/get/abc/123abc/xxx8/:param")
  513     testRequest(t, ts.URL+"/get/abc/123abc/xxx8/78k", "", "/get/abc/123abc/xxx8/:param")
  514     testRequest(t, ts.URL+"/get/abc/123abc/xxx8/1234xxxd", "", "/get/abc/123abc/xxx8/:param")
  515     testRequest(t, ts.URL+"/get/abc/123abc/xxx8/1234/ffas", "", "/get/abc/123abc/xxx8/1234/ffas")
  516     testRequest(t, ts.URL+"/get/abc/123abc/xxx8/1234/f", "", "/get/abc/123abc/xxx8/1234/:param")
  517     testRequest(t, ts.URL+"/get/abc/123abc/xxx8/1234/ffa", "", "/get/abc/123abc/xxx8/1234/:param")
  518     testRequest(t, ts.URL+"/get/abc/123abc/xxx8/1234/kka", "", "/get/abc/123abc/xxx8/1234/:param")
  519     testRequest(t, ts.URL+"/get/abc/123abc/xxx8/1234/ffas321", "", "/get/abc/123abc/xxx8/1234/:param")
  520     testRequest(t, ts.URL+"/get/abc/123abc/xxx8/1234/kkdd/12c", "", "/get/abc/123abc/xxx8/1234/kkdd/12c")
  521     testRequest(t, ts.URL+"/get/abc/123abc/xxx8/1234/kkdd/1", "", "/get/abc/123abc/xxx8/1234/kkdd/:param")
  522     testRequest(t, ts.URL+"/get/abc/123abc/xxx8/1234/kkdd/12", "", "/get/abc/123abc/xxx8/1234/kkdd/:param")
  523     testRequest(t, ts.URL+"/get/abc/123abc/xxx8/1234/kkdd/12b", "", "/get/abc/123abc/xxx8/1234/kkdd/:param")
  524     testRequest(t, ts.URL+"/get/abc/123abc/xxx8/1234/kkdd/34", "", "/get/abc/123abc/xxx8/1234/kkdd/:param")
  525     testRequest(t, ts.URL+"/get/abc/123abc/xxx8/1234/kkdd/12c2e3", "", "/get/abc/123abc/xxx8/1234/kkdd/:param")
  526     testRequest(t, ts.URL+"/get/abc/12/test", "", "/get/abc/:param/test")
  527     testRequest(t, ts.URL+"/get/abc/123abdd/test", "", "/get/abc/:param/test")
  528     testRequest(t, ts.URL+"/get/abc/123abdddf/test", "", "/get/abc/:param/test")
  529     testRequest(t, ts.URL+"/get/abc/123ab/test", "", "/get/abc/:param/test")
  530     testRequest(t, ts.URL+"/get/abc/123abgg/test", "", "/get/abc/:param/test")
  531     testRequest(t, ts.URL+"/get/abc/123abff/test", "", "/get/abc/:param/test")
  532     testRequest(t, ts.URL+"/get/abc/123abffff/test", "", "/get/abc/:param/test")
  533     testRequest(t, ts.URL+"/get/abc/123abd/test", "", "/get/abc/123abd/:param")
  534     testRequest(t, ts.URL+"/get/abc/123abddd/test", "", "/get/abc/123abddd/:param")
  535     testRequest(t, ts.URL+"/get/abc/123/test22", "", "/get/abc/123/:param")
  536     testRequest(t, ts.URL+"/get/abc/123abg/test", "", "/get/abc/123abg/:param")
  537     testRequest(t, ts.URL+"/get/abc/123abf/testss", "", "/get/abc/123abf/:param")
  538     testRequest(t, ts.URL+"/get/abc/123abfff/te", "", "/get/abc/123abfff/:param")
  539     // 404 not found
  540     testRequest(t, ts.URL+"/c/d/e", "404 Not Found")
  541     testRequest(t, ts.URL+"/c/d/e1", "404 Not Found")
  542     testRequest(t, ts.URL+"/c/d/eee", "404 Not Found")
  543     testRequest(t, ts.URL+"/c1/d/eee", "404 Not Found")
  544     testRequest(t, ts.URL+"/c1/d/e2", "404 Not Found")
  545     testRequest(t, ts.URL+"/cc/dd/ee/ff/gg/hh1", "404 Not Found")
  546     testRequest(t, ts.URL+"/a/dd", "404 Not Found")
  547     testRequest(t, ts.URL+"/addr/dd/aa", "404 Not Found")
  548     testRequest(t, ts.URL+"/something/secondthing/121", "404 Not Found")
  549 }