func TestAlpineReleaseNamespaceDetection(t *testing.T) { testData := []namespace.TestData{ { ExpectedNamespace: &database.Namespace{Name: "alpine:v3.3"}, Data: map[string][]byte{"etc/alpine-release": []byte(`3.3.4`)}, }, { ExpectedNamespace: &database.Namespace{Name: "alpine:v3.4"}, Data: map[string][]byte{"etc/alpine-release": []byte(`3.4.0`)}, }, { ExpectedNamespace: &database.Namespace{Name: "alpine:v0.3"}, Data: map[string][]byte{"etc/alpine-release": []byte(`0.3.4`)}, }, { ExpectedNamespace: &database.Namespace{Name: "alpine:v0.3"}, Data: map[string][]byte{"etc/alpine-release": []byte(` 0.3.4 `)}, }, { ExpectedNamespace: nil, Data: map[string][]byte{}, }, } namespace.TestDetector(t, &detector{}, testData) }
func TestRedhatReleaseNamespaceDetector(t *testing.T) { testData := []namespace.TestData{ { ExpectedNamespace: &database.Namespace{Name: "oracle:6"}, Data: map[string][]byte{ "etc/oracle-release": []byte(`Oracle Linux Server release 6.8`), }, }, { ExpectedNamespace: &database.Namespace{Name: "oracle:7"}, Data: map[string][]byte{ "etc/oracle-release": []byte(`Oracle Linux Server release 7.2`), }, }, { ExpectedNamespace: &database.Namespace{Name: "centos:6"}, Data: map[string][]byte{ "etc/centos-release": []byte(`CentOS release 6.6 (Final)`), }, }, { ExpectedNamespace: &database.Namespace{Name: "centos:7"}, Data: map[string][]byte{ "etc/system-release": []byte(`CentOS Linux release 7.1.1503 (Core)`), }, }, } namespace.TestDetector(t, &RedhatReleaseNamespaceDetector{}, testData) }
func TestLsbReleaseNamespaceDetector(t *testing.T) { testData := []namespace.TestData{ { ExpectedNamespace: &database.Namespace{Name: "ubuntu:12.04"}, Data: map[string][]byte{ "etc/lsb-release": []byte( `DISTRIB_ID=Ubuntu DISTRIB_RELEASE=12.04 DISTRIB_CODENAME=precise DISTRIB_DESCRIPTION="Ubuntu 12.04 LTS"`), }, }, { // We don't care about the minor version of Debian ExpectedNamespace: &database.Namespace{Name: "debian:7"}, Data: map[string][]byte{ "etc/lsb-release": []byte( `DISTRIB_ID=Debian DISTRIB_RELEASE=7.1 DISTRIB_CODENAME=wheezy DISTRIB_DESCRIPTION="Debian 7.1"`), }, }, } namespace.TestDetector(t, &LsbReleaseNamespaceDetector{}, testData) }
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)" 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" VERSION="15.10 (Wily Werewolf)" ID=ubuntu ID_LIKE=debian PRETTY_NAME="Ubuntu Wily Werewolf (development branch)" 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 VERSION="20 (Heisenbug)" ID=fedora VERSION_ID=20 PRETTY_NAME="Fedora 20 (Heisenbug)" ANSI_COLOR="0;34" CPE_NAME="cpe:/o:fedoraproject:fedora:20" HOME_URL="https://fedoraproject.org/" BUG_REPORT_URL="https://bugzilla.redhat.com/" REDHAT_BUGZILLA_PRODUCT="Fedora" REDHAT_BUGZILLA_PRODUCT_VERSION=20 REDHAT_SUPPORT_PRODUCT="Fedora" REDHAT_SUPPORT_PRODUCT_VERSION=20`), }, }, } namespace.TestDetector(t, &OsReleaseNamespaceDetector{}, testData) }
func TestAptSourcesNamespaceDetector(t *testing.T) { testData := []namespace.TestData{ { ExpectedNamespace: &database.Namespace{Name: "debian:unstable"}, Data: map[string][]byte{ "etc/os-release": []byte( `PRETTY_NAME="Debian GNU/Linux stretch/sid" NAME="Debian GNU/Linux" ID=debian HOME_URL="https://www.debian.org/" SUPPORT_URL="https://www.debian.org/support/" BUG_REPORT_URL="https://bugs.debian.org/"`), "etc/apt/sources.list": []byte(`deb http://httpredir.debian.org/debian unstable main`), }, }, } namespace.TestDetector(t, &AptSourcesNamespaceDetector{}, testData) }