nebius/SWE-rebench-V2-PRs huggingface dataset:
Repository: dexidp/dex
Pull request #1661 (2020-02-21 15:55:31)

Setting email for OpenShift connector
Automatically sets the email field to be based on the username for the OpenShift connector


Patch:
diff --git a/connector/openshift/openshift.go b/connector/openshift/openshift.go
index 6ac5d044..090d04ff 100644
--- a/connector/openshift/openshift.go
+++ b/connector/openshift/openshift.go
@@ -177,6 +177,7 @@ func (c *openshiftConnector) HandleCallback(s connector.Scopes, r *http.Request)
 		UserID:            user.UID,
 		Username:          user.Name,
 		PreferredUsername: user.Name,
+		Email:             user.Name,
 		Groups:            user.Groups,
 	}
 


Test patch:
diff --git a/connector/openshift/openshift_test.go b/connector/openshift/openshift_test.go
index 316af60a..d4efa14d 100644
--- a/connector/openshift/openshift_test.go
+++ b/connector/openshift/openshift_test.go
@@ -180,6 +180,7 @@ func TestCallbackIdentity(t *testing.T) {
 	expectEquals(t, identity.UserID, "12345")
 	expectEquals(t, identity.Username, "jdoe")
 	expectEquals(t, identity.PreferredUsername, "jdoe")
+	expectEquals(t, identity.Email, "jdoe")
 	expectEquals(t, len(identity.Groups), 1)
 	expectEquals(t, identity.Groups[0], "users")
 }
Repository: dexidp/dex
Pull request #1690 (2020-04-16 20:52:31)

Fix templates which asset path points to external URL
## Description:
#1554 breaks the ability to specify an icon for header using external URL like [this one](https://kubernetes.io/images/favicon.png).

I added check, that if assetURL points to external URL, no transformations required.

sagikazarmark: @nabokihms can you please rebase your branch?

Patch:
diff --git a/server/templates.go b/server/templates.go
index 4947a102..bc2c81eb 100644
--- a/server/templates.go
+++ b/server/templates.go
@@ -176,6 +176,11 @@ func loadTemplates(c webConfig, templatesDir string) (*templates, error) {
 //assetPath is static/main.css
 //relativeURL("/dex", "/dex/auth", "static/main.css") = "../static/main.css"
 func relativeURL(serverPath, reqPath, assetPath string) string {
+	if u, err := url.ParseRequestURI(assetPath); err == nil && u.Scheme != "" {
+		// assetPath points to the external URL, no changes needed
+		return assetPath
+	}
+
 	splitPath := func(p string) []string {
 		res := []string{}
 		parts := strings.Split(path.Clean(p), "/")


Test patch:
diff --git a/server/templates_test.go b/server/templates_test.go
index 5ead66e5..defb2e5e 100644
--- a/server/templates_test.go
+++ b/server/templates_test.go
@@ -31,6 +31,13 @@ func TestRelativeURL(t *testing.T) {
 			assetPath:  "assets/css/main.css",
 			expected:   "../assets/css/main.css",
 		},
+		{
+			name:       "external-url",
+			serverPath: "/dex",
+			reqPath:    "/dex/auth/connector",
+			assetPath:  "https://kubernetes.io/images/favicon.png",
+			expected:   "https://kubernetes.io/images/favicon.png",
+		},
 	}
 
 	for _, test := range tests {
Repository: dexidp/dex
Pull request #3563 (2024-06-03 19:11:08)

Fix slog nil pointer error

<!--
Thank you for sending a pull request! Here are some tips for contributors:

1. Fill the description template below.
2. Sign a DCO (if you haven't already signed it).
3. Include appropriate tests (if necessary). Make sure that all CI checks passed.
4. If the Pull Request is a work in progress, make use of GitHub's "Draft PR" feature and mark it as such.
-->

#### Overview

The problem caused by the mistake in the newLogger function. The nil value is returned even with the valid log format.

#### What this PR does / why we need it

Closes https://github.com/dexidp/dex/issues/3559

#### Special notes for your reviewer



Patch:
diff --git a/cmd/dex/serve.go b/cmd/dex/serve.go
index b39354ec..456e07f6 100644
--- a/cmd/dex/serve.go
+++ b/cmd/dex/serve.go
@@ -520,11 +520,11 @@ func newLogger(level slog.Level, format string) (*slog.Logger, error) {
 	var handler slog.Handler
 	switch strings.ToLower(format) {
 	case "", "text":
-		slog.NewTextHandler(os.Stderr, &slog.HandlerOptions{
+		handler = slog.NewTextHandler(os.Stderr, &slog.HandlerOptions{
 			Level: level,
 		})
 	case "json":
-		slog.NewJSONHandler(os.Stderr, &slog.HandlerOptions{
+		handler = slog.NewJSONHandler(os.Stderr, &slog.HandlerOptions{
 			Level: level,
 		})
 	default:


Test patch:
diff --git a/cmd/dex/serve_test.go b/cmd/dex/serve_test.go
new file mode 100644
index 00000000..9e214480
--- /dev/null
+++ b/cmd/dex/serve_test.go
@@ -0,0 +1,29 @@
+package main
+
+import (
+	"log/slog"
+	"testing"
+
+	"github.com/stretchr/testify/require"
+)
+
+func TestNewLogger(t *testing.T) {
+	t.Run("JSON", func(t *testing.T) {
+		logger, err := newLogger(slog.LevelInfo, "json")
+		require.NoError(t, err)
+		require.NotEqual(t, (*slog.Logger)(nil), logger)
+	})
+
+	t.Run("Text", func(t *testing.T) {
+		logger, err := newLogger(slog.LevelError, "text")
+		require.NoError(t, err)
+		require.NotEqual(t, (*slog.Logger)(nil), logger)
+	})
+
+	t.Run("Unknown", func(t *testing.T) {
+		logger, err := newLogger(slog.LevelError, "gofmt")
+		require.Error(t, err)
+		require.Equal(t, "log format is not one of the supported values (json, text): gofmt", err.Error())
+		require.Equal(t, (*slog.Logger)(nil), logger)
+	})
+}