diff --git a/apidocs/openapi.yaml b/apidocs/openapi.yaml index 167b032d896..c03442ce863 100644 --- a/apidocs/openapi.yaml +++ b/apidocs/openapi.yaml @@ -204,6 +204,9 @@ components: PathConf: type: object properties: + name: + type: string + # General source: type: string diff --git a/internal/conf/conf_test.go b/internal/conf/conf_test.go index d9fe00e96b2..729f05099fc 100644 --- a/internal/conf/conf_test.go +++ b/internal/conf/conf_test.go @@ -48,6 +48,7 @@ func TestConfFromFile(t *testing.T) { pa, ok := conf.Paths["cam1"] require.Equal(t, true, ok) require.Equal(t, &Path{ + Name: "cam1", Source: "publisher", SourceOnDemandStartTimeout: 10 * StringDuration(time.Second), SourceOnDemandCloseAfter: 10 * StringDuration(time.Second), diff --git a/internal/conf/path.go b/internal/conf/path.go index 75e2f7cb8d5..e3f16d8b8ed 100644 --- a/internal/conf/path.go +++ b/internal/conf/path.go @@ -49,7 +49,8 @@ func srtCheckPassphrase(passphrase string) error { // Path is a path configuration. 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 Source string `json:"source"` @@ -209,6 +210,8 @@ func (pconf Path) Clone() *Path { } func (pconf *Path) check(conf *Conf, name string) error { + pconf.Name = name + switch { case name == "all_others", name == "all": pconf.Regexp = regexp.MustCompile("^.*$") diff --git a/internal/core/api_test.go b/internal/core/api_test.go index 41770870bd2..4c39bbd265a 100644 --- a/internal/core/api_test.go +++ b/internal/core/api_test.go @@ -255,8 +255,10 @@ func TestAPIConfigPathsList(t *testing.T) { httpRequest(t, hc, http.MethodGet, "http://localhost:9997/v3/config/paths/list", nil, &out) require.Equal(t, 2, out.ItemCount) 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, "mypass1", out.Items[0]["readPass"]) + require.Equal(t, "path2", out.Items[1]["name"]) require.Equal(t, "myuser2", out.Items[1]["readUser"]) require.Equal(t, "mypass2", out.Items[1]["readPass"]) } @@ -274,6 +276,7 @@ func TestAPIConfigPathsGet(t *testing.T) { var out map[string]interface{} 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"]) }