File: id_test.go

package info (click to toggle)
golang-github-crowdsecurity-machineid 1.0.3-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 140 kB
  • sloc: makefile: 2
file content (30 lines) | stat: -rw-r--r-- 458 bytes parent folder | download | duplicates (2)
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
package machineid

import "testing"

func TestID(t *testing.T) {
	got, err := ID()
	if err != nil {
		t.Error(err)
	}
	if got == "" {
		t.Error("Got empty machine id")
	}
}

func TestProtectedID(t *testing.T) {
	id, err := ID()
	if err != nil {
		t.Error(err)
	}
	hash, err := ProtectedID("app.id")
	if err != nil {
		t.Error(err)
	}
	if hash == "" {
		t.Error("Got empty machine id hash")
	}
	if id == hash {
		t.Error("id and hashed id are the same")
	}
}