Advertisement
Guest User

Untitled

a guest
Sep 25th, 2016
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.48 KB | None | 0 0
  1. # To get started with security, check out the documentation:
  2. # http://symfony.com/doc/current/book/security.html
  3. security:
  4.  
  5. # http://symfony.com/doc/current/book/security.html#where-do-users-come-from-user-providers
  6. providers:
  7. in_memory:
  8. memory:
  9. users:
  10. admin:
  11. password: $2y$12$mWzkl91Q4moTzVYechsGPu52KpY/A8ZLWwK1aou4..q0LkOKMXFdq
  12. roles: 'ROLE_ADMIN'
  13. admin_2:
  14. password: $2y$12$uyCzM272bS.I335IvfUdeyxRu42ywKpC/51onQhMV2.yQBWSN6l3SEzqq
  15. roles: 'ROLE_ADMIN'
  16.  
  17. firewalls:
  18. # disables authentication for assets and the profiler, adapt it according to your needs
  19. dev:
  20. pattern: ^/(_(profiler|wdt)|css|images|js)/
  21. security: false
  22.  
  23. main:
  24. pattern: /.*
  25. anonymous: ~
  26. # activate different ways to authenticate
  27.  
  28. # http_basic: ~
  29. # http://symfony.com/doc/current/book/security.html#a-configuring-how-your-users-will-authenticate
  30.  
  31. # form_login: ~
  32. # http://symfony.com/doc/current/cookbook/security/form_login_setup.html
  33. provider: in_memory
  34. form_login:
  35. check_path: /admin_login_check
  36. login_path: /admin_login
  37. default_target_path: /admin/dashboard
  38. security: ~
  39. logout: ~
  40.  
  41. encoders:
  42. SymfonyComponentSecurityCoreUserUser:
  43. algorithm: bcrypt
  44. cost: 12
  45.  
  46. access_control:
  47. - { path: ^/admin/.*, roles: ROLE_ADMIN }
  48. - { path: ^/.*, roles: IS_AUTHENTICATED_ANONYMOUSLY }
  49.  
  50. <?php
  51.  
  52. // src/Shop/AdminBundle/Tests/Controller/API/OrderStatusTest.php
  53.  
  54. namespace ShopAdminBundleTestsControllerAPI;
  55.  
  56. use SymfonyBundleFrameworkBundleTestWebTestCase;
  57. use SymfonyComponentBrowserKitCookie;
  58. use SymfonyComponentSecurityCoreAuthenticationTokenUsernamePasswordToken;
  59.  
  60. class OrderStatusTest extends WebTestCase
  61. {
  62. private $client = null;
  63.  
  64. public function setUp()
  65. {
  66. $this->client = static::createClient();
  67. }
  68.  
  69. private function logIn()
  70. {
  71. $session = $this
  72. ->client
  73. ->getContainer()
  74. ->get('session');
  75.  
  76. $firewall = "main";
  77.  
  78. $token = new UsernamePasswordToken('admin', null, $firewall, array('ROLE_ADMIN'));
  79. $session->set('_secutiry_'. $firewall, serialize($token));
  80. $session->save();
  81.  
  82. $cookie = new Cookie($session->getName(), $session->getId());
  83. $this->client->getCookieJar()->set($cookie);
  84. }
  85.  
  86. public function testUpdate()
  87. {
  88. $kernel = static::createKernel();
  89. $kernel->boot();
  90.  
  91. $this->logIn();
  92.  
  93. $manager = $kernel
  94. ->getContainer()
  95. ->get('doctrine.orm.entity_manager');
  96.  
  97. $dql = "SELECT o
  98. FROM ShopCartBundleEntityOrder as o";
  99. $query = $manager->createQuery($dql);
  100. $orders = $query->getResult();
  101. $order = $orders[0];
  102.  
  103. $statuses = $manager->getRepository('ShopCartBundle:Status')
  104. ->findAll();
  105.  
  106. foreach($statuses as $key => $status) {
  107. $statuses[$status->getName()] = $status;
  108.  
  109. unset($statuses[$key]);
  110. }
  111.  
  112. $status = $statuses['Новый'];
  113. $crawler = $this->client->request('GET', '/admin/api/order_status/update/'. $order->getId() .'/'. $status->getId());
  114. print_r($this->client->getResponse()->getContent());
  115. }
  116. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement