Skip to content

Commit 5987443

Browse files
author
Dale Sikkema
committed
MAGETWO-38065: /magento_verion exposes too detailed version information
1 parent dcda524 commit 5987443

File tree

2 files changed

+38
-2
lines changed
  • app/code/Magento/Version/Controller/Index
  • dev/tests/integration/testsuite/Magento/Version/Controller/Index

2 files changed

+38
-2
lines changed

app/code/Magento/Version/Controller/Index/Index.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,15 +31,18 @@ public function __construct(Context $context, ProductMetadataInterface $productM
3131
}
3232

3333
/**
34-
* Sets the response body with ProductName/Version (Edition). E.g.: Magento/0.42.0-beta3 (Community)
34+
* Sets the response body to ProductName/Major.MinorVersion (Edition). E.g.: Magento/0.42 (Community). Omits patch
35+
* version from response
3536
*
3637
* @return void
3738
*/
3839
public function execute()
3940
{
41+
$fullVersion = explode('.', $this->productMetadata->getVersion());
42+
$majorMinorVersion = $fullVersion[0] . '.' . $fullVersion[1];
4043
$this->getResponse()->setBody(
4144
$this->productMetadata->getName() . '/' .
42-
$this->productMetadata->getVersion() . ' (' .
45+
$majorMinorVersion . ' (' .
4346
$this->productMetadata->getEdition() . ')'
4447
);
4548
}
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
<?php
2+
/***
3+
* Copyright © 2015 Magento. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
7+
class IndexTest extends \Magento\TestFramework\TestCase\AbstractController
8+
{
9+
public function testExecute()
10+
{
11+
// Execute controller to get version response
12+
$this->dispatch('magento_version');
13+
$body = $this->getResponse()->getBody();
14+
15+
$objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager();
16+
/** @var \Magento\Framework\App\ProductMetadataInterface $productMetadata */
17+
$productMetadata = $objectManager->get('Magento\Framework\App\ProductMetadataInterface');
18+
$name = $productMetadata->getName();
19+
$edition = $productMetadata->getEdition();
20+
21+
$fullVersion = $productMetadata->getVersion();
22+
$versionParts = explode('.', $fullVersion);
23+
$majorMinor = $versionParts[0] . '.' . $versionParts[1];
24+
25+
// Response must contain Major.Minor version, product name, and edition
26+
$this->assertContains($majorMinor, $body);
27+
$this->assertContains($name, $body);
28+
$this->assertContains($edition, $body);
29+
30+
// Response must not contain full version including patch version
31+
$this->assertNotContains($fullVersion, $body);
32+
}
33+
}

0 commit comments

Comments
 (0)