MCPcopy Create free account
hub / github.com/TheThingsNetwork/lorawan-stack / TestAuth

Function TestAuth

pkg/auth/auth_test.go:26–48  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

24)
25
26func TestAuth(t *testing.T) {
27 a := assertions.New(t)
28
29 token, err := auth.APIKey.Generate(test.Context(), "")
30 a.So(err, should.BeNil)
31
32 tokenType, id, key, err := auth.SplitToken(token)
33 a.So(err, should.BeNil)
34 a.So(tokenType, should.Equal, auth.APIKey)
35 a.So(tokenType.String(), should.Equal, "APIKey")
36
37 a.So(auth.JoinToken(tokenType, id, key), should.Equal, token)
38
39 for _, token := range []string{
40 "FOO", // invalid length
41 "FOO.FOO", // invalid length
42 "FOO.FOO.FOO", // invalid type
43 "FOO.FOO.FOO.FOO", // invalid length
44 } {
45 _, _, _, err := auth.SplitToken(token)
46 a.So(err, should.NotBeNil)
47 }
48}

Callers

nothing calls this directly

Calls 6

ContextFunction · 0.92
SplitTokenFunction · 0.92
JoinTokenFunction · 0.92
NewMethod · 0.65
GenerateMethod · 0.65
StringMethod · 0.65

Tested by

no test coverage detected