forked from cloudfoundry/guardian
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathsubuid_test.go
44 lines (38 loc) · 1.34 KB
/
subuid_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
package sysinfo_test
import (
"code.cloudfoundry.org/guardian/sysinfo"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
)
var _ = Describe("UidCanMapRange", func() {
Context("when the uid can map the exact provided range", func() {
It("returns true", func() {
subidFileContents := "1000:0:10\n"
Expect(sysinfo.UidCanMapExactRange(subidFileContents, "frank", 1000, 0, 10)).To(BeTrue())
})
})
Context("when the username can map the exact provided range", func() {
It("returns true", func() {
subidFileContents := "frank:0:10\n"
Expect(sysinfo.UidCanMapExactRange(subidFileContents, "frank", 1000, 0, 10)).To(BeTrue())
})
})
Context("when the uid can map some of the provided range", func() {
It("returns false", func() {
subidFileContents := "1000:0:10\n"
Expect(sysinfo.UidCanMapExactRange(subidFileContents, "frank", 1000, 0, 9)).To(BeFalse())
})
})
Context("when the uid can't map the desired range", func() {
It("returns false", func() {
subidFileContents := "1000:0:9\n"
Expect(sysinfo.UidCanMapExactRange(subidFileContents, "frank", 1000, 0, 10)).To(BeFalse())
})
})
Context("when the uid is not found in the subid file", func() {
It("returns false", func() {
subidFileContents := "1001:0:11\n"
Expect(sysinfo.UidCanMapExactRange(subidFileContents, "frank", 1000, 0, 10)).To(BeFalse())
})
})
})