forked from External/mediamtx
This commit is contained in:
parent
6e7a6fe71a
commit
4b4d57f18e
4 changed files with 11 additions and 1 deletions
|
|
@ -204,6 +204,9 @@ components:
|
||||||
PathConf:
|
PathConf:
|
||||||
type: object
|
type: object
|
||||||
properties:
|
properties:
|
||||||
|
name:
|
||||||
|
type: string
|
||||||
|
|
||||||
# General
|
# General
|
||||||
source:
|
source:
|
||||||
type: string
|
type: string
|
||||||
|
|
|
||||||
|
|
@ -48,6 +48,7 @@ func TestConfFromFile(t *testing.T) {
|
||||||
pa, ok := conf.Paths["cam1"]
|
pa, ok := conf.Paths["cam1"]
|
||||||
require.Equal(t, true, ok)
|
require.Equal(t, true, ok)
|
||||||
require.Equal(t, &Path{
|
require.Equal(t, &Path{
|
||||||
|
Name: "cam1",
|
||||||
Source: "publisher",
|
Source: "publisher",
|
||||||
SourceOnDemandStartTimeout: 10 * StringDuration(time.Second),
|
SourceOnDemandStartTimeout: 10 * StringDuration(time.Second),
|
||||||
SourceOnDemandCloseAfter: 10 * StringDuration(time.Second),
|
SourceOnDemandCloseAfter: 10 * StringDuration(time.Second),
|
||||||
|
|
|
||||||
|
|
@ -49,7 +49,8 @@ func srtCheckPassphrase(passphrase string) error {
|
||||||
|
|
||||||
// Path is a path configuration.
|
// Path is a path configuration.
|
||||||
type Path struct {
|
type Path struct {
|
||||||
Regexp *regexp.Regexp `json:"-"` // filled by Check()
|
Regexp *regexp.Regexp `json:"-"` // filled by Check()
|
||||||
|
Name string `json:"name"` // filled by Check()
|
||||||
|
|
||||||
// General
|
// General
|
||||||
Source string `json:"source"`
|
Source string `json:"source"`
|
||||||
|
|
@ -209,6 +210,8 @@ func (pconf Path) Clone() *Path {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (pconf *Path) check(conf *Conf, name string) error {
|
func (pconf *Path) check(conf *Conf, name string) error {
|
||||||
|
pconf.Name = name
|
||||||
|
|
||||||
switch {
|
switch {
|
||||||
case name == "all_others", name == "all":
|
case name == "all_others", name == "all":
|
||||||
pconf.Regexp = regexp.MustCompile("^.*$")
|
pconf.Regexp = regexp.MustCompile("^.*$")
|
||||||
|
|
|
||||||
|
|
@ -255,8 +255,10 @@ func TestAPIConfigPathsList(t *testing.T) {
|
||||||
httpRequest(t, hc, http.MethodGet, "http://localhost:9997/v3/config/paths/list", nil, &out)
|
httpRequest(t, hc, http.MethodGet, "http://localhost:9997/v3/config/paths/list", nil, &out)
|
||||||
require.Equal(t, 2, out.ItemCount)
|
require.Equal(t, 2, out.ItemCount)
|
||||||
require.Equal(t, 1, out.PageCount)
|
require.Equal(t, 1, out.PageCount)
|
||||||
|
require.Equal(t, "path1", out.Items[0]["name"])
|
||||||
require.Equal(t, "myuser1", out.Items[0]["readUser"])
|
require.Equal(t, "myuser1", out.Items[0]["readUser"])
|
||||||
require.Equal(t, "mypass1", out.Items[0]["readPass"])
|
require.Equal(t, "mypass1", out.Items[0]["readPass"])
|
||||||
|
require.Equal(t, "path2", out.Items[1]["name"])
|
||||||
require.Equal(t, "myuser2", out.Items[1]["readUser"])
|
require.Equal(t, "myuser2", out.Items[1]["readUser"])
|
||||||
require.Equal(t, "mypass2", out.Items[1]["readPass"])
|
require.Equal(t, "mypass2", out.Items[1]["readPass"])
|
||||||
}
|
}
|
||||||
|
|
@ -274,6 +276,7 @@ func TestAPIConfigPathsGet(t *testing.T) {
|
||||||
|
|
||||||
var out map[string]interface{}
|
var out map[string]interface{}
|
||||||
httpRequest(t, hc, http.MethodGet, "http://localhost:9997/v3/config/paths/get/my/path", nil, &out)
|
httpRequest(t, hc, http.MethodGet, "http://localhost:9997/v3/config/paths/get/my/path", nil, &out)
|
||||||
|
require.Equal(t, "my/path", out["name"])
|
||||||
require.Equal(t, "myuser", out["readUser"])
|
require.Equal(t, "myuser", out["readUser"])
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue