forked from taskcluster/taskcluster
-
Notifications
You must be signed in to change notification settings - Fork 0
/
os_groups_windows_test.go
60 lines (52 loc) · 1.79 KB
/
os_groups_windows_test.go
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
package main
import (
"fmt"
"strings"
"testing"
)
func TestMissingScopesOSGroups(t *testing.T) {
setup(t)
payload := GenericWorkerPayload{
Command: helloGoodbye(),
MaxRunTime: 30,
OSGroups: []string{"abc", "def"},
}
td := testTask(t)
// don't set any scopes
_ = submitAndAssert(t, td, payload, "exception", "malformed-payload")
logtext := LogText(t)
if !strings.Contains(logtext, "generic-worker:os-group:"+td.ProvisionerID+"/"+td.WorkerType+"/abc") || !strings.Contains(logtext, "generic-worker:os-group:"+td.ProvisionerID+"/"+td.WorkerType+"/def") {
t.Fatalf("Was expecting log file to contain missing scopes, but it doesn't")
}
}
func TestOSGroupsRespected(t *testing.T) {
setup(t)
payload := GenericWorkerPayload{
Command: helloGoodbye(),
MaxRunTime: 30,
OSGroups: []string{"abc", "def"},
}
td := testTask(t)
td.Scopes = []string{
"generic-worker:os-group:" + td.ProvisionerID + "/" + td.WorkerType + "/abc",
"generic-worker:os-group:" + td.ProvisionerID + "/" + td.WorkerType + "/def",
}
if config.RunTasksAsCurrentUser {
_ = submitAndAssert(t, td, payload, "completed", "completed")
logtext := LogText(t)
substring := fmt.Sprintf("Not adding task user to group(s) %v since we are running as current user.", payload.OSGroups)
if !strings.Contains(logtext, substring) {
t.Log(logtext)
t.Fatalf("Was expecting log to contain string: '%v'", substring)
}
} else {
// check task had malformed payload, due to non existent groups
_ = submitAndAssert(t, td, payload, "exception", "malformed-payload")
logtext := LogText(t)
substring := fmt.Sprintf("Could not add task user to os group(s): %v", payload.OSGroups)
if !strings.Contains(logtext, substring) {
t.Log(logtext)
t.Fatalf("Was expecting log to contain string: '%v'", substring)
}
}
}