summaryrefslogtreecommitdiffhomepage
path: root/posture/serialnumber_macos_test.go
blob: 5f1aec5cd790b94f7ccc941f255d339dee643e76 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
// Copyright (c) Tailscale Inc & contributors
// SPDX-License-Identifier: BSD-3-Clause

//go:build cgo && darwin && !ios

package posture

import (
	"fmt"
	"testing"

	"tailscale.com/types/logger"
	"tailscale.com/util/cibuild"
	"tailscale.com/util/syspolicy/policyclient"
)

func TestGetSerialNumberMac(t *testing.T) {
	// Do not run this test on CI, it can only be ran on macOS
	// and we currently only use Linux runners.
	if cibuild.On() {
		t.Skip()
	}

	sns, err := GetSerialNumbers(policyclient.NoPolicyClient{}, logger.Discard)
	if err != nil {
		t.Fatalf("failed to get serial number: %s", err)
	}

	if len(sns) != 1 {
		t.Errorf("expected list of one serial number, got %v", sns)
	}

	if len(sns[0]) <= 0 {
		t.Errorf("expected a serial number with more than zero characters, got %s", sns[0])
	}

	fmt.Printf("serials: %v\n", sns)
}