tests: Add tests for new repo gpg support
Add testing for gpgkeys and check_repogpg.
This commit is contained in:
parent
c2577eaea8
commit
d5e666cc9c
2 changed files with 63 additions and 1 deletions
|
|
@ -450,6 +450,18 @@ func (suite *storeTest) TestNewSourceConfigWithMirrorList() {
|
|||
suite.Equal(expectedSource, actualSource)
|
||||
}
|
||||
|
||||
// Test converting a SourceConfig with GPGkeys to a RepoConfig
|
||||
func (suite *storeTest) TestRepoConfigGPGKeys() {
|
||||
expectedRepo := rpmmd.RepoConfig{Name: "testSourceConfig", BaseURL: "testURL", Metalink: "", MirrorList: "", IgnoreSSL: true, MetadataExpire: "", CheckRepoGPG: true, GPGKeys: []string{"http://path.to.gpgkeys/key.pub", "-----BEGIN PGP PUBLIC KEY BLOCK-----\nFULL GPG KEY HERE\n-----END PGP PUBLIC KEY BLOCK-----"}}
|
||||
mySourceConfig := suite.mySourceConfig
|
||||
mySourceConfig.Type = "yum-baseurl"
|
||||
mySourceConfig.URL = "testURL"
|
||||
mySourceConfig.CheckRepoGPG = true
|
||||
mySourceConfig.GPGKeys = []string{"http://path.to.gpgkeys/key.pub", "-----BEGIN PGP PUBLIC KEY BLOCK-----\nFULL GPG KEY HERE\n-----END PGP PUBLIC KEY BLOCK-----"}
|
||||
actualRepo := mySourceConfig.RepoConfig("testSourceConfig")
|
||||
suite.Equal(expectedRepo, actualRepo)
|
||||
}
|
||||
|
||||
func (suite *storeTest) TestRepoConfigBaseURL() {
|
||||
expectedRepo := rpmmd.RepoConfig{Name: "testSourceConfig", BaseURL: "testURL", Metalink: "", MirrorList: "", IgnoreSSL: true, MetadataExpire: ""}
|
||||
suite.mySourceConfig.Type = "yum-baseurl"
|
||||
|
|
@ -473,6 +485,7 @@ func (suite *storeTest) TestRepoConfigMirrorlist() {
|
|||
actualRepo := suite.mySourceConfig.RepoConfig("testSourceConfig")
|
||||
suite.Equal(expectedRepo, actualRepo)
|
||||
}
|
||||
|
||||
func TestStore(t *testing.T) {
|
||||
suite.Run(t, new(storeTest))
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1549,6 +1549,7 @@ func TestSourcesNew(t *testing.T) {
|
|||
{"POST", "/api/v1/projects/source/new", `{"id": "test-id", "name": "test system repo", "url": "https://download.opensuse.org/repositories/shells:/fish:/release:/3/Fedora_29/","type": "yum-baseurl","check_ssl": false,"check_gpg": false}`, http.StatusBadRequest, `{"errors": [{"id": "SystemSource","msg": "test-id is a system source, it cannot be changed."}],"status":false}`},
|
||||
{"POST", "/api/v1/projects/source/new", `{"id": "fish","name":"fish repo","url": "https://download.opensuse.org/repositories/shells:/fish:/release:/3/Fedora_29/","type": "yum-baseurl","check_ssl": false,"check_gpg": false,"distros":["test-distro", "test-distro-2"]}`, http.StatusOK, `{"status":true}`},
|
||||
{"POST", "/api/v1/projects/source/new", `{"id": "fish","name":"fish repo","url": "https://download.opensuse.org/repositories/shells:/fish:/release:/3/Fedora_29/","type": "yum-baseurl","check_ssl": false,"check_gpg": false,"distros":["fedora-1"]}`, http.StatusBadRequest, `{"status":false, "errors":[{"id":"ProjectsError", "msg":"Invalid distributions: fedora-1"}]}`},
|
||||
{"POST", "/api/v1/projects/source/new", `{"id": "fish","name":"fish repo","url": "https://download.opensuse.org/repositories/shells:/fish:/release:/3/Fedora_29/","type": "yum-baseurl","check_ssl": false,"check_gpg": true,"check_repogpg":true,"gpgkeys": ["https://repourl/path/to/key.pub"]}`, http.StatusOK, `{"status":true}`},
|
||||
}
|
||||
|
||||
tempdir := t.TempDir()
|
||||
|
|
@ -1638,6 +1639,45 @@ url = "https://download.opensuse.org/repositories/shells:/fish:/release:/3/Fedor
|
|||
type = "yum-baseurl"
|
||||
check_ssl = false
|
||||
check_gpg = false
|
||||
`, `id = "fish"
|
||||
name = "fish or cut bait"
|
||||
url = "https://download.opensuse.org/repositories/shells:/fish:/release:/3/Fedora_29/"
|
||||
type = "yum-baseurl"
|
||||
check_ssl = false
|
||||
check_gpg = true
|
||||
check_repogpg = true
|
||||
gpgkeys = ['''-----BEGIN PGP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QbX5/7kBDQRLfsVzAQgAvN5jr95pJthv2w9co9/7omhM
|
||||
5rAnr9WJfbMLLiUfPPUvpL24RGO6SKy03aiVTUjlaHc+cGqOciwnNKMCSt+noyG2
|
||||
kNnAESTDtCivpsjonaFP8jA3TqL0QK+yzBRKJnMnLEY1nWE1FtkMRccXvzi0Z/XQ
|
||||
VhiWQyTvDFoKtepBFrH9UqWbNHyki22aighumUsW01pcPH2ogSj+HR01r7SfI/y2
|
||||
EkE6loHQfCDycHmlqYV+X6GZEvf1qu2+EHEQChsHIAxWyshsxM/ZPmx/8e5S3Xmj
|
||||
l7h/6E9wcsIpvnf504sLX5j4Km9I5HgJSRxHxgRPpqJ2/XiClAJanO5gCw0RdQAR
|
||||
AQABiQEfBBgBAgAJBQJLfsVzAhsMAAoJEBF+jBaO/jp/SqEH/iArzrfVOhZQGuy1
|
||||
KmG0+/FdJGqAEHP5HWpsaeYJok1VmhTPZd4IVFBz/bGJYyvsrPU0pJ6QLkdGxNnb
|
||||
KulJocgkW5MKEL/CRc54ESKwYngigmbY4qLwhS+gB3BJg1TvoHD810MSj4wdxNNo
|
||||
6JQmFmuoDsLRwaRYbKQDz95XXoGQtmV1o57T05WkLuC5OmHqnWv3rggVC8madpUJ
|
||||
moUUvUWgU1qyXe3PrgMGFOibWIl7lPZ08nzKXBRvSK/xoTGxl+570AevfVHMu5Uk
|
||||
Yu2U6D6/DYohtTYp0s1ekS5KQkCJM7lfqecDsQhfVfOfR0w4aF8k8u3HmWdOfUz+
|
||||
9+2ZsBo=
|
||||
=myjM
|
||||
-----END PGP PUBLIC KEY BLOCK-----''']
|
||||
`}
|
||||
for _, source := range sources {
|
||||
req := httptest.NewRequest("POST", "/api/v1/projects/source/new", bytes.NewReader([]byte(source)))
|
||||
|
|
@ -1663,7 +1703,7 @@ type = "yum-baseurl"
|
|||
rhsm = true
|
||||
`
|
||||
|
||||
sourceStr := `{"check_gpg":false,"check_ssl":false,"id":"fish","name":"fish","rhsm":true,"system":false,"type":"yum-baseurl","url":"https://download.opensuse.org/repositories/shells:/fish:/release:/3/Fedora_29/"}`
|
||||
sourceStr := `{"check_gpg":false,"check_repogpg":false,"check_ssl":false,"id":"fish","name":"fish","rhsm":true,"system":false,"type":"yum-baseurl","url":"https://download.opensuse.org/repositories/shells:/fish:/release:/3/Fedora_29/"}`
|
||||
|
||||
req := httptest.NewRequest("POST", "/api/v1/projects/source/new", bytes.NewReader([]byte(source)))
|
||||
req.Header.Set("Content-Type", "text/x-toml")
|
||||
|
|
@ -1678,6 +1718,15 @@ rhsm = true
|
|||
test.TestRoute(t, api, true, "GET", "/api/v1/projects/source/info/fish?format=json", ``, 200, `{"sources":{"fish":`+sourceStr+`},"errors":[]}`)
|
||||
}
|
||||
|
||||
func TestSourcesInfoGPGKeysV1(t *testing.T) {
|
||||
sourceStr := `{"id":"fish","name":"fish repo","type":"yum-baseurl","url":"https://download.opensuse.org/repositories/shells:/fish:/release:/3/Fedora_29/","check_gpg":true,"check_repogpg":true,"check_ssl":false,"gpgkeys":["https://repourl/path/to/key.pub"],"rhsm":false,"system":false}`
|
||||
|
||||
api, _ := createWeldrAPI(t.TempDir(), rpmmd_mock.BaseFixture)
|
||||
test.SendHTTP(api, true, "POST", "/api/v1/projects/source/new", sourceStr)
|
||||
test.TestRoute(t, api, true, "GET", "/api/v1/projects/source/info/fish", ``, 200, `{"sources":{"fish":`+sourceStr+`},"errors":[]}`)
|
||||
test.TestRoute(t, api, true, "GET", "/api/v1/projects/source/info/fish?format=json", ``, 200, `{"sources":{"fish":`+sourceStr+`},"errors":[]}`)
|
||||
}
|
||||
|
||||
// TestSourcesNewWrongTomlV1 Tests that Empty TOML, and invalid TOML should return an error
|
||||
func TestSourcesNewWrongTomlV1(t *testing.T) {
|
||||
tempdir := t.TempDir()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue