|
|
|
@ -1,4 +1,4 @@
|
|
|
|
|
// Copyright 2015 clair authors
|
|
|
|
|
// Copyright 2016 clair authors
|
|
|
|
|
//
|
|
|
|
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
|
// you may not use this file except in compliance with the License.
|
|
|
|
@ -21,12 +21,13 @@ import (
|
|
|
|
|
"github.com/coreos/clair/worker/detectors/namespace"
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
var osReleaseOSTests = []namespace.NamespaceTest{
|
|
|
|
|
{
|
|
|
|
|
ExpectedNamespace: database.Namespace{Name: "debian:8"},
|
|
|
|
|
Data: map[string][]byte{
|
|
|
|
|
"etc/os-release": []byte(
|
|
|
|
|
`PRETTY_NAME="Debian GNU/Linux 8 (jessie)"
|
|
|
|
|
func TestOsReleaseNamespaceDetector(t *testing.T) {
|
|
|
|
|
testData := []namespace.TestData{
|
|
|
|
|
{
|
|
|
|
|
ExpectedNamespace: &database.Namespace{Name: "debian:8"},
|
|
|
|
|
Data: map[string][]byte{
|
|
|
|
|
"etc/os-release": []byte(
|
|
|
|
|
`PRETTY_NAME="Debian GNU/Linux 8 (jessie)"
|
|
|
|
|
NAME="Debian GNU/Linux"
|
|
|
|
|
VERSION_ID="8"
|
|
|
|
|
VERSION="8 (jessie)"
|
|
|
|
@ -34,13 +35,13 @@ ID=debian
|
|
|
|
|
HOME_URL="http://www.debian.org/"
|
|
|
|
|
SUPPORT_URL="http://www.debian.org/support/"
|
|
|
|
|
BUG_REPORT_URL="https://bugs.debian.org/"`),
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
ExpectedNamespace: database.Namespace{Name: "ubuntu:15.10"},
|
|
|
|
|
Data: map[string][]byte{
|
|
|
|
|
"etc/os-release": []byte(
|
|
|
|
|
`NAME="Ubuntu"
|
|
|
|
|
{
|
|
|
|
|
ExpectedNamespace: &database.Namespace{Name: "ubuntu:15.10"},
|
|
|
|
|
Data: map[string][]byte{
|
|
|
|
|
"etc/os-release": []byte(
|
|
|
|
|
`NAME="Ubuntu"
|
|
|
|
|
VERSION="15.10 (Wily Werewolf)"
|
|
|
|
|
ID=ubuntu
|
|
|
|
|
ID_LIKE=debian
|
|
|
|
@ -49,13 +50,13 @@ VERSION_ID="15.10"
|
|
|
|
|
HOME_URL="http://www.ubuntu.com/"
|
|
|
|
|
SUPPORT_URL="http://help.ubuntu.com/"
|
|
|
|
|
BUG_REPORT_URL="http://bugs.launchpad.net/ubuntu/"`),
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
{ // Doesn't have quotes around VERSION_ID
|
|
|
|
|
ExpectedNamespace: database.Namespace{Name: "fedora:20"},
|
|
|
|
|
Data: map[string][]byte{
|
|
|
|
|
"etc/os-release": []byte(
|
|
|
|
|
`NAME=Fedora
|
|
|
|
|
{ // Doesn't have quotes around VERSION_ID
|
|
|
|
|
ExpectedNamespace: &database.Namespace{Name: "fedora:20"},
|
|
|
|
|
Data: map[string][]byte{
|
|
|
|
|
"etc/os-release": []byte(
|
|
|
|
|
`NAME=Fedora
|
|
|
|
|
VERSION="20 (Heisenbug)"
|
|
|
|
|
ID=fedora
|
|
|
|
|
VERSION_ID=20
|
|
|
|
@ -68,10 +69,9 @@ REDHAT_BUGZILLA_PRODUCT="Fedora"
|
|
|
|
|
REDHAT_BUGZILLA_PRODUCT_VERSION=20
|
|
|
|
|
REDHAT_SUPPORT_PRODUCT="Fedora"
|
|
|
|
|
REDHAT_SUPPORT_PRODUCT_VERSION=20`),
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func TestOsReleaseNamespaceDetector(t *testing.T) {
|
|
|
|
|
namespace.TestNamespaceDetector(t, &OsReleaseNamespaceDetector{}, osReleaseOSTests)
|
|
|
|
|
namespace.TestDetector(t, &OsReleaseNamespaceDetector{}, testData)
|
|
|
|
|
}
|
|
|
|
|