2023-04-19 18:40:40 +02:00
|
|
|
// apparmor.d - Full set of apparmor profiles
|
2024-02-07 00:16:21 +01:00
|
|
|
// Copyright (C) 2023-2024 Alexandre Pujol <alexandre@pujol.io>
|
2023-04-19 18:40:40 +02:00
|
|
|
// SPDX-License-Identifier: GPL-2.0-only
|
|
|
|
|
2023-05-06 14:01:07 +02:00
|
|
|
package prebuild
|
2023-04-19 18:40:40 +02:00
|
|
|
|
|
|
|
import (
|
|
|
|
"testing"
|
|
|
|
|
|
|
|
"github.com/arduino/go-paths-helper"
|
|
|
|
)
|
|
|
|
|
|
|
|
const (
|
|
|
|
Archlinux = `NAME="Arch Linux"
|
|
|
|
PRETTY_NAME="Arch Linux"
|
|
|
|
ID=arch
|
|
|
|
BUILD_ID=rolling
|
|
|
|
ANSI_COLOR="38;2;23;147;209"
|
|
|
|
HOME_URL="https://archlinux.org/"
|
|
|
|
DOCUMENTATION_URL="https://wiki.archlinux.org/"
|
|
|
|
SUPPORT_URL="https://bbs.archlinux.org/"
|
|
|
|
BUG_REPORT_URL="https://bugs.archlinux.org/"
|
|
|
|
PRIVACY_POLICY_URL="https://terms.archlinux.org/docs/privacy-policy/"
|
|
|
|
LOGO=archlinux-logo`
|
|
|
|
|
|
|
|
Ubuntu = `PRETTY_NAME="Ubuntu 22.04.2 LTS"
|
|
|
|
NAME="Ubuntu"
|
|
|
|
VERSION_ID="22.04"
|
|
|
|
VERSION="22.04.2 LTS (Jammy Jellyfish)"
|
|
|
|
VERSION_CODENAME=jammy
|
|
|
|
ID=ubuntu
|
|
|
|
ID_LIKE=debian
|
|
|
|
HOME_URL="https://www.ubuntu.com/"
|
|
|
|
SUPPORT_URL="https://help.ubuntu.com/"
|
|
|
|
BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/"
|
|
|
|
PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy"
|
|
|
|
UBUNTU_CODENAME=jammy`
|
|
|
|
|
|
|
|
Debian = `PRETTY_NAME="Debian GNU/Linux 11 (bullseye)"
|
|
|
|
NAME="Debian GNU/Linux"
|
|
|
|
VERSION_ID="11"
|
|
|
|
VERSION="11 (bullseye)"
|
|
|
|
VERSION_CODENAME=bullseye
|
|
|
|
ID=debian
|
|
|
|
HOME_URL="https://www.debian.org/"
|
|
|
|
SUPPORT_URL="https://www.debian.org/support"
|
|
|
|
BUG_REPORT_URL="https://bugs.debian.org/"`
|
|
|
|
|
|
|
|
OpenSUSETumbleweed = `ID="opensuse-tumbleweed"
|
|
|
|
ID_LIKE="opensuse suse"
|
|
|
|
VERSION_ID="20230404"
|
|
|
|
PRETTY_NAME="openSUSE Tumbleweed"
|
|
|
|
ANSI_COLOR="0;32"
|
|
|
|
CPE_NAME="cpe:/o:opensuse:tumbleweed:20230404"
|
|
|
|
BUG_REPORT_URL="https://bugs.opensuse.org"
|
|
|
|
HOME_URL="https://www.opensuse.org/"
|
|
|
|
DOCUMENTATION_URL="https://en.opensuse.org/Portal:Tumbleweed"
|
|
|
|
LOGO="distributor-logo-Tumbleweed"`
|
|
|
|
|
|
|
|
ArcoLinux = `NAME=ArcoLinux
|
|
|
|
ID=arcolinux
|
|
|
|
ID_LIKE=arch
|
|
|
|
BUILD_ID=rolling
|
|
|
|
ANSI_COLOR="0;36"
|
|
|
|
HOME_URL="https://arcolinux.info/"
|
|
|
|
SUPPORT_URL="https://arcolinuxforum.com/"
|
|
|
|
BUG_REPORT_URL="https://github.com/arcolinux"
|
|
|
|
LOGO=arcolinux-hello`
|
|
|
|
|
|
|
|
Fedora = `NAME="Fedora Linux"
|
|
|
|
VERSION="37 (Workstation Edition)"
|
|
|
|
ID=fedora
|
|
|
|
VERSION_ID=37
|
|
|
|
VERSION_CODENAME=""
|
|
|
|
PLATFORM_ID="platform:f37"
|
|
|
|
PRETTY_NAME="Fedora Linux 37 (Workstation Edition)"
|
|
|
|
ANSI_COLOR="0;38;2;60;110;180"
|
|
|
|
LOGO=fedora-logo-icon`
|
|
|
|
)
|
|
|
|
|
2023-05-06 14:01:07 +02:00
|
|
|
func Test_getSupportedDistribution(t *testing.T) {
|
2023-04-19 18:40:40 +02:00
|
|
|
tests := []struct {
|
|
|
|
name string
|
|
|
|
osRelease string
|
|
|
|
want string
|
|
|
|
}{
|
|
|
|
{
|
|
|
|
name: "Archlinux",
|
|
|
|
osRelease: Archlinux,
|
|
|
|
want: "arch",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "Ubuntu",
|
|
|
|
osRelease: Ubuntu,
|
|
|
|
want: "ubuntu",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "Debian",
|
|
|
|
osRelease: Debian,
|
|
|
|
want: "debian",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "OpenSUSE Tumbleweed",
|
|
|
|
osRelease: OpenSUSETumbleweed,
|
|
|
|
want: "opensuse",
|
|
|
|
},
|
2023-05-06 14:01:07 +02:00
|
|
|
// {
|
|
|
|
// name: "Fedora",
|
|
|
|
// osRelease: Fedora,
|
|
|
|
// want: "fedora",
|
|
|
|
// },
|
2023-04-19 18:40:40 +02:00
|
|
|
}
|
|
|
|
|
2023-05-06 14:01:07 +02:00
|
|
|
osReleaseFile = "/tmp/os-release"
|
2023-04-19 18:40:40 +02:00
|
|
|
for _, tt := range tests {
|
|
|
|
t.Run(tt.name, func(t *testing.T) {
|
|
|
|
err := paths.New(osReleaseFile).WriteFile([]byte(tt.osRelease))
|
|
|
|
if err != nil {
|
|
|
|
return
|
|
|
|
}
|
2023-05-06 14:01:07 +02:00
|
|
|
got := getSupportedDistribution()
|
2023-04-19 18:40:40 +02:00
|
|
|
if got != tt.want {
|
2023-05-06 14:01:07 +02:00
|
|
|
t.Errorf("getSupportedDistribution() = %v, want %v", got, tt.want)
|
2023-04-19 18:40:40 +02:00
|
|
|
}
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|