Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit f2b4e37

Browse filesBrowse files
committed
util: Expose rights' NewContext
1 parent 15a0642 commit f2b4e37
Copy full SHA for f2b4e37

4 files changed

+5-4Lines changed: 5 additions & 4 deletions

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎pkg/auth/rights/hook.go‎

Copy file name to clipboardExpand all lines: pkg/auth/rights/hook.go
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ func Hook(next grpc.UnaryHandler) grpc.UnaryHandler {
9696
return nil, err
9797
}
9898
}
99-
ctx = newContext(ctx, results)
99+
ctx = NewContext(ctx, results)
100100
return next(ctx, req)
101101
}
102102
}
Collapse file

‎pkg/auth/rights/require_test.go‎

Copy file name to clipboardExpand all lines: pkg/auth/rights/require_test.go
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ func TestRequire(t *testing.T) {
6464
RequireOrganization(test.Context(), ttnpb.OrganizationIdentifiers{}, ttnpb.RIGHT_ORGANIZATION_INFO)
6565
}, should.Panic)
6666

67-
fooCtx := newContext(test.Context(), Rights{
67+
fooCtx := NewContext(test.Context(), Rights{
6868
ApplicationRights: map[ttnpb.ApplicationIdentifiers][]ttnpb.Right{
6969
{ApplicationID: "foo"}: {ttnpb.RIGHT_APPLICATION_INFO},
7070
},
Collapse file

‎pkg/auth/rights/rights.go‎

Copy file name to clipboardExpand all lines: pkg/auth/rights/rights.go
+2-1Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ func FromContext(ctx context.Context) (Rights, bool) {
5555
return Rights{}, false
5656
}
5757

58-
func newContext(ctx context.Context, rights Rights) context.Context {
58+
// NewContext returns a derived context with the given rights.
59+
func NewContext(ctx context.Context, rights Rights) context.Context {
5960
return context.WithValue(ctx, rightsKey, rights)
6061
}
Collapse file

‎pkg/auth/rights/rights_test.go‎

Copy file name to clipboardExpand all lines: pkg/auth/rights/rights_test.go
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ func TestContext(t *testing.T) {
4242
},
4343
}
4444

45-
ctx := newContext(test.Context(), fooRights)
45+
ctx := NewContext(test.Context(), fooRights)
4646

4747
rights, ok = FromContext(ctx)
4848
a.So(ok, should.BeTrue)

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.