Files
o11y/pkg/valuer/email_test.go
Vibhu PandeyandGitHub 03fb051a9c feat(tokenizer|sso): add tokenizer for session management and oidc sso support (#9183)
## 📄 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
2025-10-16 18:00:38 +05:30

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)
})
}
}