Repository: dexidp/dex
Pull request #2683 (2022-09-28 14:49:03)

supply HMACKey in test case
commit 49471b14c8080ddb034d4855841123d378b7a634 has a failing test case due to the lack of specification of an HMACKey

https://github.com/dexidp/dex/actions/runs/3144248007/jobs/5110000846

Signed-off-by: Bob Callaway <bcallaway@google.com>


Patch:
diff --git a/connector/google/google.go b/connector/google/google.go
index 72cc6a18..313858f6 100644
--- a/connector/google/google.go
+++ b/connector/google/google.go
@@ -71,10 +71,13 @@ func (c *Config) Open(id string, logger log.Logger) (conn connector.Connector, e
 		scopes = append(scopes, "profile", "email")
 	}
 
-	srv, err := createDirectoryService(c.ServiceAccountFilePath, c.AdminEmail, logger)
-	if err != nil {
-		cancel()
-		return nil, fmt.Errorf("could not create directory service: %v", err)
+	var srv *admin.Service
+	if len(c.Groups) > 0 {
+		srv, err = createDirectoryService(c.ServiceAccountFilePath, c.AdminEmail, logger)
+		if err != nil {
+			cancel()
+			return nil, fmt.Errorf("could not create directory service: %v", err)
+		}
 	}
 
 	clientID := c.ClientID
diff --git a/storage/conformance/transactions.go b/storage/conformance/transactions.go
index 2fc6755b..1d4011a4 100644
--- a/storage/conformance/transactions.go
+++ b/storage/conformance/transactions.go
@@ -75,6 +75,7 @@ func testAuthRequestConcurrentUpdate(t *testing.T, s storage.Storage) {
 			EmailVerified: true,
 			Groups:        []string{"a", "b"},
 		},
+		HMACKey: []byte("hmac_key"),
 	}
 
 	if err := s.CreateAuthRequest(a); err != nil {


Test patch:
diff --git a/connector/google/google_test.go b/connector/google/google_test.go
index 5cecbec9..26241ab6 100644
--- a/connector/google/google_test.go
+++ b/connector/google/google_test.go
@@ -72,12 +72,22 @@ func TestOpen(t *testing.T) {
 	assert.Nil(t, err)
 
 	for name, reference := range map[string]testCase{
+		"not_requesting_groups": {
+			config: &Config{
+				ClientID:     "testClient",
+				ClientSecret: "testSecret",
+				RedirectURI:  ts.URL + "/callback",
+				Scopes:       []string{"openid"},
+			},
+			expectedErr: "",
+		},
 		"missing_admin_email": {
 			config: &Config{
 				ClientID:     "testClient",
 				ClientSecret: "testSecret",
 				RedirectURI:  ts.URL + "/callback",
 				Scopes:       []string{"openid", "groups"},
+				Groups:       []string{"someGroup"},
 			},
 			expectedErr: "requires adminEmail",
 		},
@@ -89,6 +99,7 @@ func TestOpen(t *testing.T) {
 				Scopes:                 []string{"openid", "groups"},
 				AdminEmail:             "foo@bar.com",
 				ServiceAccountFilePath: "not_found.json",
+				Groups:                 []string{"someGroup"},
 			},
 			expectedErr: "error reading credentials",
 		},
@@ -100,6 +111,7 @@ func TestOpen(t *testing.T) {
 				Scopes:                 []string{"openid", "groups"},
 				AdminEmail:             "foo@bar.com",
 				ServiceAccountFilePath: serviceAccountFilePath,
+				Groups:                 []string{"someGroup"},
 			},
 			expectedErr: "",
 		},
@@ -110,6 +122,7 @@ func TestOpen(t *testing.T) {
 				RedirectURI:  ts.URL + "/callback",
 				Scopes:       []string{"openid", "groups"},
 				AdminEmail:   "foo@bar.com",
+				Groups:       []string{"someGroup"},
 			},
 			adc:         serviceAccountFilePath,
 			expectedErr: "",
@@ -122,6 +135,7 @@ func TestOpen(t *testing.T) {
 				Scopes:                 []string{"openid", "groups"},
 				AdminEmail:             "foo@bar.com",
 				ServiceAccountFilePath: serviceAccountFilePath,
+				Groups:                 []string{"someGroup"},
 			},
 			adc:         "/dev/null",
 			expectedErr: "",