c.Check(arvados.NewClientFromEnv().RequestAndDecode(nil, "POST", "database/reset", nil, nil), check.IsNil)
}
+// TODO: In the interest of reducing redundant tests: It looks like if we change
+// Given/Family names to {"Fake", "User Name"} in SetUpTest, and update
+// TestGoogleLogin_Success accordingly, then we wouldn't even need a separate
+// TestGoogleLogin_OIDCClamisWithGivenNames test to check the normal case, and
+// the old/renamed OIDCNameWithoutGivenAndFamilyNames test would check the case
+// where we fall back to splitting on whitespace.
+
func (s *OIDCLoginSuite) SetUpTest(c *check.C) {
s.fakeProvider = arvadostest.NewOIDCProvider(c)
s.fakeProvider.AuthEmail = "active-user@arvados.local"
s.fakeProvider.AuthEmailVerified = true
s.fakeProvider.AuthName = "Fake User Name"
+ s.fakeProvider.AuthGivenName = "Fake User"
+ s.fakeProvider.AuthFamilyName = "Name"
s.fakeProvider.ValidCode = fmt.Sprintf("abcdefgh-%d", time.Now().Unix())
s.fakeProvider.PeopleAPIResponse = map[string]interface{}{}
func (s *OIDCLoginSuite) TestGoogleLogin_RealName(c *check.C) {
s.fakeProvider.AuthEmail = "joe.smith@primary.example.com"
+ s.fakeProvider.AuthEmailVerified = true
s.fakeProvider.PeopleAPIResponse = map[string]interface{}{
"names": []map[string]interface{}{
{
c.Check(authinfo.LastName, check.Equals, "Psmith")
}
-func (s *OIDCLoginSuite) TestGoogleLogin_OIDCRealName(c *check.C) {
+func (s *OIDCLoginSuite) TestGoogleLogin_OIDCNameWithoutGivenAndFamilyNames(c *check.C) {
s.fakeProvider.AuthName = "Joe P. Smith"
+ s.fakeProvider.AuthGivenName = ""
+ s.fakeProvider.AuthFamilyName = ""
s.fakeProvider.AuthEmail = "joe.smith@primary.example.com"
state := s.startLogin(c)
s.localdb.Login(context.Background(), arvados.LoginOptions{
c.Check(authinfo.LastName, check.Equals, "Smith")
}
+func (s *OIDCLoginSuite) TestGoogleLogin_OIDCClaimsWithGivenNames(c *check.C) {
+ s.fakeProvider.AuthName = "Federico Garcia Lorca"
+ s.fakeProvider.AuthGivenName = "Federico"
+ s.fakeProvider.AuthFamilyName = "Garcia Lorca"
+ s.fakeProvider.AuthEmail = "federico.garcia.lorca@primary.example.com"
+ state := s.startLogin(c)
+ s.localdb.Login(context.Background(), arvados.LoginOptions{
+ Code: s.fakeProvider.ValidCode,
+ State: state,
+ })
+
+ authinfo := getCallbackAuthInfo(c, s.railsSpy)
+ c.Check(authinfo.FirstName, check.Equals, "Federico")
+ c.Check(authinfo.LastName, check.Equals, "Garcia Lorca")
+}
+
// People API returns some additional email addresses.
func (s *OIDCLoginSuite) TestGoogleLogin_AlternateEmailAddresses(c *check.C) {
s.fakeProvider.AuthEmail = "joe.smith@primary.example.com"