mirror of
https://github.com/hanzoai/o11y.git
synced 2026-10-15 12:58:33 +00:00
## 📄 Summary
- Instead of relying on JWT for session management, we are adding another token system: opaque. This gives the benefits of expiration and revocation.
- We are now ensuring that emails are regex checked throughout the backend.
- Support has been added for OIDC protocol
40 lines
1.3 KiB
Go
40 lines
1.3 KiB
Go
package valuer
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
)
|
|
|
|
func TestNewEmail(t *testing.T) {
|
|
tests := []struct {
|
|
name string
|
|
val string
|
|
want Email
|
|
pass bool
|
|
}{
|
|
{name: "Valid", val: "[email protected]", want: Email{val: "[email protected]"}, pass: true},
|
|
{name: "ValidWithPlus", val: "[email protected]", want: Email{val: "[email protected]"}, pass: true},
|
|
{name: "ValidWithMultipleDotsInDomain", val: "[email protected]", want: Email{val: "[email protected]"}, pass: true},
|
|
{name: "InvalidMissingAt", val: "testtest.com", want: Email{val: ""}, pass: false},
|
|
{name: "InvalidMissingDot", val: "test@testcom", want: Email{val: ""}, pass: false},
|
|
{name: "InvalidMissingLocalPart", val: "@test.com", want: Email{val: ""}, pass: false},
|
|
{name: "InvalidMissingDomain", val: "[email protected]", want: Email{val: ""}, pass: false},
|
|
{name: "InvalidMissingLocalPartAndDomain", val: "@.com", want: Email{val: ""}, pass: false},
|
|
{name: "InvalidMissingTldAndDomain", val: "test.c", want: Email{val: ""}, pass: false},
|
|
}
|
|
|
|
for _, test := range tests {
|
|
t.Run(test.name, func(t *testing.T) {
|
|
got, err := NewEmail(test.val)
|
|
if !test.pass {
|
|
assert.Error(t, err)
|
|
return
|
|
}
|
|
|
|
assert.NoError(t, err)
|
|
assert.Equal(t, test.want, got)
|
|
})
|
|
}
|
|
}
|