Skip to content

Commit

Permalink
Merge pull request #99 from magento-api/pull-request
Browse files Browse the repository at this point in the history
[API-Ext-Ogre] P0-P1 Bugs
  • Loading branch information
Oleksii Korshenko authored Jun 12, 2016
2 parents 1ea57c2 + 76f3706 commit e7d6678
Show file tree
Hide file tree
Showing 21 changed files with 499 additions and 106 deletions.
1 change: 1 addition & 0 deletions app/code/Magento/Backend/i18n/en_US.csv
Original file line number Diff line number Diff line change
Expand Up @@ -456,3 +456,4 @@ Pagination,Pagination
"Anchor Text for Next","Anchor Text for Next"
"Alternative text for the next pages link in the pagination menu. If empty, default arrow image is used.","Alternative text for the next pages link in the pagination menu. If empty, default arrow image is used."
"Theme Name","Theme Name"
"Deployment config file %1 is not writable.","Deployment config file %1 is not writable."
4 changes: 2 additions & 2 deletions app/code/Magento/PageCache/etc/varnish3.vcl
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@ sub vcl_recv {
return (pass);
}

# Bypass shopping cart and checkout requests
if (req.url ~ "/checkout") {
# Bypass shopping cart, checkout and search requests
if (req.url ~ "/checkout" || req.url ~ "/catalogsearch") {
return (pass);
}

Expand Down
14 changes: 12 additions & 2 deletions app/code/Magento/PageCache/etc/varnish4.vcl
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ sub vcl_recv {
return (pass);
}

# Bypass shopping cart and checkout requests
if (req.url ~ "/checkout") {
# Bypass shopping cart, checkout and search requests
if (req.url ~ "/checkout" || req.url ~ "/catalogsearch") {
return (pass);
}

Expand Down Expand Up @@ -136,6 +136,16 @@ sub vcl_backend_response {
set beresp.grace = 1m;
}
}

# If page is not cacheable then bypass varnish for 2 minutes as Hit-For-Pass
if (beresp.ttl <= 0s ||
beresp.http.Surrogate-control ~ "no-store" ||
(!beresp.http.Surrogate-Control && beresp.http.Vary == "*")) {
# Mark as Hit-For-Pass for the next 2 minutes
set beresp.ttl = 120s;
set beresp.uncacheable = true;
}
return (deliver);
}

sub vcl_deliver {
Expand Down
4 changes: 2 additions & 2 deletions app/code/Magento/Translation/Model/Inline/Parser.php
Original file line number Diff line number Diff line change
Expand Up @@ -436,12 +436,12 @@ private function _prepareTagAttributesForContent(&$content)
$tagHtml = str_replace($matches[0], '', $tagHtml);
$trAttr = ' ' . $this->_getHtmlAttribute(
self::DATA_TRANSLATE,
'[' . htmlspecialchars($matches[1]) . ',' . join(',', $trArr) . ']'
'[' . htmlspecialchars($matches[1]) . ',' . str_replace("\"", "'", join(',', $trArr)) . ']'
);
} else {
$trAttr = ' ' . $this->_getHtmlAttribute(
self::DATA_TRANSLATE,
'[' . join(',', $trArr) . ']'
'[' . str_replace("\"", "'", join(',', $trArr)) . ']'
);
}
$trAttr = $this->_addTranslateAttribute($trAttr);
Expand Down
112 changes: 112 additions & 0 deletions app/code/Magento/Translation/Test/Unit/Model/Inline/ParserTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
<?php
/**
* Copyright © 2016 Magento. All rights reserved.
* See COPYING.txt for license details.
*/
namespace Magento\Translation\Test\Unit\Model\Inline;

/**
* Class ParserTest to test \Magento\Translation\Model\Inline\Parser
*/
class ParserTest extends \PHPUnit_Framework_TestCase
{
/**
* @var \Magento\Translation\Model\Inline\Parser|\PHPUnit_Framework_MockObject_MockObject
*/
private $model;

/**
* @var \Magento\Translation\Model\ResourceModel\StringUtilsFactory|\PHPUnit_Framework_MockObject_MockObject
*/
private $resourceMock;

/**
* @var \Magento\Store\Model\StoreManagerInterface|\PHPUnit_Framework_MockObject_MockObject
*/
private $storeManagerMock;

/**
* @var \Zend_Filter_Interface|\PHPUnit_Framework_MockObject_MockObject
*/
private $inputFilterMock;

/**
* @var \Magento\Framework\App\State|\PHPUnit_Framework_MockObject_MockObject
*/
private $appStateMock;

/**
* @var \Magento\Framework\App\Cache\TypeListInterface|\PHPUnit_Framework_MockObject_MockObject
*/
private $appCacheMock;

/**
* @var \Magento\Framework\Translate\InlineInterface|\PHPUnit_Framework_MockObject_MockObject
*/
private $translateInlineMock;

protected function setUp()
{
$this->resourceMock = $this->getMockBuilder('Magento\Translation\Model\ResourceModel\StringUtilsFactory')
->disableOriginalConstructor()
->setMethods([])
->getMock();

$this->storeManagerMock = $this->getMockBuilder('Magento\Store\Model\StoreManagerInterface')
->disableOriginalConstructor()
->setMethods([])
->getMock();

$this->inputFilterMock = $this->getMockBuilder('Zend_Filter_Interface')
->disableOriginalConstructor()
->setMethods([])
->getMock();

$this->appStateMock = $this->getMockBuilder('Magento\Framework\App\State')
->disableOriginalConstructor()
->setMethods([])
->getMock();

$this->appCacheMock = $this->getMockBuilder('Magento\Framework\App\Cache\TypeListInterface')
->disableOriginalConstructor()
->setMethods([])
->getMock();

$this->translateInlineMock= $this->getMockBuilder('Magento\Framework\Translate\InlineInterface')
->disableOriginalConstructor()
->setMethods([])
->getMock();

$objectManagerHelper = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
$this->model = $objectManagerHelper->getObject(
'Magento\Translation\Model\Inline\Parser',
[
"_resourceFactory" => $this->resourceMock,
"_storeManager" => $this->storeManagerMock,
"_inputFilter" => $this->inputFilterMock,
"_appState" => $this->appStateMock,
"_appCache" => $this->appCacheMock,
"_translateInline" => $this->translateInlineMock
]
);
}

public function testProcessResponseBodyStringProcessingAttributesCorrectly()
{
$testContent = file_get_contents(__DIR__ . '/_files/datatranslate_fixture.html');
$processedAttributes = [
"data-translate=\"[{'shown':'* Required Fields','translated':'* Required Fields',"
. "'original':'* Required Fields','location':'Tag attribute (ALT, TITLE, etc.)'}]\"",
"data-translate=\"[{'shown':'Email','translated':'Email','original':'Email',"
. "'location':'Tag attribute (ALT, TITLE, etc.)'}]\"",
"data-translate=\"[{'shown':'Password','translated':'Password','original':'Password',"
. "'location':'Tag attribute (ALT, TITLE, etc.)'}]\""
];
$this->translateInlineMock->expects($this->any())->method('getAdditionalHtmlAttribute')->willReturn(null);

$processedContent = $this->model->processResponseBodyString($testContent);
foreach ($processedAttributes as $attribute) {
$this->assertContains($attribute, $processedContent, "data-translate attribute not processed correctly");
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<div class="login-container">
<div class="block block-customer-login">
<div class="block-content" aria-labelledby="block-customer-login-heading">
<form class="form form-login"
action=""
method="post"
id="login-form"
data-mage-init='{"validation":{}}'>
<input name="form_key" type="hidden" value="" />
<fieldset class="fieldset login" data-hasrequired="{{{* Required Fields}}{{* Required Fields}}{{* Required Fields}}{{theme3}}}">
<div class="field note">{{{If you have an account, sign in with your email address.}}{{If you have an account, sign in with your email address.}}{{If you have an account, sign in with your email address.}}{{theme3}}}</div>
<div class="field email required">
<label class="label" for="email"><span>{{{Email}}{{Email}}{{Email}}{{theme3}}}</span></label>
<div class="control">
<input name="login[username]" value="" autocomplete="off" id="email" type="email" class="input-text" title="{{{Email}}{{Email}}{{Email}}{{theme3}}}" data-validate="{required:true, 'validate-email':true}">
</div>
</div>
<div class="field password required">
<label for="pass" class="label"><span>{{{Password}}{{Password}}{{Password}}{{theme3}}}</span></label>
<div class="control">
<input name="login[password]" type="password" autocomplete="off" class="input-text" id="pass" title="{{{Password}}{{Password}}{{Password}}{{theme3}}}" data-validate="{required:true}">
</div>
</div>
<div class="actions-toolbar">
<div class="primary"><button type="submit" class="action login primary" name="send" id="send2"><span>{{{Sign In}}{{Sign In}}{{Sign In}}{{theme3}}}</span></button></div>
<div class="secondary"><a class="action remind" href=""><span>{{{Forgot Your Password?}}{{Forgot Your Password?}}{{Forgot Your Password?}}{{theme3}}}</span></a></div>
</div>
</fieldset>
</form>
</div>
</div>
</div>
29 changes: 20 additions & 9 deletions app/code/Magento/User/Model/ResourceModel/User.php
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ protected function _afterSave(\Magento\Framework\Model\AbstractModel $user)
*/
public function _clearUserRoles(ModelUser $user)
{
$conditions = ['user_id = ?' => (int)$user->getId()];
$conditions = ['user_id = ?' => (int)$user->getId(), 'user_type = ?' => UserContextInterface::USER_TYPE_ADMIN];
$this->getConnection()->delete($this->getTable('authorization_role'), $conditions);
}

Expand Down Expand Up @@ -255,13 +255,13 @@ public function delete(\Magento\Framework\Model\AbstractModel $user)
$uid = $user->getId();
$connection->beginTransaction();
try {
$conditions = ['user_id = ?' => $uid];

$connection->delete($this->getMainTable(), $conditions);
$connection->delete($this->getTable('authorization_role'), $conditions);
$connection->delete($this->getMainTable(), ['user_id = ?' => $uid]);
$connection->delete(
$this->getTable('authorization_role'),
['user_id = ?' => $uid, 'user_type = ?' => UserContextInterface::USER_TYPE_ADMIN]
);
} catch (\Magento\Framework\Exception\LocalizedException $e) {
throw $e;
return false;
} catch (\Exception $e) {
$connection->rollBack();
return false;
Expand Down Expand Up @@ -329,7 +329,11 @@ public function deleteFromRole(\Magento\Framework\Model\AbstractModel $user)

$dbh = $this->getConnection();

$condition = ['user_id = ?' => (int)$user->getId(), 'parent_id = ?' => (int)$user->getRoleId()];
$condition = [
'user_id = ?' => (int)$user->getId(),
'parent_id = ?' => (int)$user->getRoleId(),
'user_type = ?' => UserContextInterface::USER_TYPE_ADMIN
];

$dbh->delete($this->getTable('authorization_role'), $condition);
return $this;
Expand All @@ -348,9 +352,16 @@ public function roleUserExists(\Magento\Framework\Model\AbstractModel $user)

$dbh = $this->getConnection();

$binds = ['parent_id' => $user->getRoleId(), 'user_id' => $user->getUserId()];
$binds = [
'parent_id' => $user->getRoleId(),
'user_id' => $user->getUserId(),
'user_type' => UserContextInterface::USER_TYPE_ADMIN
];

$select = $dbh->select()->from($roleTable)->where('parent_id = :parent_id')->where('user_id = :user_id');
$select = $dbh->select()->from($roleTable)
->where('parent_id = :parent_id')
->where('user_type = :user_type')
->where('user_id = :user_id');

return $dbh->fetchCol($select, $binds);
} else {
Expand Down
45 changes: 44 additions & 1 deletion app/code/Magento/Webapi/Model/Rest/Swagger/Generator.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
use Magento\Framework\Exception\NoSuchEntityException;
use Magento\Framework\Phrase;
use Magento\Framework\App\ProductMetadataInterface;
use \Magento\Framework\Api\SimpleDataObjectConverter;

/**
* REST Swagger schema generator.
Expand Down Expand Up @@ -541,10 +542,52 @@ protected function getDefinitions()
],
],
],
$this->definitions
$this->snakeCaseDefinitions($this->definitions)
);
}

/**
* Converts definitions' properties array to snake_case.
*
* @param array $definitions
* @return array
*/
private function snakeCaseDefinitions($definitions)
{
foreach ($definitions as $name => $vals) {
if (!empty($vals['properties'])) {
$definitions[$name]['properties'] = $this->convertArrayToSnakeCase($vals['properties']);
}
if (!empty($vals['required'])) {
$snakeCaseRequired = [];
foreach ($vals['required'] as $requiredProperty) {
$snakeCaseRequired[] = SimpleDataObjectConverter::camelCaseToSnakeCase($requiredProperty);
}
$definitions[$name]['required'] = $snakeCaseRequired;
}
}
return $definitions;
}

/**
* Converts associative array's key names from camelCase to snake_case, recursively.
*
* @param array $properties
* @return array
*/
private function convertArrayToSnakeCase($properties)
{
foreach ($properties as $name => $value) {
$snakeCaseName = SimpleDataObjectConverter::camelCaseToSnakeCase($name);
if (is_array($value)) {
$value = $this->convertArrayToSnakeCase($value);
}
unset($properties[$name]);
$properties[$snakeCaseName] = $value;
}
return $properties;
}

/**
* Get definition reference
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ public function getExpectedMultiServiceData()
'type' => 'object',
'description' => 'Interface for custom attribute value.',
'properties' => [
'attributeCode' => [
'attribute_code' => [
'type' => 'string',
'description' => 'Attribute code',
],
Expand All @@ -250,15 +250,15 @@ public function getExpectedMultiServiceData()
],
],
'required' => [
'attributeCode',
'attribute_code',
'value',
],
],
'test-module5-v1-entity-all-soap-and-rest' => [
'type' => 'object',
'description' => 'Some Data Object short description. Data Object long multi line description.',
'properties' => [
'entityId' => [
'entity_id' => [
'type' => 'integer',
'description' => 'Item ID',
],
Expand All @@ -274,7 +274,7 @@ public function getExpectedMultiServiceData()
'type' => 'boolean',
'description' => 'If current entity has a property defined',
],
'customAttributes' => [
'custom_attributes' => [
'type' => 'array',
'description' => 'Custom attributes values.',
'items' => [
Expand All @@ -283,7 +283,7 @@ public function getExpectedMultiServiceData()
],
],
'required' => [
'entityId',
'entity_id',
'enabled',
'orders',
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,4 +52,15 @@ public function fill(FixtureInterface $fixture, SimpleElement $element = null)
$this->waitForElementVisible($this->firstField);
return parent::fill($fixture, $element);
}

/**
* Choose 'yes' for upgrade option called 'Other components'
*
* @return void
*/
public function chooseUpgradeOtherComponents()
{
$this->_rootElement->find("[for=yesUpdateComponents]", Locator::SELECTOR_CSS)->click();
$this->waitForElementVisible("[ng-show='componentsProcessed']");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,9 @@ public function test(
// Select upgrade to version
$this->setupWizard->getSystemUpgradeHome()->clickSystemUpgrade();
$this->setupWizard->getSelectVersion()->fill($upgradeFixture);
if ($upgrade['otherComponents'] === 'Yes') {
$this->setupWizard->getSelectVersion()->chooseUpgradeOtherComponents();
}
$this->setupWizard->getSelectVersion()->clickNext();

// Readiness Check
Expand Down
Loading

0 comments on commit e7d6678

Please sign in to comment.