Updated fetcher and tests to close the file handles and HTTP response.
Signed-off-by: Avi Miller <avi.miller@oracle.com>
This commit is contained in:
parent
a3c2dae790
commit
2643d22aaa
@ -105,6 +105,7 @@ func (f *OracleFetcher) FetchUpdate(datastore database.Datastore) (resp updater.
|
|||||||
log.Errorf("could not download Oracle's update list: %s", err)
|
log.Errorf("could not download Oracle's update list: %s", err)
|
||||||
return resp, cerrors.ErrCouldNotDownload
|
return resp, cerrors.ErrCouldNotDownload
|
||||||
}
|
}
|
||||||
|
defer r.Body.Close()
|
||||||
|
|
||||||
// Get the list of ELSAs that we have to process.
|
// Get the list of ELSAs that we have to process.
|
||||||
var elsaList []int
|
var elsaList []int
|
||||||
|
@ -31,6 +31,8 @@ func TestOracleParser(t *testing.T) {
|
|||||||
|
|
||||||
// Test parsing testdata/fetcher_oracle_test.1.xml
|
// Test parsing testdata/fetcher_oracle_test.1.xml
|
||||||
testFile, _ := os.Open(path + "/testdata/fetcher_oracle_test.1.xml")
|
testFile, _ := os.Open(path + "/testdata/fetcher_oracle_test.1.xml")
|
||||||
|
defer testFile.Close()
|
||||||
|
|
||||||
vulnerabilities, err := parseELSA(testFile)
|
vulnerabilities, err := parseELSA(testFile)
|
||||||
if assert.Nil(t, err) && assert.Len(t, vulnerabilities, 1) {
|
if assert.Nil(t, err) && assert.Len(t, vulnerabilities, 1) {
|
||||||
assert.Equal(t, "ELSA-2015-1193", vulnerabilities[0].Name)
|
assert.Equal(t, "ELSA-2015-1193", vulnerabilities[0].Name)
|
||||||
@ -67,8 +69,10 @@ func TestOracleParser(t *testing.T) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
testFile, _ = os.Open(path + "/testdata/fetcher_oracle_test.2.xml")
|
testFile2, _ := os.Open(path + "/testdata/fetcher_oracle_test.2.xml")
|
||||||
vulnerabilities, err = parseELSA(testFile)
|
defer testFile2.Close()
|
||||||
|
|
||||||
|
vulnerabilities, err = parseELSA(testFile2)
|
||||||
if assert.Nil(t, err) && assert.Len(t, vulnerabilities, 1) {
|
if assert.Nil(t, err) && assert.Len(t, vulnerabilities, 1) {
|
||||||
assert.Equal(t, "ELSA-2015-1207", vulnerabilities[0].Name)
|
assert.Equal(t, "ELSA-2015-1207", vulnerabilities[0].Name)
|
||||||
assert.Equal(t, "http://linux.oracle.com/errata/ELSA-2015-1207.html", vulnerabilities[0].Link)
|
assert.Equal(t, "http://linux.oracle.com/errata/ELSA-2015-1207.html", vulnerabilities[0].Link)
|
||||||
|
Loading…
Reference in New Issue
Block a user