Skip to content

Commit faefe9c

Browse files
committed
fix(rocky): fix failed tests
1 parent ce1b94a commit faefe9c

File tree

8 files changed

+135
-16
lines changed

8 files changed

+135
-16
lines changed

rocky/rocky.go

+9-2
Original file line numberDiff line numberDiff line change
@@ -187,9 +187,16 @@ func (c Config) update(majorVer string, releases map[string][]string, repo, arch
187187
return xerrors.Errorf("failed to mkdir: %w", err)
188188
}
189189

190+
// ["pub", "vault"] => ["vault", "pub"]
191+
statuses := []string{}
192+
for status := range releases {
193+
statuses = append(statuses, status)
194+
}
195+
sort.Slice(statuses, func(i, j int) bool { return statuses[i] > statuses[j] })
196+
190197
advisories := map[string]Advisory{}
191-
for status, rels := range releases {
192-
for _, rel := range rels {
198+
for _, status := range statuses {
199+
for _, rel := range releases[status] {
193200
u, err := url.Parse(fmt.Sprintf(c.url, status, rel, repo, arch))
194201
if err != nil {
195202
return xerrors.Errorf("failed to parse root url: %w", err)

rocky/rocky_test.go

+16-14
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package rocky_test
22

33
import (
44
"encoding/json"
5+
"errors"
56
"fmt"
67
"net/http"
78
"net/http/httptest"
@@ -15,6 +16,7 @@ import (
1516
"github.com/kylelemons/godebug/pretty"
1617
"github.com/stretchr/testify/assert"
1718
"github.com/stretchr/testify/require"
19+
"golang.org/x/xerrors"
1820
)
1921

2022
func Test_Update(t *testing.T) {
@@ -32,20 +34,20 @@ func Test_Update(t *testing.T) {
3234
repository: []string{"BaseOS", "AppStream"},
3335
expectedError: nil,
3436
},
35-
// {
36-
// name: "not module in modules.yaml",
37-
// rootDir: "testdata/fixtures/not_module_in_yaml",
38-
// releases: map[string]map[string][]string{"8": {"pub": {"8.5"}}},
39-
// repository: []string{"AppStream"},
40-
// expectedError: nil,
41-
// },
42-
// {
43-
// name: "bad updateInfo response",
44-
// rootDir: "testdata/fixtures/updateinfo_invalid",
45-
// releases: map[string]map[string][]string{"8": {"pub": {"8.5"}}},
46-
// repository: []string{"BaseOS"},
47-
// expectedError: xerrors.Errorf("failed to update security advisories of Rocky Linux 8 BaseOS x86_64: %w", errors.New("failed to fetch updateInfo")),
48-
// },
37+
{
38+
name: "not module in modules.yaml",
39+
rootDir: "testdata/fixtures/not_module_in_yaml",
40+
releases: map[string]map[string][]string{"8": {"pub": {"8.5"}}},
41+
repository: []string{"AppStream"},
42+
expectedError: nil,
43+
},
44+
{
45+
name: "bad updateInfo response",
46+
rootDir: "testdata/fixtures/updateinfo_invalid",
47+
releases: map[string]map[string][]string{"8": {"pub": {"8.5"}}},
48+
repository: []string{"BaseOS"},
49+
expectedError: xerrors.Errorf("failed to update security advisories of Rocky Linux 8 BaseOS x86_64: %w", errors.New("failed to fetch updateInfo")),
50+
},
4951
}
5052
for _, tt := range tests {
5153
t.Run(tt.name, func(t *testing.T) {
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<html>
2+
<head><title>Index of /pub/rocky/8.5/AppStream/x86_64/os/repodata/</title></head>
3+
<body bgcolor="white">
4+
<h1>Index of /pub/rocky/8.5/AppStream/x86_64/os/repodata/</h1><hr><pre><a href="../">../</a>
5+
<a href="1-updateinfo.xml.gz">0c11bf32680996cf227bba2496573626142ab58de0bdacd..&gt;</a> 27-Jan-2022 21:37 26010
6+
<a href="1-modules.yaml.xz">67f7e4dea4a7468c1017a362af42bdd7254a92bf6dcb3b5..&gt;</a> 27-Jan-2022 19:50 63260
7+
<a href="repomd.xml">repomd.xml</a> 27-Jan-2022 23:09 4876
8+
<a href="repomd.xml.asc">repomd.xml.asc</a> 27-Jan-2022 23:09 833
9+
</pre><hr></body>
10+
</html>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
<updates
2+
<update from="[email protected]" status="final" type="security" version="2">
3+
<id>RLSA-2021:4511</id>
4+
<title>Moderate: curl security and bug fix update</title>
5+
<issued date="2021-11-15 07:26:41"></issued>
6+
<updated date="2021-11-09 00:00:00"></updated>
7+
<rights>Copyright (C) 2021 Rocky Enterprise Software Foundation</rights>
8+
<release>Rocky Linux 8</release>
9+
<pushcount>1</pushcount>
10+
<severity>Moderate</severity>
11+
<summary>An update for curl is now available for Rocky Linux 8.&#xA;Rocky Linux Product Security has rated this update as having a security impact of Moderate. A Common Vulnerability Scoring System (CVSS) base score, which gives a detailed severity rating, is available for each vulnerability from the CVE link(s) in the References section.</summary>
12+
<description>For more information visit https://errata.rockylinux.org/RLSA-2021:4511</description>
13+
<references>
14+
<reference href="https://access.redhat.com/hydra/rest/securitydata/cve/CVE-2021-22925.json" id="CVE-2021-22925" type="cve" title="Update information for CVE-2021-22925 is retrieved from Red Hat"></reference>
15+
</references>
16+
<pkglist>
17+
<collection short="RL8">
18+
<name>Rocky Linux 8</name>
19+
<package name="libcurl-minimal" version="7.61.1" release="22.el8" epoch="0" arch="i686" src="curl-7.61.1-22.el8.src.rpm">
20+
<filename>libcurl-minimal-7.61.1-22.el8.i686.rpm</filename>
21+
<sum type="sha256">b2ec1f86fd58731f4fe6bb19540b8cca8d61418a47760babef44fe37eb6d1707</sum>
22+
</package>
23+
<package name="libcurl-devel" version="7.61.1" release="22.el8" epoch="0" arch="i686" src="curl-7.61.1-22.el8.src.rpm">
24+
<filename>libcurl-devel-7.61.1-22.el8.i686.rpm</filename>
25+
<sum type="sha256">4c278eb72cbb6d9cbc0ac4677cc25ef11302ce2b149e19e9e9789ea3fbcb2fb1</sum>
26+
</package>
27+
<package name="curl" version="7.61.1" release="22.el8" epoch="0" arch="x86_64" src="curl-7.61.1-22.el8.src.rpm">
28+
<filename>curl-7.61.1-22.el8.x86_64.rpm</filename>
29+
<sum type="sha256">e372199f281feaad685fa855a3c585c381ca5abcbe2d7e5a6dde103f337cb7e2</sum>
30+
</package>
31+
<package name="libcurl" version="7.61.1" release="22.el8" epoch="0" arch="i686" src="curl-7.61.1-22.el8.src.rpm">
32+
<filename>libcurl-7.61.1-22.el8.i686.rpm</filename>
33+
<sum type="sha256">7508b40b10f354ae27647efa810be3d53c7255fc39494d6addd5df536c5a9295</sum>
34+
</package>
35+
<package name="libcurl-devel" version="7.61.1" release="22.el8" epoch="0" arch="x86_64" src="curl-7.61.1-22.el8.src.rpm">
36+
<filename>libcurl-devel-7.61.1-22.el8.x86_64.rpm</filename>
37+
<sum type="sha256">b97faa42eb51fb20ceb8a70d9fb7e5647de92775d52292ace032108f3d3fab30</sum>
38+
</package>
39+
<package name="libcurl" version="7.61.1" release="22.el8" epoch="0" arch="x86_64" src="curl-7.61.1-22.el8.src.rpm">
40+
<filename>libcurl-7.61.1-22.el8.x86_64.rpm</filename>
41+
<sum type="sha256">7cc35e59072c0f21b2f8f7c4d8769b8b143299bab5438619d0a895ee9be62b8b</sum>
42+
</package>
43+
<package name="libcurl-minimal" version="7.61.1" release="22.el8" epoch="0" arch="x86_64" src="curl-7.61.1-22.el8.src.rpm">
44+
<filename>libcurl-minimal-7.61.1-22.el8.x86_64.rpm</filename>
45+
<sum type="sha256">a01088cec7aaabebb5389eb6181dc11e1fe240319e6ce18f7f625434386591f0</sum>
46+
</package>
47+
</collection>
48+
</pkglist>
49+
</update>
50+
</updates>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<html>
2+
<head><title>Index of /pub/rocky/8.5/BaseOS/x86_64/os/repodata/</title></head>
3+
<body bgcolor="white">
4+
<h1>Index of /pub/rocky/8.5/BaseOS/x86_64/os/repodata/</h1><hr><pre><a href="../">../</a>
5+
<a href="1-updateinfo.xml.gz">b729c78fe0fa3b5ec30761bcc900b249b9669db8f5f23fd..&gt;</a> 27-Jan-2022 21:37 18554
6+
<a href="repomd.xml">repomd.xml</a> 27-Jan-2022 23:09 4396
7+
<a href="repomd.xml.asc">repomd.xml.asc</a> 27-Jan-2022 23:09 833
8+
</pre><hr></body>
9+
</html>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
{
2+
"id": "RLSA-2021:1979(invalid)",
3+
"title": "Important: squid:4 security update",
4+
"issued": {
5+
"date": "2021-07-22 03:16:49"
6+
},
7+
"updated": {
8+
"date": "2021-05-18 00:00:00"
9+
},
10+
"severity": "Important",
11+
"description": "For more information visit https://errata.rockylinux.org/RLSA-2021:1979",
12+
"packages": [
13+
{
14+
"name": "libecap",
15+
"epoch": "0",
16+
"version": "1.0.1",
17+
"release": "2.module+el8.4.0+404+316a0dc5",
18+
"arch": "x86_64",
19+
"src": "libecap-1.0.1-2.module+el8.4.0+404+316a0dc5.src.rpm",
20+
"filename": "libecap-1.0.1-2.module+el8.4.0+404+316a0dc5.x86_64.rpm"
21+
},
22+
{
23+
"name": "libecap-devel",
24+
"epoch": "0",
25+
"version": "1.0.1",
26+
"release": "2.module+el8.4.0+404+316a0dc5",
27+
"arch": "x86_64",
28+
"src": "libecap-1.0.1-2.module+el8.4.0+404+316a0dc5.src.rpm",
29+
"filename": "libecap-devel-1.0.1-2.module+el8.4.0+404+316a0dc5.x86_64.rpm"
30+
}
31+
],
32+
"references": [
33+
{
34+
"href": "https://access.redhat.com/hydra/rest/securitydata/cve/CVE-2020-25097.json",
35+
"id": "CVE-2020-25097",
36+
"title": "Update information for CVE-2020-25097 is retrieved from Red Hat",
37+
"type": "cve"
38+
}
39+
],
40+
"cveids": ["CVE-2020-25097"]
41+
}

0 commit comments

Comments
 (0)