From c029b2a78ce6937789011f3c535332d90b6c43f7 Mon Sep 17 00:00:00 2001 From: Michael Mayer Date: Tue, 9 Nov 2021 16:55:16 +0100 Subject: [PATCH] Docker: Rename and update dummy-webdav service --- docker-compose.drone.yml | 4 ++-- docker-compose.postgres.yml | 4 ++-- docker-compose.yml | 10 +++++++--- internal/api/account_test.go | 10 +++++----- internal/entity/account_fixtures.go | 12 ++++++------ internal/entity/account_test.go | 4 ++-- internal/remote/discover_test.go | 12 ++++++------ internal/remote/webdav/webdav_test.go | 2 +- 8 files changed, 31 insertions(+), 27 deletions(-) diff --git a/docker-compose.drone.yml b/docker-compose.drone.yml index 1ee6cb681..fbcd54779 100644 --- a/docker-compose.drone.yml +++ b/docker-compose.drone.yml @@ -11,7 +11,7 @@ services: - apparmor:unconfined depends_on: - mariadb - - webdav-dummy + - dummy-webdav volumes: - "~/.cache/npm:/root/.cache/npm" - "~/.cache/go-mod:/go/pkg/mod" @@ -154,5 +154,5 @@ services: MYSQL_PASSWORD: photoprism MYSQL_DATABASE: photoprism - webdav-dummy: + dummy-webdav: image: photoprism/webdav:20211021 diff --git a/docker-compose.postgres.yml b/docker-compose.postgres.yml index f061c22cb..3b49fcdd0 100644 --- a/docker-compose.postgres.yml +++ b/docker-compose.postgres.yml @@ -11,7 +11,7 @@ services: image: photoprism/photoprism:develop depends_on: - postgres - - webdav-dummy + - dummy-webdav security_opt: - seccomp:unconfined - apparmor:unconfined @@ -76,7 +76,7 @@ services: POSTGRES_USER: photoprism POSTGRES_PASSWORD: photoprism - webdav-dummy: + dummy-webdav: image: photoprism/webdav:20211021 volumes: diff --git a/docker-compose.yml b/docker-compose.yml index b99db782e..525cbaf99 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -9,7 +9,7 @@ services: image: photoprism/photoprism:develop depends_on: - mariadb - - webdav-dummy + - dummy-webdav security_opt: - seccomp:unconfined - apparmor:unconfined @@ -98,8 +98,12 @@ services: MYSQL_PASSWORD: photoprism MYSQL_DATABASE: photoprism - webdav-dummy: - image: photoprism/webdav:20211021 + ## Dummy WebDAV Server + dummy-webdav: + image: photoprism/dummy-webdav:20211109 + environment: + WEBDAV_USERNAME: admin + WEBDAV_PASSWORD: photoprism volumes: go-mod: diff --git a/internal/api/account_test.go b/internal/api/account_test.go index 9a822d109..a82c5e7d5 100644 --- a/internal/api/account_test.go +++ b/internal/api/account_test.go @@ -19,7 +19,7 @@ func TestSearchAccounts(t *testing.T) { val := gjson.Get(r.Body.String(), "#(AccName=\"Test Account\").AccURL") count := gjson.Get(r.Body.String(), "#") assert.LessOrEqual(t, int64(1), count.Int()) - assert.Equal(t, "http://webdav-dummy/", val.String()) + assert.Equal(t, "http://dummy-webdav/", val.String()) assert.Equal(t, http.StatusOK, r.Code) }) t.Run("invalid request", func(t *testing.T) { @@ -111,7 +111,7 @@ func TestCreateAccount(t *testing.T) { t.Run("successful request", func(t *testing.T) { app, router, _ := NewApiTest() CreateAccount(router) - r := PerformRequestWithBody(app, "POST", "/api/v1/accounts", `{"AccName": "CreateTest", "AccOwner": "Test", "AccUrl": "http://webdav-dummy/", "AccType": "webdav", + r := PerformRequestWithBody(app, "POST", "/api/v1/accounts", `{"AccName": "CreateTest", "AccOwner": "Test", "AccUrl": "http://dummy-webdav/", "AccType": "webdav", "AccKey": "123", "AccUser": "admin", "AccPass": "photoprism", "AccError": "", "AccShare": false, "AccSync": false, "RetryLimit": 3, "SharePath": "", "ShareSize": "", "ShareExpires": 0, "SyncPath": "", "SyncInterval": 3, "SyncUpload": false, "SyncDownload": false, "SyncFilenames": false, "SyncRaw": false}`) val := gjson.Get(r.Body.String(), "AccOwner") @@ -123,7 +123,7 @@ func TestCreateAccount(t *testing.T) { func TestUpdateAccount(t *testing.T) { app, router, _ := NewApiTest() CreateAccount(router) - r := PerformRequestWithBody(app, "POST", "/api/v1/accounts", `{"AccName": "CreateTest3", "AccOwner": "TestUpdate", "AccUrl": "http://webdav-dummy/", "AccType": "webdav", + r := PerformRequestWithBody(app, "POST", "/api/v1/accounts", `{"AccName": "CreateTest3", "AccOwner": "TestUpdate", "AccUrl": "http://dummy-webdav/", "AccType": "webdav", "AccKey": "123", "AccUser": "admin", "AccPass": "photoprism", "AccError": "", "AccShare": false, "AccSync": false, "RetryLimit": 3, "SharePath": "", "ShareSize": "", "ShareExpires": 0, "SyncPath": "", "SyncInterval": 5, "SyncUpload": false, "SyncDownload": false, "SyncFilenames": false, "SyncRaw": false}`) val := gjson.Get(r.Body.String(), "AccOwner") @@ -131,7 +131,7 @@ func TestUpdateAccount(t *testing.T) { val2 := gjson.Get(r.Body.String(), "SyncInterval") assert.Equal(t, int64(5), val2.Int()) val3 := gjson.Get(r.Body.String(), "AccName") - assert.Equal(t, "Webdav-Dummy", val3.String()) + assert.Equal(t, "Dummy-Webdav", val3.String()) assert.Equal(t, http.StatusOK, r.Code) id := gjson.Get(r.Body.String(), "ID").String() @@ -170,7 +170,7 @@ func TestUpdateAccount(t *testing.T) { func TestDeleteAccount(t *testing.T) { app, router, _ := NewApiTest() CreateAccount(router) - r := PerformRequestWithBody(app, "POST", "/api/v1/accounts", `{"AccName": "DeleteTest", "AccOwner": "TestDelete", "AccUrl": "http://webdav-dummy/", "AccType": "webdav", + r := PerformRequestWithBody(app, "POST", "/api/v1/accounts", `{"AccName": "DeleteTest", "AccOwner": "TestDelete", "AccUrl": "http://dummy-webdav/", "AccType": "webdav", "AccKey": "123", "AccUser": "admin", "AccPass": "photoprism", "AccError": "", "AccShare": false, "AccSync": false, "RetryLimit": 3, "SharePath": "", "ShareSize": "", "ShareExpires": 0, "SyncPath": "", "SyncInterval": 5, "SyncUpload": false, "SyncDownload": false, "SyncFilenames": false, "SyncRaw": false}`) assert.Equal(t, http.StatusOK, r.Code) diff --git a/internal/entity/account_fixtures.go b/internal/entity/account_fixtures.go index 7b01b042b..5c70226b9 100644 --- a/internal/entity/account_fixtures.go +++ b/internal/entity/account_fixtures.go @@ -7,11 +7,11 @@ import ( type AccountMap map[string]Account var AccountFixtures = AccountMap{ - "webdav-dummy": { + "dummy-webdav": { ID: 1000000, AccName: "Test Account", AccOwner: "", - AccURL: "http://webdav-dummy/", + AccURL: "http://dummy-webdav/", AccType: "webdav", AccKey: "", AccUser: "admin", @@ -36,11 +36,11 @@ var AccountFixtures = AccountMap{ UpdatedAt: TimeStamp(), DeletedAt: nil, }, - "webdav-dummy2": { + "dummy-webdav2": { ID: 1000001, AccName: "Test Account2", AccOwner: "", - AccURL: "http://webdav-dummy/", + AccURL: "http://dummy-webdav/", AccType: "webdav", AccKey: "", AccUser: "admin", @@ -67,8 +67,8 @@ var AccountFixtures = AccountMap{ }, } -var AccountFixtureWebdavDummy = AccountFixtures["webdav-dummy"] -var AccountFixtureWebdavDummy2 = AccountFixtures["webdav-dummy2"] +var AccountFixtureWebdavDummy = AccountFixtures["dummy-webdav"] +var AccountFixtureWebdavDummy2 = AccountFixtures["dummy-webdav2"] // CreateLabelFixtures inserts known entities into the database for testing. func CreateAccountFixtures() { diff --git a/internal/entity/account_test.go b/internal/entity/account_test.go index c9a22870f..ccc4fcc21 100644 --- a/internal/entity/account_test.go +++ b/internal/entity/account_test.go @@ -116,7 +116,7 @@ func TestAccount_Delete(t *testing.T) { func TestAccount_Directories(t *testing.T) { t.Run("success", func(t *testing.T) { - account := Account{AccName: "DirectoriesAccount", AccOwner: "Owner", AccURL: "http://webdav-dummy/", AccType: "webdav", AccKey: "123", AccUser: "admin", AccPass: "photoprism", + account := Account{AccName: "DirectoriesAccount", AccOwner: "Owner", AccURL: "http://dummy-webdav/", AccType: "webdav", AccKey: "123", AccUser: "admin", AccPass: "photoprism", AccError: "", AccShare: true, AccSync: true, RetryLimit: 4, SharePath: "/home", ShareSize: "500", ShareExpires: 3500, SyncPath: "/sync", SyncInterval: 5, SyncUpload: true, SyncDownload: false, SyncFilenames: true, SyncRaw: false} @@ -141,7 +141,7 @@ func TestAccount_Directories(t *testing.T) { }) t.Run("no directory", func(t *testing.T) { - account := Account{AccName: "DirectoriesAccount", AccOwner: "Owner", AccURL: "http://webdav-dummy/", AccType: "xxx", AccKey: "123", AccUser: "admin", AccPass: "photoprism", + account := Account{AccName: "DirectoriesAccount", AccOwner: "Owner", AccURL: "http://dummy-webdav/", AccType: "xxx", AccKey: "123", AccUser: "admin", AccPass: "photoprism", AccError: "", AccShare: true, AccSync: true, RetryLimit: 4, SharePath: "/home", ShareSize: "500", ShareExpires: 3500, SyncPath: "/sync", SyncInterval: 5, SyncUpload: true, SyncDownload: false, SyncFilenames: true, SyncRaw: false} diff --git a/internal/remote/discover_test.go b/internal/remote/discover_test.go index 90430eff5..e37da4aea 100644 --- a/internal/remote/discover_test.go +++ b/internal/remote/discover_test.go @@ -8,29 +8,29 @@ import ( func TestDiscover(t *testing.T) { t.Run("webdav", func(t *testing.T) { - r, err := Discover("http://admin:photoprism@webdav-dummy/", "", "") + r, err := Discover("http://admin:photoprism@dummy-webdav/", "", "") if err != nil { t.Fatal(err) } - assert.Equal(t, "Webdav-Dummy", r.AccName) + assert.Equal(t, "Dummy-Webdav", r.AccName) assert.Equal(t, "webdav", r.AccType) - assert.Equal(t, "http://webdav-dummy/", r.AccURL) + assert.Equal(t, "http://dummy-webdav/", r.AccURL) assert.Equal(t, "admin", r.AccUser) assert.Equal(t, "photoprism", r.AccPass) }) t.Run("webdav password", func(t *testing.T) { - r, err := Discover("http://admin@webdav-dummy/", "", "photoprism") + r, err := Discover("http://admin@dummy-webdav/", "", "photoprism") if err != nil { t.Fatal(err) } - assert.Equal(t, "Webdav-Dummy", r.AccName) + assert.Equal(t, "Dummy-Webdav", r.AccName) assert.Equal(t, "webdav", r.AccType) - assert.Equal(t, "http://webdav-dummy/", r.AccURL) + assert.Equal(t, "http://dummy-webdav/", r.AccURL) assert.Equal(t, "admin", r.AccUser) assert.Equal(t, "photoprism", r.AccPass) }) diff --git a/internal/remote/webdav/webdav_test.go b/internal/remote/webdav/webdav_test.go index cf66c7700..26bc8c31d 100644 --- a/internal/remote/webdav/webdav_test.go +++ b/internal/remote/webdav/webdav_test.go @@ -11,7 +11,7 @@ import ( ) const ( - testUrl = "http://webdav-dummy/" + testUrl = "http://dummy-webdav/" testUser = "admin" testPass = "photoprism" )