nebius/SWE-rebench-V2-PRs huggingface dataset:
Repository: softlayer/softlayer-python
Pull request #591 (2015-07-29 21:43:47)

Re-enables the use of custom headers on a per-API-call basis
This was unintentionally removed some time in the past


Patch:
diff --git a/SoftLayer/API.py b/SoftLayer/API.py
index 09a6c63c..2612d412 100644
--- a/SoftLayer/API.py
+++ b/SoftLayer/API.py
@@ -223,6 +223,7 @@ def call(self, service, method, *args, **kwargs):
 
             request = self.auth.get_request(request)
 
+        request.headers.update(kwargs.get('headers', {}))
         return self.transport(request)
 
     __call__ = call


Test patch:
diff --git a/SoftLayer/testing/xmlrpc.py b/SoftLayer/testing/xmlrpc.py
index 47272616..d13753b3 100644
--- a/SoftLayer/testing/xmlrpc.py
+++ b/SoftLayer/testing/xmlrpc.py
@@ -49,6 +49,7 @@ def do_POST(self):
                                                   'InitParameters').get('id')
             req.transport_headers = dict(((k.lower(), v)
                                           for k, v in self.headers.items()))
+            req.headers = headers
 
             # Get response
             response = self.server.transport(req)
diff --git a/SoftLayer/tests/api_tests.py b/SoftLayer/tests/api_tests.py
index 95272d0a..34df1517 100644
--- a/SoftLayer/tests/api_tests.py
+++ b/SoftLayer/tests/api_tests.py
@@ -89,9 +89,11 @@ def test_complex(self):
             1234,
             id=5678,
             mask={'object': {'attribute': ''}},
+            headers={'header': 'value'},
             raw_headers={'RAW': 'HEADER'},
             filter=_filter,
-            limit=9, offset=10)
+            limit=9,
+            offset=10)
 
         self.assertEqual(resp, {"test": "result"})
         self.assert_called_with('SoftLayer_SERVICE', 'METHOD',
@@ -102,6 +104,10 @@ def test_complex(self):
                                 limit=9,
                                 offset=10,
                                 )
+        calls = self.calls('SoftLayer_SERVICE', 'METHOD')
+        self.assertEqual(len(calls), 1)
+        self.assertIn('header', calls[0].headers)
+        self.assertEqual(calls[0].headers['header'], 'value')
 
     @mock.patch('SoftLayer.API.BaseClient.iter_call')
     def test_iterate(self, _iter_call):
Repository: softlayer/softlayer-python
Pull request #688 (2016-02-17 05:11:51)

Returns the new record when calling DNSManager.create_record
Resolves issue #660 


Patch:
diff --git a/SoftLayer/managers/dns.py b/SoftLayer/managers/dns.py
index ce6cf790..c2524800 100644
--- a/SoftLayer/managers/dns.py
+++ b/SoftLayer/managers/dns.py
@@ -92,7 +92,7 @@ def create_record(self, zone_id, record, record_type, data, ttl=60):
         :param integer ttl: the TTL or time-to-live value (default: 60)
 
         """
-        self.record.createObject({
+        return self.record.createObject({
             'domainId': zone_id,
             'ttl': ttl,
             'host': record,


Test patch:
diff --git a/tests/managers/dns_tests.py b/tests/managers/dns_tests.py
index 254fbc9d..8cd83a3a 100644
--- a/tests/managers/dns_tests.py
+++ b/tests/managers/dns_tests.py
@@ -77,7 +77,8 @@ def test_edit_zone(self):
                                 args=('example.com',))
 
     def test_create_record(self):
-        self.dns_client.create_record(1, 'test', 'TXT', 'testing', ttl=1200)
+        res = self.dns_client.create_record(1, 'test', 'TXT', 'testing',
+                                            ttl=1200)
 
         self.assert_called_with('SoftLayer_Dns_Domain_ResourceRecord',
                                 'createObject',
@@ -88,6 +89,7 @@ def test_create_record(self):
                                     'type': 'TXT',
                                     'data': 'testing'
                                 },))
+        self.assertEqual(res, {'name': 'example.com'})
 
     def test_delete_record(self):
         self.dns_client.delete_record(1)
Repository: softlayer/softlayer-python
Pull request #702 (2016-03-20 15:00:37)

Updates CDN manager to use new purge method
Resolves issue #701


Patch:
diff --git a/SoftLayer/fixtures/SoftLayer_Network_ContentDelivery_Account.py b/SoftLayer/fixtures/SoftLayer_Network_ContentDelivery_Account.py
index 9581d5b7..28e043bc 100644
--- a/SoftLayer/fixtures/SoftLayer_Network_ContentDelivery_Account.py
+++ b/SoftLayer/fixtures/SoftLayer_Network_ContentDelivery_Account.py
@@ -33,3 +33,5 @@
 loadContent = True
 
 purgeContent = True
+
+purgeCache = True
diff --git a/SoftLayer/managers/cdn.py b/SoftLayer/managers/cdn.py
index a805ed39..d93f148a 100644
--- a/SoftLayer/managers/cdn.py
+++ b/SoftLayer/managers/cdn.py
@@ -131,8 +131,8 @@ def purge_content(self, account_id, urls):
             urls = [urls]
 
         for i in range(0, len(urls), MAX_URLS_PER_PURGE):
-            result = self.account.purgeContent(urls[i:i + MAX_URLS_PER_PURGE],
-                                               id=account_id)
+            result = self.account.purgeCache(urls[i:i + MAX_URLS_PER_PURGE],
+                                             id=account_id)
             if not result:
                 return result
 


Test patch:
diff --git a/tests/managers/cdn_tests.py b/tests/managers/cdn_tests.py
index e4c20f52..6f438776 100644
--- a/tests/managers/cdn_tests.py
+++ b/tests/managers/cdn_tests.py
@@ -105,7 +105,7 @@ def test_purge_content(self):
 
         self.cdn_client.purge_content(12345, urls)
         calls = self.calls('SoftLayer_Network_ContentDelivery_Account',
-                           'purgeContent')
+                           'purgeCache')
         self.assertEqual(len(calls),
                          math.ceil(len(urls) / float(cdn.MAX_URLS_PER_PURGE)))
 
@@ -115,12 +115,12 @@ def test_purge_content_failure(self):
                 'http://x/img/0x001.png']
 
         mock = self.set_mock('SoftLayer_Network_ContentDelivery_Account',
-                             'purgeContent')
+                             'purgeCache')
         mock.return_value = False
 
         self.cdn_client.purge_content(12345, urls)
         calls = self.calls('SoftLayer_Network_ContentDelivery_Account',
-                           'purgeContent')
+                           'purgeCache')
         self.assertEqual(len(calls),
                          math.ceil(len(urls) / float(cdn.MAX_URLS_PER_PURGE)))
 
@@ -129,6 +129,6 @@ def test_purge_content_single(self):
 
         self.cdn_client.purge_content(12345, url)
         self.assert_called_with('SoftLayer_Network_ContentDelivery_Account',
-                                'purgeContent',
+                                'purgeCache',
                                 args=([url],),
                                 identifier=12345)
Repository: softlayer/softlayer-python
Pull request #769 (2016-08-30 16:36:15)

Enable zone import to import wildcard entries
DNS CLI tests pass


Patch:
diff --git a/SoftLayer/CLI/dns/zone_import.py b/SoftLayer/CLI/dns/zone_import.py
index 6e1259de..7b47cdb1 100644
--- a/SoftLayer/CLI/dns/zone_import.py
+++ b/SoftLayer/CLI/dns/zone_import.py
@@ -9,7 +9,7 @@
 from SoftLayer.CLI import exceptions
 from SoftLayer.CLI import helpers
 
-RECORD_REGEX = re.compile(r"""^((?P<domain>([\w-]+(\.)?)*|\@)?\s+
+RECORD_REGEX = re.compile(r"""^((?P<domain>(([\w-]+|\*)(\.)?)*|\@)?\s+
                                (?P<ttl>\d+)?\s+
                                (?P<class>\w+)?)?\s+
                                (?P<type>\w+)\s+


Test patch:
diff --git a/tests/CLI/modules/dns_tests.py b/tests/CLI/modules/dns_tests.py
index d537872d..836da74a 100644
--- a/tests/CLI/modules/dns_tests.py
+++ b/tests/CLI/modules/dns_tests.py
@@ -115,6 +115,8 @@ def test_parse_zone_file(self):
 dev.realtest.com    IN  TXT "This is just a test of the txt record"
     IN  AAAA  2001:db8:10::1
 spf  IN TXT "v=spf1 ip4:192.0.2.0/24 ip4:198.51.100.123 a"
+*.testing              86400    IN A     127.0.0.2
+*                      86400    IN A     127.0.0.3
 
 """
         expected = [{'data': 'ns1.softlayer.com.',
@@ -148,7 +150,15 @@ def test_parse_zone_file(self):
                     {'data': '"v=spf1 ip4:192.0.2.0/24 ip4:198.51.100.123 a"',
                      'record': 'spf',
                      'type': 'TXT',
-                     'ttl': None}]
+                     'ttl': None},
+                    {'data': '127.0.0.2',
+                     'record': '*.testing',
+                     'type': 'A',
+                     'ttl': '86400'},
+                    {'data': '127.0.0.3',
+                     'record': '*',
+                     'type': 'A',
+                     'ttl': '86400'}]
         zone, records, bad_lines = zone_import.parse_zone_details(zone_file)
         self.assertEqual(zone, 'realtest.com')
         self.assertEqual(records, expected)
Repository: softlayer/softlayer-python
Pull request #933 (2018-01-24 19:50:20)

Add fix for unsetting of values in edit SG rules
The SL API for editing security group rules allows you to unset string
values by passing in an empty string (''). The edit_securitygroup_rule()
function skipped over any values that were falsy (because if they
weren't set in the arguments, we don't want to change them).
Unfortunately, this caused values that were an empty string to also get
skipped over and not get unset in the API. So edit needs to check
explicitly for None (don't change) in order to get skipped over in
passing to the API.


Patch:
diff --git a/SoftLayer/managers/network.py b/SoftLayer/managers/network.py
index 2513a912..621cded9 100644
--- a/SoftLayer/managers/network.py
+++ b/SoftLayer/managers/network.py
@@ -318,19 +318,19 @@ def edit_securitygroup_rule(self, group_id, rule_id, remote_ip=None,
         """
         successful = False
         obj = {}
-        if remote_ip:
+        if remote_ip is not None:
             obj['remoteIp'] = remote_ip
-        if remote_group:
+        if remote_group is not None:
             obj['remoteGroupId'] = remote_group
-        if direction:
+        if direction is not None:
             obj['direction'] = direction
-        if ethertype:
+        if ethertype is not None:
             obj['ethertype'] = ethertype
-        if port_max:
+        if port_max is not None:
             obj['portRangeMax'] = port_max
-        if port_min:
+        if port_min is not None:
             obj['portRangeMin'] = port_min
-        if protocol:
+        if protocol is not None:
             obj['protocol'] = protocol
 
         if obj:


Test patch:
diff --git a/tests/managers/network_tests.py b/tests/managers/network_tests.py
index cf38e730..7a84beba 100644
--- a/tests/managers/network_tests.py
+++ b/tests/managers/network_tests.py
@@ -244,6 +244,23 @@ def test_edit_securitygroup_rule(self):
                                 args=([{'id': 500,
                                         'direction': 'ingress'}],))
 
+    def test_edit_securitygroup_rule_unset(self):
+        # Test calling edit rule with falsy values, which are used
+        # to unset those values in the API
+        result = self.network.edit_securitygroup_rule(100, 500,
+                                                      protocol='',
+                                                      port_min=-1,
+                                                      port_max=-1,
+                                                      ethertype='',
+                                                      remote_ip='')
+
+        self.assertTrue(result)
+        self.assert_called_with('SoftLayer_Network_SecurityGroup',
+                                'editRules', identifier=100,
+                                args=([{'id': 500, 'protocol': '',
+                                        'portRangeMin': -1, 'portRangeMax': -1,
+                                        'ethertype': '', 'remoteIp': ''}],))
+
     def test_get_rwhois(self):
         result = self.network.get_rwhois()
Repository: softlayer/softlayer-python
Pull request #963 (2018-04-13 17:18:08)

Presets filter
Added filter to check accountRestrictedActivePresets.


Patch:
diff --git a/SoftLayer/managers/ordering.py b/SoftLayer/managers/ordering.py
index 12744dce..4ac1b150 100644
--- a/SoftLayer/managers/ordering.py
+++ b/SoftLayer/managers/ordering.py
@@ -299,7 +299,18 @@ def list_presets(self, package_keyname, **kwargs):
     def get_preset_by_key(self, package_keyname, preset_keyname, mask=None):
         """Gets a single preset with the given key."""
         preset_operation = '_= %s' % preset_keyname
-        _filter = {'activePresets': {'keyName': {'operation': preset_operation}}}
+        _filter = {
+            'activePresets': {
+                'keyName': {
+                    'operation': preset_operation
+                }
+            },
+            'accountRestrictedActivePresets': {
+                'keyName': {
+                    'operation': preset_operation
+                }
+            }
+        }
 
         presets = self.list_presets(package_keyname, mask=mask, filter=_filter)
 


Test patch:
diff --git a/tests/managers/ordering_tests.py b/tests/managers/ordering_tests.py
index 276249cd..f3ccfaaa 100644
--- a/tests/managers/ordering_tests.py
+++ b/tests/managers/ordering_tests.py
@@ -201,7 +201,18 @@ def test_list_presets(self):
 
     def test_get_preset_by_key(self):
         keyname = 'PRESET_KEYNAME'
-        preset_filter = {'activePresets': {'keyName': {'operation': '_= %s' % keyname}}}
+        preset_filter = {
+            'activePresets': {
+                'keyName': {
+                    'operation': '_= %s' % keyname
+                }
+            },
+            'accountRestrictedActivePresets': {
+                'keyName': {
+                    'operation': '_= %s' % keyname
+                }
+            }
+        }
 
         with mock.patch.object(self.ordering, 'list_presets') as list_mock:
             list_mock.return_value = ['preset1']
@@ -213,8 +224,18 @@ def test_get_preset_by_key(self):
 
     def test_get_preset_by_key_preset_not_found(self):
         keyname = 'PRESET_KEYNAME'
-        preset_filter = {'activePresets': {'keyName': {'operation': '_= %s' % keyname}}}
-
+        preset_filter = {
+            'activePresets': {
+                'keyName': {
+                    'operation': '_= %s' % keyname
+                }
+            },
+            'accountRestrictedActivePresets': {
+                'keyName': {
+                    'operation': '_= %s' % keyname
+                }
+            }
+        }
         with mock.patch.object(self.ordering, 'list_presets') as list_mock:
             list_mock.return_value = []
Repository: api-platform/admin
Pull request #351 (2020-12-10 17:28:33)

[Hydra] Use JSON when `FormData` value is an array or an object
| Q             | A
| ------------- | ---
| Bug fix?      | yes
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tickets       | N/A
| License       | MIT
| Doc PR        | N/A


Patch:
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 45e196b..fe92e8d 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,5 +1,9 @@
 # Changelog
 
+## 2.5.4
+
+* Fix sent `FormData` when a value is an object or an array (use JSON)
+
 ## 2.5.3
 
 * Fix `ResourceGuesser` propTypes
diff --git a/src/hydra/dataProvider.js b/src/hydra/dataProvider.js
index d66ce76..4a71263 100644
--- a/src/hydra/dataProvider.js
+++ b/src/hydra/dataProvider.js
@@ -196,6 +196,9 @@ export default (
             Object.values(value).find((value) => value instanceof File),
           );
         }
+        if (isPlainObject(value) || Array.isArray(value)) {
+          return body.append(key, JSON.stringify(value));
+        }
         return body.append(key, value);
       });
 


Test patch:
diff --git a/src/hydra/dataProvider.test.js b/src/hydra/dataProvider.test.js
index 2ea891e..336c73a 100644
--- a/src/hydra/dataProvider.test.js
+++ b/src/hydra/dataProvider.test.js
@@ -197,6 +197,8 @@ describe('Transform a React Admin request to an Hydra request', () => {
             rawFile: file,
           },
           bar: 'baz',
+          array: ['foo', 'dummy'],
+          object: { foo: 'dummy' },
         },
       })
       .then(() => {
@@ -211,6 +213,8 @@ describe('Transform a React Admin request to an Hydra request', () => {
         expect(Array.from(options.body.entries())).toEqual([
           ['image', file],
           ['bar', 'baz'],
+          ['array', '["foo","dummy"]'],
+          ['object', '{"foo":"dummy"}'],
         ]);
       });
   });