nebius/SWE-rebench-V2-PRs huggingface dataset:
Repository: scionproto/scion
Pull request #3649 (2020-01-30 14:55:52)

Msgr: Fix svc redirect in UDP only mode
This fixes a bug where SVC is not resolved in a UDP-only configured host.

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/scionproto/scion/3649)
<!-- Reviewable:end -->



Patch:
diff --git a/go/lib/infra/messenger/addr.go b/go/lib/infra/messenger/addr.go
index 93d67ed81..6e63040a0 100644
--- a/go/lib/infra/messenger/addr.go
+++ b/go/lib/infra/messenger/addr.go
@@ -77,7 +77,7 @@ func (r AddressRewriter) RedirectToQUIC(ctx context.Context,
 	// FIXME(scrye): This is not legitimate use. It's only included for
 	// compatibility with older unit tests. See
 	// https://github.com/scionproto/scion/issues/2611.
-	if address == nil || r.SVCResolutionFraction <= 0.0 {
+	if address == nil {
 		return address, false, nil
 	}
 
@@ -89,6 +89,9 @@ func (r AddressRewriter) RedirectToQUIC(ctx context.Context,
 		if err != nil {
 			return nil, false, err
 		}
+		if r.SVCResolutionFraction <= 0.0 {
+			return fa, false, nil
+		}
 
 		path, err := fa.GetPath()
 		if err != nil {


Test patch:
diff --git a/go/lib/infra/messenger/addr_test.go b/go/lib/infra/messenger/addr_test.go
index 9e2226531..dbbf30697 100644
--- a/go/lib/infra/messenger/addr_test.go
+++ b/go/lib/infra/messenger/addr_test.go
@@ -49,12 +49,6 @@ func TestRedirectQUIC(t *testing.T) {
 			wantAddr:  nil,
 			assertErr: assert.NoError,
 		},
-		"disabling SVC resolution, ": {
-			input:                 &snet.SVCAddr{},
-			wantAddr:              &snet.SVCAddr{},
-			SVCResolutionFraction: 0.0,
-			assertErr:             assert.NoError,
-		},
 		"not nil invalid addr, error": {
 			input:                 &net.TCPAddr{},
 			wantAddr:              nil,
@@ -158,6 +152,38 @@ func TestRedirectQUIC(t *testing.T) {
 		assert.Equal(t, want, a)
 		assert.True(t, r)
 	})
+
+	t.Run("valid SVCAddr, no resolution, resolves path", func(t *testing.T) {
+		ctrl := gomock.NewController(t)
+		defer ctrl.Finish()
+		router := mock_snet.NewMockRouter(ctrl)
+
+		path := mock_snet.NewMockPath(ctrl)
+		router.EXPECT().Route(gomock.Any(), gomock.Any()).Return(path, nil)
+		path.EXPECT().Path().Return(nil)
+		path.EXPECT().OverlayNextHop().Return(&net.UDPAddr{IP: net.ParseIP("10.1.1.1")})
+		path.EXPECT().Fingerprint().Return(snet.PathFingerprint(""))
+		svcRouter := mock_messenger.NewMockLocalSVCRouter(ctrl)
+		svcRouter.EXPECT().GetOverlay(addr.SvcBS).Return(
+			&net.UDPAddr{IP: net.ParseIP("10.1.1.1")}, nil,
+		)
+
+		aw := messenger.AddressRewriter{
+			Router:                router,
+			SVCRouter:             svcRouter,
+			SVCResolutionFraction: 0.0,
+		}
+
+		input := &snet.SVCAddr{SVC: addr.SvcBS}
+		want := &snet.SVCAddr{
+			SVC:     addr.SvcBS,
+			NextHop: &net.UDPAddr{IP: net.ParseIP("10.1.1.1")},
+		}
+		a, r, err := aw.RedirectToQUIC(context.Background(), input)
+		assert.NoError(t, err)
+		assert.Equal(t, want, a)
+		assert.False(t, r)
+	})
 }
 
 func TestBuildFullAddress(t *testing.T) {
Repository: scionproto/scion
Pull request #3657 (2020-02-06 09:55:07)

Fake SCIOND: Use MTU of 1472
We are using 1472 as a default averywhere else.

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/scionproto/scion/3657)
<!-- Reviewable:end -->



Patch:
diff --git a/go/lib/sciond/fake/fake.go b/go/lib/sciond/fake/fake.go
index 88937980d..6f7e10cd6 100644
--- a/go/lib/sciond/fake/fake.go
+++ b/go/lib/sciond/fake/fake.go
@@ -111,7 +111,7 @@ func (p Path) Destination() addr.IA {
 }
 
 func (p Path) MTU() uint16 {
-	return 1500
+	return 1472
 }
 
 func (p Path) Expiry() time.Time {


Test patch:
diff --git a/go/lib/sciond/fake/fake_test.go b/go/lib/sciond/fake/fake_test.go
index 9cc0c9eb1..f308ca5b1 100644
--- a/go/lib/sciond/fake/fake_test.go
+++ b/go/lib/sciond/fake/fake_test.go
@@ -111,7 +111,7 @@ func TestPaths(t *testing.T) {
 	assert.Equal(t, fake.DummyPath(), paths[0].Path())
 	assert.Equal(t, []snet.PathInterface{}, paths[0].Interfaces())
 	assert.Equal(t, xtest.MustParseIA("1-ff00:0:1"), paths[0].Destination())
-	assert.Equal(t, uint16(1500), paths[0].MTU())
+	assert.Equal(t, uint16(1472), paths[0].MTU())
 	// path valid for more than an hour, but less than three
 	assert.True(t, paths[0].Expiry().After(time.Now().Add(time.Hour)))
 	assert.True(t, paths[0].Expiry().Before(time.Now().Add(3*time.Hour)))
@@ -132,7 +132,7 @@ func TestPaths(t *testing.T) {
 	assert.Equal(t, fake.DummyPath(), paths[0].Path())
 	assert.Equal(t, []snet.PathInterface{}, paths[0].Interfaces())
 	assert.Equal(t, xtest.MustParseIA("2-ff00:0:2"), paths[0].Destination())
-	assert.Equal(t, uint16(1500), paths[0].MTU())
+	assert.Equal(t, uint16(1472), paths[0].MTU())
 	// path valid for more than two hours, but less than four
 	assert.True(t, paths[0].Expiry().After(time.Now().Add(2*time.Hour)))
 	assert.True(t, paths[0].Expiry().Before(time.Now().Add(4*time.Hour)))
Repository: xanzy/go-gitlab
Pull request #1018 (2020-12-25 21:41:16)

Add restore group
Adds restore group (only available in silver/premium) to groups API


Patch:
diff --git a/groups.go b/groups.go
index f79cb53..6a3f64f 100644
--- a/groups.go
+++ b/groups.go
@@ -266,6 +266,31 @@ func (s *GroupsService) DeleteGroup(gid interface{}, options ...RequestOptionFun
 	return s.client.Do(req, nil)
 }
 
+// RestoreGroup restores a previously deleted group
+//
+// GitLap API docs:
+// https://docs.gitlab.com/ee/api/groups.html#restore-group-marked-for-deletion
+func (s *GroupsService) RestoreGroup(gid interface{}, options ...RequestOptionFunc) (*Group, *Response, error) {
+	group, err := parseID(gid)
+	if err != nil {
+		return nil, nil, err
+	}
+	u := fmt.Sprintf("groups/%s/restore", pathEscape(group))
+
+	req, err := s.client.NewRequest("POST", u, nil, options)
+	if err != nil {
+		return nil, nil, err
+	}
+
+	g := new(Group)
+	resp, err := s.client.Do(req, g)
+	if err != nil {
+		return nil, resp, err
+	}
+
+	return g, resp, nil
+}
+
 // SearchGroup get all groups that match your string in their name or path.
 //
 // GitLab API docs: https://docs.gitlab.com/ce/api/groups.html#search-for-group


Test patch:
diff --git a/groups_test.go b/groups_test.go
index e318ee7..c8e1902 100644
--- a/groups_test.go
+++ b/groups_test.go
@@ -282,3 +282,22 @@ func TestAddGroupLDAPLink(t *testing.T) {
 		t.Errorf("Groups.AddGroupLDAPLink returned %+v, want %+v", link, want)
 	}
 }
+
+func TestRestoreGroup(t *testing.T) {
+	mux, server, client := setup(t)
+	defer teardown(server)
+	mux.HandleFunc("/api/v4/groups/1/restore",
+		func(w http.ResponseWriter, r *http.Request) {
+			testMethod(t, r, "POST")
+			fmt.Fprint(w, `{"id": 1, "name": "g"}`)
+		})
+
+	group,_, err := client.Groups.RestoreGroup(1)
+	if err != nil {
+		t.Errorf("Groups.RestoreGroup returned error: %v", err)
+	}
+	want := &Group{ID: 1, Name: "g"}
+	if !reflect.DeepEqual(want, group) {
+		t.Errorf("Groups.RestoreGroup returned %+v, want %+v", group, want)
+	}
+}
Repository: xanzy/go-gitlab
Pull request #1024 (2021-01-06 11:52:16)

fix(users.go): fix json unmarshal error of usermembership accesslevel
Fix json unmarshal error of usermembership accesslevel，the gitlab api response accesslevel int type, when unmarshal response will return 400


Patch:
diff --git a/users.go b/users.go
index a3bff6f..3b8dc1b 100644
--- a/users.go
+++ b/users.go
@@ -942,10 +942,10 @@ func (s *UsersService) SetUserStatus(opt *UserStatusOptions, options ...RequestO
 // GitLab API docs:
 // https://docs.gitlab.com/ee/api/users.html#user-memberships-admin-only
 type UserMembership struct {
-	SourceID    int    `json:"source_id"`
-	SourceName  string `json:"source_name"`
-	SourceType  string `json:"source_type"`
-	AccessLevel string `json:"access_level"`
+	SourceID    int              `json:"source_id"`
+	SourceName  string           `json:"source_name"`
+	SourceType  string           `json:"source_type"`
+	AccessLevel AccessLevelValue `json:"access_level"`
 }
 
 // GetUserMembershipOptions represents the options available to query user memberships.


Test patch:
diff --git a/testdata/get_user_memberships.json b/testdata/get_user_memberships.json
index 80dfd62..198bba8 100644
--- a/testdata/get_user_memberships.json
+++ b/testdata/get_user_memberships.json
@@ -3,12 +3,12 @@
     "source_id": 1,
     "source_name": "Project one",
     "source_type": "Project",
-    "access_level": "20"
+    "access_level": 20
   },
   {
     "source_id": 3,
     "source_name": "Group three",
     "source_type": "Namespace",
-    "access_level": "20"
+    "access_level": 20
   }
 ]
diff --git a/users_test.go b/users_test.go
index 283eadf..4445721 100644
--- a/users_test.go
+++ b/users_test.go
@@ -253,6 +253,6 @@ func TestGetMemberships(t *testing.T) {
 	memberships, _, err := client.Users.GetUserMemberships(1, opt)
 	require.NoError(t, err)
 
-	want := []*UserMembership{{SourceID: 1, SourceName: "Project one", SourceType: "Project", AccessLevel: "20"}, {SourceID: 3, SourceName: "Group three", SourceType: "Namespace", AccessLevel: "20"}}
+	want := []*UserMembership{{SourceID: 1, SourceName: "Project one", SourceType: "Project", AccessLevel: 20}, {SourceID: 3, SourceName: "Group three", SourceType: "Namespace", AccessLevel: 20}}
 	assert.Equal(t, want, memberships)
 }