mirror of
https://github.com/ossrs/srs.git
synced 2025-03-09 15:49:59 +00:00
TEST: Upgrade pion to v3.2.9. (#3567)
------ Co-authored-by: chundonglinlin <chundonglinlin@163.com>
This commit is contained in:
parent
900c4cdd97
commit
1545425e06
1383 changed files with 118469 additions and 41421 deletions
114
trunk/3rdparty/srs-bench/blackbox/http_api_test.go
vendored
114
trunk/3rdparty/srs-bench/blackbox/http_api_test.go
vendored
|
@ -21,73 +21,73 @@
|
|||
package blackbox
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"github.com/ossrs/go-oryx-lib/errors"
|
||||
"github.com/ossrs/go-oryx-lib/logger"
|
||||
"net/http"
|
||||
"sync"
|
||||
"testing"
|
||||
"time"
|
||||
"context"
|
||||
"fmt"
|
||||
"github.com/ossrs/go-oryx-lib/errors"
|
||||
"github.com/ossrs/go-oryx-lib/logger"
|
||||
"net/http"
|
||||
"sync"
|
||||
"testing"
|
||||
"time"
|
||||
)
|
||||
|
||||
func TestFast_Http_Api_Basic_Auth(t *testing.T) {
|
||||
// This case is run in parallel.
|
||||
t.Parallel()
|
||||
// This case is run in parallel.
|
||||
t.Parallel()
|
||||
|
||||
// Setup the max timeout for this case.
|
||||
ctx, cancel := context.WithTimeout(logger.WithContext(context.Background()), time.Duration(*srsTimeout)*time.Millisecond)
|
||||
defer cancel()
|
||||
// Setup the max timeout for this case.
|
||||
ctx, cancel := context.WithTimeout(logger.WithContext(context.Background()), time.Duration(*srsTimeout)*time.Millisecond)
|
||||
defer cancel()
|
||||
|
||||
// Check a set of errors.
|
||||
var r0, r1, r2, r3, r4, r5, r6 error
|
||||
defer func(ctx context.Context) {
|
||||
if err := filterTestError(ctx.Err(), r0, r1, r2, r3, r4, r5, r6); err != nil {
|
||||
t.Errorf("Fail for err %+v", err)
|
||||
} else {
|
||||
logger.Tf(ctx, "test done with err %+v", err)
|
||||
}
|
||||
}(ctx)
|
||||
// Check a set of errors.
|
||||
var r0, r1, r2, r3, r4, r5, r6 error
|
||||
defer func(ctx context.Context) {
|
||||
if err := filterTestError(ctx.Err(), r0, r1, r2, r3, r4, r5, r6); err != nil {
|
||||
t.Errorf("Fail for err %+v", err)
|
||||
} else {
|
||||
logger.Tf(ctx, "test done with err %+v", err)
|
||||
}
|
||||
}(ctx)
|
||||
|
||||
var wg sync.WaitGroup
|
||||
defer wg.Wait()
|
||||
var wg sync.WaitGroup
|
||||
defer wg.Wait()
|
||||
|
||||
// Start SRS server and wait for it to be ready.
|
||||
svr := NewSRSServer(func(v *srsServer) {
|
||||
v.envs = []string{
|
||||
"SRS_HTTP_API_AUTH_ENABLED=on",
|
||||
"SRS_HTTP_API_AUTH_USERNAME=admin",
|
||||
"SRS_HTTP_API_AUTH_PASSWORD=admin",
|
||||
}
|
||||
})
|
||||
wg.Add(1)
|
||||
go func() {
|
||||
defer wg.Done()
|
||||
r0 = svr.Run(ctx, cancel)
|
||||
}()
|
||||
// Start SRS server and wait for it to be ready.
|
||||
svr := NewSRSServer(func(v *srsServer) {
|
||||
v.envs = []string{
|
||||
"SRS_HTTP_API_AUTH_ENABLED=on",
|
||||
"SRS_HTTP_API_AUTH_USERNAME=admin",
|
||||
"SRS_HTTP_API_AUTH_PASSWORD=admin",
|
||||
}
|
||||
})
|
||||
wg.Add(1)
|
||||
go func() {
|
||||
defer wg.Done()
|
||||
r0 = svr.Run(ctx, cancel)
|
||||
}()
|
||||
|
||||
<-svr.ReadyCtx().Done()
|
||||
<-svr.ReadyCtx().Done()
|
||||
|
||||
if true {
|
||||
defer cancel()
|
||||
if true {
|
||||
defer cancel()
|
||||
|
||||
var res *http.Response
|
||||
url := fmt.Sprintf("http://admin:admin@localhost:%v/api/v1/versions", svr.APIPort())
|
||||
res, r1 = http.Get(url)
|
||||
if r1 == nil && res.StatusCode != 200 {
|
||||
r2 = errors.Errorf("get status code=%v, expect=200", res.StatusCode)
|
||||
}
|
||||
var res *http.Response
|
||||
url := fmt.Sprintf("http://admin:admin@localhost:%v/api/v1/versions", svr.APIPort())
|
||||
res, r1 = http.Get(url)
|
||||
if r1 == nil && res.StatusCode != 200 {
|
||||
r2 = errors.Errorf("get status code=%v, expect=200", res.StatusCode)
|
||||
}
|
||||
|
||||
url = fmt.Sprintf("http://admin:123456@localhost:%v/api/v1/versions", svr.APIPort())
|
||||
res, r3 = http.Get(url)
|
||||
if r3 == nil && res.StatusCode != 401 {
|
||||
r4 = errors.Errorf("get status code=%v, expect=401", res.StatusCode)
|
||||
}
|
||||
url = fmt.Sprintf("http://admin:123456@localhost:%v/api/v1/versions", svr.APIPort())
|
||||
res, r3 = http.Get(url)
|
||||
if r3 == nil && res.StatusCode != 401 {
|
||||
r4 = errors.Errorf("get status code=%v, expect=401", res.StatusCode)
|
||||
}
|
||||
|
||||
url = fmt.Sprintf("http://localhost:%v/api/v1/versions", svr.APIPort())
|
||||
res, r5 = http.Get(url)
|
||||
if r5 == nil && res.StatusCode != 401 {
|
||||
r6 = errors.Errorf("get status code=%v, expect=401", res.StatusCode)
|
||||
}
|
||||
}
|
||||
url = fmt.Sprintf("http://localhost:%v/api/v1/versions", svr.APIPort())
|
||||
res, r5 = http.Get(url)
|
||||
if r5 == nil && res.StatusCode != 401 {
|
||||
r6 = errors.Errorf("get status code=%v, expect=401", res.StatusCode)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue