MCPcopy Index your code
hub / github.com/coder/coder / TestAuthzRecorder

Function TestAuthzRecorder

coderd/coderdtest/authorize_test.go:15–102  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

13)
14
15func TestAuthzRecorder(t *testing.T) {
16 t.Parallel()
17
18 t.Run("Authorize", func(t *testing.T) {
19 t.Parallel()
20
21 rec := &coderdtest.RecordingAuthorizer{
22 Wrapped: &coderdtest.FakeAuthorizer{},
23 }
24 sub := coderdtest.RandomRBACSubject()
25 pairs := fuzzAuthz(t, sub, rec, 10)
26 rec.AssertActor(t, sub, pairs...)
27 require.NoError(t, rec.AllAsserted(), "all assertions should have been made")
28 })
29
30 t.Run("Authorize2Subjects", func(t *testing.T) {
31 t.Parallel()
32
33 rec := &coderdtest.RecordingAuthorizer{
34 Wrapped: &coderdtest.FakeAuthorizer{},
35 }
36 a := coderdtest.RandomRBACSubject()
37 aPairs := fuzzAuthz(t, a, rec, 10)
38
39 b := coderdtest.RandomRBACSubject()
40 bPairs := fuzzAuthz(t, b, rec, 10)
41
42 rec.AssertActor(t, b, bPairs...)
43 rec.AssertActor(t, a, aPairs...)
44 require.NoError(t, rec.AllAsserted(), "all assertions should have been made")
45 })
46
47 t.Run("Authorize_Prepared", func(t *testing.T) {
48 t.Parallel()
49
50 rec := &coderdtest.RecordingAuthorizer{
51 Wrapped: &coderdtest.FakeAuthorizer{},
52 }
53 a := coderdtest.RandomRBACSubject()
54 aPairs := fuzzAuthz(t, a, rec, 10)
55
56 b := coderdtest.RandomRBACSubject()
57
58 act, objTy := coderdtest.RandomRBACAction(), coderdtest.RandomRBACObject().Type
59 prep, _ := rec.Prepare(context.Background(), b, act, objTy)
60 bPairs := fuzzAuthzPrep(t, prep, 10, act, objTy)
61
62 rec.AssertActor(t, b, bPairs...)
63 rec.AssertActor(t, a, aPairs...)
64 require.NoError(t, rec.AllAsserted(), "all assertions should have been made")
65 })
66
67 t.Run("AuthorizeOutOfOrder", func(t *testing.T) {
68 t.Parallel()
69
70 rec := &coderdtest.RecordingAuthorizer{
71 Wrapped: &coderdtest.FakeAuthorizer{},
72 }

Callers

nothing calls this directly

Calls 11

AssertActorMethod · 0.95
AllAssertedMethod · 0.95
PrepareMethod · 0.95
AssertOutOfOrderMethod · 0.95
AllCallsMethod · 0.95
RandomRBACSubjectFunction · 0.92
RandomRBACActionFunction · 0.92
RandomRBACObjectFunction · 0.92
fuzzAuthzFunction · 0.85
fuzzAuthzPrepFunction · 0.85
RunMethod · 0.65

Tested by

no test coverage detected