You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

migrate_test.go 924B

12345678910111213141516171819202122232425262728293031323334
  1. // Copyright 2019 The Gitea Authors. All rights reserved.
  2. // Use of this source code is governed by a MIT-style
  3. // license that can be found in the LICENSE file.
  4. package migrations
  5. import (
  6. "testing"
  7. "code.gitea.io/gitea/modules/setting"
  8. "github.com/stretchr/testify/assert"
  9. )
  10. func TestMigrateWhiteBlocklist(t *testing.T) {
  11. setting.Migrations.AllowedDomains = []string{"github.com"}
  12. assert.NoError(t, Init())
  13. err := isMigrateURLAllowed("https://gitlab.com/gitlab/gitlab.git")
  14. assert.Error(t, err)
  15. err = isMigrateURLAllowed("https://github.com/go-gitea/gitea.git")
  16. assert.NoError(t, err)
  17. setting.Migrations.AllowedDomains = []string{}
  18. setting.Migrations.BlockedDomains = []string{"github.com"}
  19. assert.NoError(t, Init())
  20. err = isMigrateURLAllowed("https://gitlab.com/gitlab/gitlab.git")
  21. assert.NoError(t, err)
  22. err = isMigrateURLAllowed("https://github.com/go-gitea/gitea.git")
  23. assert.Error(t, err)
  24. }