mirror of
https://github.com/datarhei/core.git
synced 2025-10-05 16:07:07 +08:00
Loosen restrictions for IAM user names
The only restriction for an IAM username is that it cannot start with a '$'. An username that contains a ':' must escape it with another ':' for use in a token for RTMP or SRT.
This commit is contained in:
41
encoding/token/token_test.go
Normal file
41
encoding/token/token_test.go
Normal file
@@ -0,0 +1,41 @@
|
||||
package token
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
func TestMarshal(t *testing.T) {
|
||||
token := "xxx"
|
||||
|
||||
data := [][2]string{
|
||||
{"", ""},
|
||||
{"foo", "foo"},
|
||||
{"foo:bar", "foo::bar"},
|
||||
{"foo::bar", "foo::::bar"},
|
||||
}
|
||||
|
||||
for _, d := range data {
|
||||
encoded := Marshal(d[0], token)
|
||||
require.Equal(t, d[1]+":"+token, encoded, d[1])
|
||||
}
|
||||
}
|
||||
|
||||
func TestUnmarshal(t *testing.T) {
|
||||
data := [][3]string{
|
||||
{"foo", "", "foo"},
|
||||
{"fo::o", "", "fo::o"},
|
||||
{"::foo", "", "::foo"},
|
||||
{":xxx", "", "xxx"},
|
||||
{"foo:xxx", "foo", "xxx"},
|
||||
{"foo::bar:xxx", "foo:bar", "xxx"},
|
||||
{"foo::::bar:xxx", "foo::bar", "xxx"},
|
||||
}
|
||||
|
||||
for _, d := range data {
|
||||
username, token := Unmarshal(d[0])
|
||||
require.Equal(t, d[1], username, d[0])
|
||||
require.Equal(t, d[2], token)
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user