 .../config/optional/rest.resource.entity__node.yml |  31 +++----
 core/modules/rest/config/schema/rest.schema.yml    |  23 ++++-
 core/modules/rest/rest.install                     |  37 +++++++-
 .../modules/rest/src/Entity/ConfigDependencies.php |  97 +++++++++++++++++----
 .../modules/rest/src/Entity/RestResourceConfig.php |   8 +-
 ...larityRestResourcesConfigEntitiesUpdateTest.php |  70 +++++++++++++++
 .../update/drupal-8.rest-rest_update_8202.php      | Bin 0 -> 4293 bytes
 .../rest.resource.entity__comment_2721595.yml      |  30 +++++++
 .../update/rest.resource.entity__node_2721595.yml  |  29 ++++++
 .../update/rest.resource.entity__user_2721595.yml  |  30 +++++++
 .../src/Tests/System/ResponseGeneratorTest.php     |  13 ++-
 11 files changed, 319 insertions(+), 49 deletions(-)

diff --git a/core/modules/rest/config/optional/rest.resource.entity__node.yml b/core/modules/rest/config/optional/rest.resource.entity__node.yml
index c7da93f..a73d44d 100644
--- a/core/modules/rest/config/optional/rest.resource.entity__node.yml
+++ b/core/modules/rest/config/optional/rest.resource.entity__node.yml
@@ -1,27 +1,16 @@
 id: entity__node
 plugin_id: 'entity:node'
-granularity: method
+granularity: resource
 configuration:
-  GET:
-    supported_formats:
-      - hal_json
-    supported_auth:
-      - basic_auth
-  POST:
-    supported_formats:
-      - hal_json
-    supported_auth:
-      - basic_auth
-  PATCH:
-    supported_formats:
-      - hal_json
-    supported_auth:
-      - basic_auth
-  DELETE:
-    supported_formats:
-      - hal_json
-    supported_auth:
-      - basic_auth
+  methods:
+    - GET
+    - POST
+    - PATCH
+    - DELETE
+  formats:
+    - hal_json
+  authentication:
+    - basic_auth
 dependencies:
   module:
     - node
diff --git a/core/modules/rest/config/schema/rest.schema.yml b/core/modules/rest/config/schema/rest.schema.yml
index 41bc2bf..080c9c5 100644
--- a/core/modules/rest/config/schema/rest.schema.yml
+++ b/core/modules/rest/config/schema/rest.schema.yml
@@ -8,7 +8,6 @@ rest.settings:
       label: 'Domain of the relation'
 
 # Method-level granularity of REST resource configuration.
-# @todo Add resource-level granularity in https://www.drupal.org/node/2721595.
 rest_resource.method:
   type: mapping
   mapping:
@@ -25,6 +24,28 @@ rest_resource.method:
       type: rest_request
       label: 'DELETE method settings'
 
+rest_resource.resource:
+  type: mapping
+  mapping:
+    methods:
+      type: sequence
+      label: 'Supported methods'
+      sequence:
+        type: string
+        label: 'HTTP method'
+    formats:
+      type: sequence
+      label: 'Supported formats'
+      sequence:
+        type: string
+        label: 'Format'
+    authentication:
+      type: sequence
+      label: 'Supported authentication providers'
+      sequence:
+        type: string
+        label: 'Authentication provider'
+
 rest_request:
   type: mapping
   mapping:
diff --git a/core/modules/rest/rest.install b/core/modules/rest/rest.install
index c40d8cf..f0ec213 100644
--- a/core/modules/rest/rest.install
+++ b/core/modules/rest/rest.install
@@ -32,8 +32,6 @@ function rest_requirements($phase) {
 
 /**
  * Install the REST config entity type and convert old settings-based config.
- *
- * @todo Automatically upgrade those REST resource config entities that have the same formats/auth mechanisms for all methods to "granular: resource" in https://www.drupal.org/node/2721595.
  */
 function rest_update_8201() {
   \Drupal::entityDefinitionUpdateManager()->installEntityType(\Drupal::entityTypeManager()->getDefinition('rest_resource_config'));
@@ -51,5 +49,40 @@ function rest_update_8201() {
 }
 
 /**
+ * Simplify method-granularity REST resources to resource-granularity.
+ */
+function rest_update_8202() {
+  $config_factory = \Drupal::configFactory();
+
+  foreach ($config_factory->listAll('rest.resource.') as $resource_config_name) {
+    $resource_config_entity = $config_factory->getEditable($resource_config_name);
+
+    if ($resource_config_entity->get('granularity') === 'method') {
+      $configuration = $resource_config_entity->get('configuration');
+
+      $format_and_auth_configuration = [];
+      foreach (array_keys($configuration) as $method) {
+        $format_and_auth_configuration['format'][$method] = implode(',', $configuration[$method]['supported_formats']);
+        $format_and_auth_configuration['auth'][$method] = implode(',', $configuration[$method]['supported_auth']);
+      }
+
+      // If each method has the same formats and the same authentication
+      // providers configured, convert it to 'granularity: resource', which has
+      // a simpler/less verbose configuration.
+      if (count(array_unique($format_and_auth_configuration['format'])) === 1 && count(array_unique($format_and_auth_configuration['auth'])) === 1) {
+        $resource_config_entity->set('configuration', [
+          'methods' => array_keys($configuration),
+          'formats' => $configuration['GET']['supported_formats'],
+          'authentication' => $configuration['GET']['supported_auth']
+        ]);
+        $resource_config_entity->set('granularity', 'resource');
+        $resource_config_entity->save(TRUE);
+      }
+    }
+  }
+}
+
+
+/**
  * @} End of "defgroup updates-8.1.x-to-8.2.x".
  */
diff --git a/core/modules/rest/src/Entity/ConfigDependencies.php b/core/modules/rest/src/Entity/ConfigDependencies.php
index 12cc380..5e46fe1 100644
--- a/core/modules/rest/src/Entity/ConfigDependencies.php
+++ b/core/modules/rest/src/Entity/ConfigDependencies.php
@@ -50,30 +50,21 @@ public function __construct(array $format_providers, array $auth_providers) {
    */
   public function calculateDependencies(RestResourceConfigInterface $rest_config) {
     $granularity = $rest_config->get('granularity');
+
+    // Dependency calculation is the same for either granularity, the most
+    // notable difference is that for the 'resource' granularity, the same
+    // authentication providers and formats are supported for every method.
     if ($granularity === 'method') {
-      return $this->calculateDependenciesForMethodGranularity($rest_config);
+      $methods = array_keys($rest_config->get('configuration'));
     }
     else {
-      // @todo Add resource-level granularity support in https://www.drupal.org/node/2721595.
+      $methods = ['GET'];
     }
-  }
 
-  /**
-   * Calculates dependencies of a specific rest resource configuration.
-   *
-   * @param \Drupal\rest\RestResourceConfigInterface $rest_config
-   *   The rest configuration.
-   *
-   * @return string[][]
-   *   Dependencies keyed by dependency type.
-   *
-   * @see \Drupal\Core\Config\Entity\ConfigEntityInterface::calculateDependencies()
-   */
-  protected function calculateDependenciesForMethodGranularity(RestResourceConfigInterface $rest_config) {
     // The dependency lists for authentication providers and formats
     // generated on container build.
     $dependencies = [];
-    foreach (array_keys($rest_config->get('configuration')) as $request_method) {
+    foreach ($methods as $request_method) {
       // 'granularity' is not a request method
       if ($request_method === 'granularity') {
         continue;
@@ -122,7 +113,7 @@ public function onDependencyRemoval(RestResourceConfigInterface $rest_config, ar
       return $this->onDependencyRemovalForMethodGranularity($rest_config, $dependencies);
     }
     else {
-      // @todo Add resource-level granularity support in https://www.drupal.org/node/2721595.
+      return $this->onDependencyRemovalForResourceGranularity($rest_config, $dependencies);
     }
   }
 
@@ -212,4 +203,76 @@ public function onDependencyRemovalForMethodGranularity(RestResourceConfigInterf
     return $changed;
   }
 
+  /**
+   * Informs the entity that entities it depends on will be deleted.
+   *
+   * @param \Drupal\rest\RestResourceConfigInterface $rest_config
+   *   The rest configuration.
+   * @param array $dependencies
+   *   An array of dependencies that will be deleted keyed by dependency type.
+   *   Dependency types are, for example, entity, module and theme.
+   *
+   * @return bool
+   *   TRUE if the entity has been changed as a result, FALSE if not.
+   */
+  public function onDependencyRemovalForResourceGranularity(RestResourceConfigInterface $rest_config, array $dependencies) {
+    $changed = FALSE;
+    // Only module-related dependencies can be fixed. All other types of
+    // dependencies cannot, because they were not generated based on supported
+    // authentication providers or formats.
+    if (isset($dependencies['module'])) {
+      // Try to fix dependencies.
+      $removed_auth = [];
+      $removed_formats = [];
+      foreach ($dependencies['module'] as $dep_module) {
+        // Check if the removed dependency module contained an authentication
+        // provider.
+        foreach ($this->authProviders as $auth => $auth_module) {
+          if ($dep_module != $auth_module) {
+            continue;
+          }
+          $removed_auth[] = $auth;
+        }
+        // Check if the removed dependency module contained a format.
+        foreach ($this->formatProviders as $format => $format_module) {
+          if ($dep_module != $format_module) {
+            continue;
+          }
+          $removed_formats[] = $format;
+        }
+      }
+      $configuration = $rest_config->get('configuration');
+      if (!empty($removed_auth) || !empty($removed_formats)) {
+        foreach ($removed_formats as $format) {
+          if (in_array($format, $configuration['formats'])) {
+            $configuration = array_filter($configuration['formats'], function ($val) use ($format) {
+              return $val !== $format;
+            });
+          }
+        }
+        foreach ($removed_auth as $auth) {
+          if (in_array($auth, $configuration['authentication'])) {
+            $configuration = array_filter($configuration['authentication'], function ($val) use ($auth) {
+              return $val !== $auth;
+            });
+          }
+        }
+        // Only mark the dependencies problems as fixed if there is still >=1
+        // format available and >=1 authentication provider available.
+        if (!empty($configuration['formats']) && !empty($configuration['authentication'])) {
+          $changed = TRUE;
+        }
+      }
+      else {
+        // Dependencies were removed, but they did not affect the formats or
+        // authentication providers used by this entity.
+        $changed = TRUE;
+      }
+    }
+    // If the dependency problems are not marked as fixed at this point they
+    // should be related to the resource plugin and the config entity should
+    // be deleted.
+    return $changed;
+  }
+
 }
diff --git a/core/modules/rest/src/Entity/RestResourceConfig.php b/core/modules/rest/src/Entity/RestResourceConfig.php
index e59c38a..c68e0af 100644
--- a/core/modules/rest/src/Entity/RestResourceConfig.php
+++ b/core/modules/rest/src/Entity/RestResourceConfig.php
@@ -46,7 +46,7 @@ class RestResourceConfig extends ConfigEntityBase implements RestResourceConfigI
   /**
    * The REST resource configuration granularity.
    *
-   * @todo Currently only 'method', but https://www.drupal.org/node/2721595 will add 'resource'
+   * Currently either 'method' or 'resource'.
    *
    * @var string
    */
@@ -121,7 +121,7 @@ public function getMethods() {
       return $this->getMethodsForMethodGranularity();
     }
     else {
-      // @todo Add resource-level granularity support in https://www.drupal.org/node/2721595.
+      return $this->configuration['methods'];
     }
   }
 
@@ -144,7 +144,7 @@ public function getAuthenticationProviders($method) {
       return $this->getAuthenticationProvidersForMethodGranularity($method);
     }
     else {
-      // @todo Add resource-level granularity support in https://www.drupal.org/node/2721595.
+      return $this->configuration['authentication'];
     }
   }
 
@@ -173,7 +173,7 @@ public function getFormats($method) {
       return $this->getFormatsForMethodGranularity($method);
     }
     else {
-      // @todo Add resource-level granularity support in https://www.drupal.org/node/2721595.
+      return $this->configuration['formats'];
     }
   }
 
diff --git a/core/modules/rest/src/Tests/Update/ResourceGranularityRestResourcesConfigEntitiesUpdateTest.php b/core/modules/rest/src/Tests/Update/ResourceGranularityRestResourcesConfigEntitiesUpdateTest.php
new file mode 100644
index 0000000..41e90be
--- /dev/null
+++ b/core/modules/rest/src/Tests/Update/ResourceGranularityRestResourcesConfigEntitiesUpdateTest.php
@@ -0,0 +1,70 @@
+<?php
+
+namespace Drupal\rest\Tests\Update;
+
+use Drupal\system\Tests\Update\UpdatePathTestBase;
+
+/**
+ * Tests rest_resource_config entities are simplified when possible.
+ *
+ * @see https://www.drupal.org/node/2721595
+ *
+ * @group rest
+ */
+class ResourceGranularityRestResourcesConfigEntitiesUpdateTest extends UpdatePathTestBase {
+
+  /**
+   * {@inheritdoc}
+   */
+  protected static $modules = ['rest', 'serialization'];
+
+  /**
+   * {@inheritdoc}
+   */
+  public function setDatabaseDumpFiles() {
+    $this->databaseDumpFiles = [
+      __DIR__ . '/../../../../system/tests/fixtures/update/drupal-8.bare.standard.php.gz',
+      __DIR__ . '/../../../../rest/tests/fixtures/update/drupal-8.rest-rest_update_8202.php',
+    ];
+  }
+
+  /**
+   * Tests rest_update_8202().
+   */
+  public function testResourcesConvertedToConfigEntities() {
+    /** @var \Drupal\Core\Entity\EntityStorageInterface $resource_config_storage */
+    $resource_config_storage = $this->container->get('entity_type.manager')->getStorage('rest_resource_config');
+
+    // Make sure we have the expected values before the update.
+    $resource_config_entities = $resource_config_storage->loadMultiple();
+    $this->assertIdentical(['entity__comment', 'entity__node', 'entity__user'], array_keys($resource_config_entities));
+    $this->assertIdentical('method', $resource_config_entities['entity__node']->get('granularity'));
+    $this->assertIdentical('method', $resource_config_entities['entity__comment']->get('granularity'));
+    $this->assertIdentical('method', $resource_config_entities['entity__user']->get('granularity'));
+
+    // Read the existing 'entity:comment' and 'entity:user' resource
+    // configuration so we can verify it after the update.
+    $comment_resource_configuration = $resource_config_entities['entity__comment']->get('configuration');
+    $user_resource_configuration = $resource_config_entities['entity__user']->get('configuration');
+
+    $this->runUpdates();
+
+    // Make sure we have the expected values after the update.
+    $resource_config_entities = $resource_config_storage->loadMultiple();
+    $this->assertIdentical(['entity__comment', 'entity__node', 'entity__user'], array_keys($resource_config_entities));
+    // 'entity:node' should be updated.
+    $this->assertIdentical('resource', $resource_config_entities['entity__node']->get('granularity'));
+    $this->assertidentical($resource_config_entities['entity__node']->get('configuration'), [
+      'methods' => ['GET', 'POST', 'PATCH', 'DELETE'],
+      'formats' => ['hal_json'],
+      'authentication' => ['basic_auth'],
+    ]);
+    // 'entity:comment' should be unchanged.
+    $this->assertIdentical('method', $resource_config_entities['entity__comment']->get('granularity'));
+    $this->assertIdentical($comment_resource_configuration, $resource_config_entities['entity__comment']->get('configuration'));
+    // 'entity:user' should be unchanged.
+    $this->assertIdentical('method', $resource_config_entities['entity__user']->get('granularity'));
+    $this->assertIdentical($user_resource_configuration, $resource_config_entities['entity__user']->get('configuration'));
+  }
+
+}
diff --git a/core/modules/rest/tests/fixtures/update/drupal-8.rest-rest_update_8202.php b/core/modules/rest/tests/fixtures/update/drupal-8.rest-rest_update_8202.php
new file mode 100644
index 0000000000000000000000000000000000000000..868db72091a2055e8cd23050a09d9d37ce817fde
GIT binary patch
literal 4293
zcmcInZExE)5bkIH3PLC#Cy1TcN#Eqv+mN)_fUO&v?!%B20wd9m5K1&CDotASzwbF7
zrAVm*Y*_Q5sZ1X4<+<mM#~*&&Ty93A{oUP>*cCsm3a#kl*i=pyRV{Mq<b|x2ka=FX
z!eGf6k=te?_2lLBLRvMgovd<c^C?tK*Pq48Sm9LdifS#~rPtSN)>h_9Y^1vsW+g1P
z(`EzhDt$RWn2&d+FuOk*H86GJwVxlGa$_o0x${$H3#p6Gk{meyTb6n;6twF6BskiA
zEJmZJnW-w3(JAp-v=T|ORt^D%o$(GN_xHuAa^$V3vrAP<ajk5PbJM<($r6w#>&Eew
zx=pX8ZdAN85@NDk6-wvz_zXXUh%=)#n~lZmrHJd>+NpBNn&Ukds${8no4{ySS*br&
zBtT}i@H-#BgBf^!hvL7pr*2f%IMqV*mrt0;43e&HoT>ss-FFR`d!SF2wIU$KK%`m~
z>mgX};+{B*iDq#K60%G+I@STXC*p9tx9>5;&d{SE*E!D_QZBoEOKGBLo(^1YD61YD
zHSX;U<<8>L<c(JG$FtaH>?4Bp8R~26OSMWpZR4IeA_(N0EV&4_BNXW5!68bt3Wr`2
zpB@XkVG&K1rLt@FE&Y2b8Kw-?Te#b4u2x0G?PH1(auR9HA5N$54)|jlo2eAa!JR3q
zO5N>dd(rhO=a1xQo<v<6L3cRzI?msCcfv3J@d5gx<nUGUrA}tgljzCr6E>J`EWEyn
z7IpG6iCS;y=j@pmLl~~e(oCXZM2m~$fVPhOmNw?9*`(+ab+nMlEcsISZR|Epkw=TK
z_l>EWjj@h|k6K}bK%zx5gW^|7w9(DFs8U{=ld)M6p{-VpmKG?J=pij1CJ~3wSWi7~
zZVq9@<`bAR9B(?C2gw)mh~u)V%9Xu~i_FhpAE!6e6w%8ncW;}+4k>EGeomN%D0&|r
z&Fg}C2cdb8MD!n^zi6sl1Ilg<l3G^l%;bLc-cQOFh$S2C(!SV3>mB$tFuuzJ2TiEL
zM>w;Me6&Ys69m>=7r=*>poXOB6TT61w5*ZwIyrpN@sA{0;=RW={&`+=4!mZjov{V-
zEA=red3R^?68EbH^hA$2fr<k%%M{x>LIi!T2a@xDKYKCQa@OcySP$8Rf3-7Ku068%
zRj_ZZ*MTj*c23(v#1|%o%uCP`)F_L(P3jyz`E_E8_18W9@qv4QNPr0yPNf4TGu(ks
zRPuKi>!P~yNCeU%5-8I0LTQjv>kFA(c~p@ST=c)u##?L3KYjVoPACPYTRJe}K?h}_
zF>ISvwD7C!a9H)`!UoEX#4#kLn3agYBtK^@Rx#64YU2I<8T;Ms_l{BlL*q9m*aL@(
zuQg3OWQyAkvoAP>?uXxfMw~i}S?ohNNHbLXO-g>37R?GhkeJ0Ot^EOy6)NKWo6`?n
z_Hg@CJN5{3h|;c`5-9eQf>VgVZ2ZJXw54PbW%}8w;S}{Q(iOTuXhED!G(0PHf0x?~
z?`Ec{e8U_xuf`TV7EmG>o3%BF5kI$dM=Y{pFN9tK#zc$n3L{zNGU|FVto{f5aE17y
z1^N!Ni;o0Ya*+$F5D`Kom;?FzRGKzL>d6TNTuV;wIGHI+Q>D1)6q-J+T8CUJC}&m$
zEgCh<?Vhe;vfj^hpx&K~lWV`<U3!NIlSz|MFNC?l#h#LWz7aVKkOlwn`WV>ZnrL4k
zL<=SrH*JuOIolH3UoP(!U)wo%IBnneVK7{T`MfvC_;H;3!~>&DZwBke&ik`d`*vU~
zhO_Xu4~PCMA$<Eeu(O0G%L(6pp(F#d@Q}iT#7{#HK1jBsGHo-{!jV?Ed0W{nQz*T}
zk|bAjL67O_n1Ve_5+rY&rYFC?Pg5}!@jhjKyZ&_kVm^EJ>e=+R)bY;FPCvlo2A5Ph
zjBihTD)5M`j1x7UQ1sd?rK<(rc<BCJpQ^tn4pb<}|6@WCO#ELoWP>*>ZtBcWevb+Y
Sp6d275h48#!ZBI)>g*rm>s&Yh

literal 0
HcmV?d00001

diff --git a/core/modules/rest/tests/fixtures/update/rest.resource.entity__comment_2721595.yml b/core/modules/rest/tests/fixtures/update/rest.resource.entity__comment_2721595.yml
new file mode 100644
index 0000000..7508bd6
--- /dev/null
+++ b/core/modules/rest/tests/fixtures/update/rest.resource.entity__comment_2721595.yml
@@ -0,0 +1,30 @@
+id: entity__comment
+plugin_id: 'entity:comment'
+granularity: method
+configuration:
+  GET:
+    supported_formats:
+      - hal_json
+      - xml
+    supported_auth:
+      - basic_auth
+  POST:
+    supported_formats:
+      - hal_json
+    supported_auth:
+      - basic_auth
+  PATCH:
+    supported_formats:
+      - hal_json
+    supported_auth:
+      - basic_auth
+  DELETE:
+    supported_formats:
+      - hal_json
+    supported_auth:
+      - basic_auth
+dependencies:
+  module:
+    - node
+    - basic_auth
+    - hal
diff --git a/core/modules/rest/tests/fixtures/update/rest.resource.entity__node_2721595.yml b/core/modules/rest/tests/fixtures/update/rest.resource.entity__node_2721595.yml
new file mode 100644
index 0000000..c7da93f
--- /dev/null
+++ b/core/modules/rest/tests/fixtures/update/rest.resource.entity__node_2721595.yml
@@ -0,0 +1,29 @@
+id: entity__node
+plugin_id: 'entity:node'
+granularity: method
+configuration:
+  GET:
+    supported_formats:
+      - hal_json
+    supported_auth:
+      - basic_auth
+  POST:
+    supported_formats:
+      - hal_json
+    supported_auth:
+      - basic_auth
+  PATCH:
+    supported_formats:
+      - hal_json
+    supported_auth:
+      - basic_auth
+  DELETE:
+    supported_formats:
+      - hal_json
+    supported_auth:
+      - basic_auth
+dependencies:
+  module:
+    - node
+    - basic_auth
+    - hal
diff --git a/core/modules/rest/tests/fixtures/update/rest.resource.entity__user_2721595.yml b/core/modules/rest/tests/fixtures/update/rest.resource.entity__user_2721595.yml
new file mode 100644
index 0000000..7715178
--- /dev/null
+++ b/core/modules/rest/tests/fixtures/update/rest.resource.entity__user_2721595.yml
@@ -0,0 +1,30 @@
+id: entity__user
+plugin_id: 'entity:user'
+granularity: method
+configuration:
+  GET:
+    supported_formats:
+      - hal_json
+    supported_auth:
+      - basic_auth
+      - oauth
+  POST:
+    supported_formats:
+      - hal_json
+    supported_auth:
+      - basic_auth
+  PATCH:
+    supported_formats:
+      - hal_json
+    supported_auth:
+      - basic_auth
+  DELETE:
+    supported_formats:
+      - hal_json
+    supported_auth:
+      - basic_auth
+dependencies:
+  module:
+    - node
+    - basic_auth
+    - hal
diff --git a/core/modules/system/src/Tests/System/ResponseGeneratorTest.php b/core/modules/system/src/Tests/System/ResponseGeneratorTest.php
index d0d22a2..e210a5d 100644
--- a/core/modules/system/src/Tests/System/ResponseGeneratorTest.php
+++ b/core/modules/system/src/Tests/System/ResponseGeneratorTest.php
@@ -53,13 +53,18 @@ function testGeneratorHeaderAdded() {
     $this->assertEqual('text/html; charset=UTF-8', $this->drupalGetHeader('Content-Type'));
     $this->assertEqual($expectedGeneratorHeader, $this->drupalGetHeader('X-Generator'));
 
-    // Enable rest API for nodes
-    $this->enableService('entity:node', 'GET', 'json');
+    // Enable cookie-based authentication for the entity:node REST resource.
+    /** @var \Drupal\rest\RestResourceConfigInterface $resource_config */
+    $resource_config = $this->resourceConfigStorage->load('entity__node');
+    $configuration = $resource_config->get('configuration');
+    $configuration['authentication'][] = 'cookie';
+    $resource_config->set('configuration', $configuration)->save();
+    $this->rebuildCache();
 
     // Tests to see if this also works for a non-html request
-    $this->httpRequest($node->urlInfo()->setOption('query', ['_format' => 'json']), 'GET');
+    $this->httpRequest($node->urlInfo()->setOption('query', ['_format' => 'hal_json']), 'GET');
     $this->assertResponse(200);
-    $this->assertEqual('application/json', $this->drupalGetHeader('Content-Type'));
+    $this->assertEqual('application/hal+json', $this->drupalGetHeader('Content-Type'));
     $this->assertEqual($expectedGeneratorHeader, $this->drupalGetHeader('X-Generator'));
 
   }
