From f8b964d8cffaa72d597fbfb630d7b55cadffb626 Mon Sep 17 00:00:00 2001 From: wang yan Date: Wed, 29 Aug 2018 18:54:00 +0800 Subject: [PATCH] Extend configuration length to 1024 in DB Signed-off-by: wang yan --- .travis.yml | 3 +- Makefile | 7 ++-- .../0002_update_v_length_properties.up.sql | 1 + src/ui/api/config_test.go | 35 +++++++++++++++++++ tests/docker-compose.test.yml | 4 +-- tools/migration/db/changelog.md | 6 +++- 6 files changed, 49 insertions(+), 7 deletions(-) create mode 100644 make/migrations/postgresql/0002_update_v_length_properties.up.sql diff --git a/.travis.yml b/.travis.yml index 34a58575e..3767aeb3d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -63,7 +63,8 @@ before_script: - echo $REGISTRY_URL - cd tests && sudo ./ldapprepare.sh && cd .. - sudo ./tests/admiral.sh - - sudo make -f make/photon/Makefile _build_db _build_registry -e VERSIONTAG=dev -e CLAIRDBVERSION=dev -e REGISTRYVERSION=${REG_VERSION} + - sudo make compile_adminserver + - sudo make -f make/photon/Makefile _build_adminiserver _build_db _build_registry -e VERSIONTAG=dev -e CLAIRDBVERSION=dev -e REGISTRYVERSION=${REG_VERSION} - sudo sed -i 's/__reg_version__/${REG_VERSION}-dev/g' ./make/docker-compose.test.yml - sudo sed -i 's/__version__/dev/g' ./make/docker-compose.test.yml - sudo mkdir -p ./make/common/config/registry/ && sudo mv ./tests/reg_config.yml ./make/common/config/registry/config.yml diff --git a/Makefile b/Makefile index 8630536f6..7bbda11bf 100644 --- a/Makefile +++ b/Makefile @@ -282,28 +282,31 @@ compile_clarity: fi @echo "Done." -compile_golangimage: compile_clarity +compile_adminserver: @echo "compiling binary for adminserver (golang image)..." @echo $(GOBASEPATH) @echo $(GOBUILDPATH) @$(DOCKERCMD) run --rm -v $(BUILDPATH):$(GOBUILDPATH) -w $(GOBUILDPATH_ADMINSERVER) $(GOBUILDIMAGE) $(GOIMAGEBUILD) -o $(GOBUILDMAKEPATH_ADMINSERVER)/$(ADMINSERVERBINARYNAME) @echo "Done." +compile_ui: @echo "compiling binary for ui (golang image)..." @echo $(GOBASEPATH) @echo $(GOBUILDPATH) @$(DOCKERCMD) run --rm -v $(BUILDPATH):$(GOBUILDPATH) -w $(GOBUILDPATH_UI) $(GOBUILDIMAGE) $(GOIMAGEBUILD) -o $(GOBUILDMAKEPATH_UI)/$(UIBINARYNAME) @echo "Done." +compile_jobservice: @echo "compiling binary for jobservice (golang image)..." @$(DOCKERCMD) run --rm -v $(BUILDPATH):$(GOBUILDPATH) -w $(GOBUILDPATH_JOBSERVICE) $(GOBUILDIMAGE) $(GOIMAGEBUILD) -o $(GOBUILDMAKEPATH_JOBSERVICE)/$(JOBSERVICEBINARYNAME) @echo "Done." +compile_registryctl: @echo "compiling binary for harbor registry controller (golang image)..." @$(DOCKERCMD) run --rm -v $(BUILDPATH):$(GOBUILDPATH) -w $(GOBUILDPATH_REGISTRYCTL) $(GOBUILDIMAGE) $(GOIMAGEBUILD) -o $(GOBUILDMAKEPATH_REGISTRYCTL)/$(REGISTRYCTLBINARYNAME) @echo "Done." -compile:check_environment compile_golangimage +compile:check_environment compile_clarity compile_adminserver compile_ui compile_jobservice compile_registryctl prepare: @echo "preparing..." diff --git a/make/migrations/postgresql/0002_update_v_length_properties.up.sql b/make/migrations/postgresql/0002_update_v_length_properties.up.sql new file mode 100644 index 000000000..1957346f6 --- /dev/null +++ b/make/migrations/postgresql/0002_update_v_length_properties.up.sql @@ -0,0 +1 @@ +ALTER TABLE properties ALTER COLUMN v TYPE varchar(1024); \ No newline at end of file diff --git a/src/ui/api/config_test.go b/src/ui/api/config_test.go index 7261d661e..695aee20e 100644 --- a/src/ui/api/config_test.go +++ b/src/ui/api/config_test.go @@ -118,3 +118,38 @@ func TestResetConfig(t *testing.T) { } t.Logf("%v", ccc) } + +func TestPutConfigMaxLength(t *testing.T) { + fmt.Println("Testing modifying configurations with max length.") + assert := assert.New(t) + apiTest := newHarborAPI() + + // length is 512,expected code: 200 + cfg := map[string]interface{}{ + common.LDAPGroupSearchFilter: "OSWvgTrQJuhiPRZt7eCReNku29vrtMBBD2cZt6jl7LQN4OZQcirqEhS2vCnkW8X1OAHMJxiO1LyEY26j" + + "YhBEiUFliPKDUt8Q9endowT3H60nJibEnCkSRVjix7QujXKRzlmvxcOK76v1oZAoWeHSwwtv7tZrOk16Jj5LTGYdLOnZd2LIgBniTKmceL" + + "VY5WOgcpmgQCfI5HLbzWsmAqmFfbsDbadirrEDiXYYfZQ0LnF8s6sD4H13eImgenAumXEsBRH43FT37AbNXNxzlaSs8IQYEdPLaMyKoXFb" + + "rfa0LPipwXnU7bl54IlWOTXwCwum0JGS4qBiMl6LwKUBle34ObZ9fTLh5dFOVE1GdzrGE0kQ7qUmYjMZafQbSXzV80zTc22aZt3RQa9Gxt" + + "Dn2VqtgcoKAiZHkEySStiwOJtZpwuplyy1jcM3DcN0R9b8IidYAWOsriqetUBThqb75XIZTXAaRWhHLw4ayROYiaw8dPuLRjeVKhdyznqq" + + "AKxQGyvm", + } + code200, _ := apiTest.PutConfig(*admin, cfg) + assert.Equal(200, code200, "the status code of modifying configurations with admin user should be 200") + + // length is 1059,expected code: 500 + cfg = map[string]interface{}{ + common.LDAPGroupSearchFilter: "YU2YcM13JtSx5jtBiftTjfaEM9KZFQ0XA5fKQHU02E9Xe0aLYaSy7YBokrTA8oHFjSkWFSgWZJ6FEmTS" + + "Vy5Ovsy5to2kWnFtbVNX3pzbeQpZeAqK3mEGnXdMkMSQu9WTq74s99GpwjEdA628pcZqLx6wCR0IvwryqIcNoRtqPlUcuRGODWA8ZXaC0d" + + "Qs7cRUYSe8onHsM2c9JWuUS8Jv4E7KggfytrxeKAT0WGP5DBZsB7rHZKxoAppE3C0NueEeC4yV791PUOODJt9rc0RrcD6ORUIO5RriCwym" + + "IinJZa03MtTk3vGFTmL9wM0wEYZP3fEBmoiB0iF8o4wkHGyMpNJoDyPuo7huuCbipAXClEcX1R7xD4aijTF9iOMKymvsObMZ4qqI7flco5" + + "yLFf7W8cpSisk3YJSvxDWfrl91WT4IFE5KHK976DgLQJhTZ8msGOImnFiUGtuIUNQpOgFFtlXJV41OltSsjW5jwAzxcko0MFkOIc7XuPjB" + + "XMrdjC9poYldrxNFrGOPFSyh19iS2UWKayKrtnhvDYAWrNCqOmRs01awEXBlwHp17VcLuze6XGCx7ZoPQX1Nu4uF1InAGpSm1B3pKtteeR" + + "WNNeLZjmNGNuiorHyxLTx1bQTfkG2UzZTTR0e2XatiXt5nCDxSqP2OkOxH7dew36fm9LpkFbmgtlxWxjHX8buYzSJCAjTqqwW3rHCEfQjv" + + "B4T7CTJrAgehCG9zL82P59DQbGXXWqRHbw5g9QszREQys1m56SHLosNptVPUwy7vD70rRf5s8knohW5npEZS9f3RGel64mj5g7bQBBkopx" + + "f6uac3MlJAe9d6C0B7fexZJABln2kCtXXYzITflICISwxuZ0YXHJmT2sMSIpn9VwMnMidV4JsM2BD8ykExZ5QyeVyOCXHDxvRvFwQwjQfR" + + "kkqQmtFREitKWl5njO8wLJw0XyeIVAej75NsGKKZWVjyaupaM9Bqn6NFrWjELFacLox6OCcRIDSDl3ntNN8tIzGOF7aXVCIqljJl0IL9Pz" + + "NenmmubaNm48YjfkBk8MqOUSYJYaFkO1qCKbVdMg7yTqKEHgSUqEkoFPoJMH6GAozC", + } + code500, _ := apiTest.PutConfig(*admin, cfg) + assert.Equal(500, code500, "the status code of modifying configurations with admin user should be 500") +} diff --git a/tests/docker-compose.test.yml b/tests/docker-compose.test.yml index 697150250..436a03fd1 100644 --- a/tests/docker-compose.test.yml +++ b/tests/docker-compose.test.yml @@ -22,9 +22,7 @@ services: ports: - 5432:5432 adminserver: - build: - context: ../ - dockerfile: make/dev/adminserver/Dockerfile + image: goharbor/harbor-adminserver:__version__ env_file: - ./common/config/adminserver/env restart: always diff --git a/tools/migration/db/changelog.md b/tools/migration/db/changelog.md index 378d9cfbc..2351afd08 100644 --- a/tools/migration/db/changelog.md +++ b/tools/migration/db/changelog.md @@ -78,4 +78,8 @@ Changelog for harbor database schema ## 1.6.0 - - add `deleted` column to table `harbor_label` + - add `deleted` column to table `harbor_label` + +## 1.7.0 + + - alter column `v` on table `properties`: varchar(128)->varchar(1024)