Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix users import ddi #2899

Open
wants to merge 2 commits into
base: bleeding
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,9 @@ public function execute(CompanyInterface $company, string $csv)

if ($ddi->isNew()) {
$user->setOutgoingDdi($ddi);

$ddi->setUser($user);
$ddi->setRouteType('user');
}

$entities[] = $ddi;
Expand Down
6 changes: 6 additions & 0 deletions library/Ivoz/Provider/Domain/Model/Ddi/Ddi.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace Ivoz\Provider\Domain\Model\Ddi;

use Assert\Assertion;
use Ivoz\Provider\Domain\Model\User\UserInterface;
use Ivoz\Provider\Domain\Traits\RoutableTrait;
use Ivoz\Provider\Domain\Model\Domain\DomainInterface;

Expand Down Expand Up @@ -139,6 +140,11 @@ public function setRouteType(?string $routeType = null): static
return $this;
}

public function setUser(?UserInterface $user = null): static
{
return parent::setUser($user);
}

/**
* @return string
*/
Expand Down
4 changes: 3 additions & 1 deletion library/Ivoz/Provider/Domain/Model/Ddi/DdiInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

use Ivoz\Core\Domain\Model\LoggableEntityInterface;
use Ivoz\Provider\Domain\Model\Domain\DomainInterface;
use Ivoz\Provider\Domain\Model\User\UserInterface;
use Ivoz\Core\Domain\Model\EntityInterface;
use Ivoz\Core\Domain\DataTransferObjectInterface;
use Ivoz\Core\Domain\ForeignKeyTransformerInterface;
Expand All @@ -13,7 +14,6 @@
use Ivoz\Provider\Domain\Model\Language\LanguageInterface;
use Ivoz\Provider\Domain\Model\Queue\QueueInterface;
use Ivoz\Provider\Domain\Model\ExternalCallFilter\ExternalCallFilterInterface;
use Ivoz\Provider\Domain\Model\User\UserInterface;
use Ivoz\Provider\Domain\Model\Ivr\IvrInterface;
use Ivoz\Provider\Domain\Model\HuntGroup\HuntGroupInterface;
use Ivoz\Provider\Domain\Model\Fax\FaxInterface;
Expand Down Expand Up @@ -87,6 +87,8 @@ public function getLanguageCode(): string;

public function setRouteType(?string $routeType = null): static;

public function setUser(?UserInterface $user = null): static;

/**
* @return string
*/
Expand Down
38 changes: 3 additions & 35 deletions web/rest/brand/features/provider/user/postUser.feature
Original file line number Diff line number Diff line change
Expand Up @@ -9,40 +9,8 @@ Feature: Create users
When I add "Content-Type" header equal to "application/json"
And I add "Accept" header equal to "application/json"
And I send a "POST" request to "/users" with body:
"""
"""
{
}
"""
Then the response status code should be 405

@createSchema
Scenario: Users mass import
Given I add Brand Authorization header
When I add "Content-Type" header equal to "multipart/form-data; boundary=------IvozProviderFormBoundaryFUBrG71LG0e8DuZ8"
And I add "Accept" header equal to "application/json"
And I send a "POST" multipart request to "/users/mass_import" with body:
"""
------IvozProviderFormBoundaryFUBrG71LG0e8DuZ8
Content-Disposition: form-data; name="company"

1
------IvozProviderFormBoundaryFUBrG71LG0e8DuZ8
Content-Disposition: form-data; name="csv"; filename="massImport.csv"
Content-Type: text/csv

Name,Lastname,name@irontec.com,terminalName,Z7+KJn8m3k,YealinkT21P_E2,a00000000052,2002,ES,946002050,DDIProviderName
John,Doe,jon@irontec.com,terminalName2,Z7+KJn8m3k,YealinkT21P_E2,a00000000053,2003,ES,946002051,DDIProviderName
------IvozProviderFormBoundaryFUBrG71LG0e8DuZ8--

"""
Then the response status code should be 201
And the response should be in JSON
And the header "Content-Type" should be equal to "application/json; charset=utf-8"
And the JSON should be equal to:
"""
{
"success": true,
"errorMsg": "",
"failed": 0
}
"""
"""
Then the response status code should be 405
281 changes: 281 additions & 0 deletions web/rest/brand/features/provider/user/postUserMassImport.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,281 @@
Feature: Create users
In order to manage users
As a brand admin
I need to be able to create them through the API.

@createSchema
Scenario: Retrieve the user json list
Given I add Brand Authorization header
When I add "Accept" header equal to "application/json"
And I send a "GET" request to "users"
Then the response status code should be 200
And the response should be in JSON
And the header "Content-Type" should be equal to "application/json; charset=utf-8"
And the JSON should be equal to:
"""
[
{
"name": "Alice",
"lastname": "Allison",
"email": "alice@democompany.com",
"active": true,
"id": 1,
"company": 1,
"terminal": 1,
"extension": null,
"outgoingDdi": 3,
"location": null,
"status": [
{
"contact": "sip:yealinktest@10.10.1.106:5060",
"received": "sip:212.64.172.23:5060",
"publicReceived": true,
"expires": "2031-01-01 00:59:59",
"userAgent": "Yealink SIP-T23G 44.80.0.130"
}
]
},
{
"name": "Bob",
"lastname": "Bobson",
"email": "bob@democompany.com",
"active": true,
"id": 2,
"company": 1,
"terminal": 2,
"extension": null,
"outgoingDdi": null,
"location": 1,
"status": []
},
{
"name": "Joe",
"lastname": "Doe",
"email": "joe@democompany.com",
"active": true,
"id": 3,
"company": 1,
"terminal": 4,
"extension": 2,
"outgoingDdi": null,
"location": 1,
"status": []
}
]
"""

Scenario: Retrieve the ddi json list
Given I add Brand Authorization header
When I add "Accept" header equal to "application/json"
And I send a "GET" request to "ddis"
Then the response status code should be 200
And the response should be in JSON
And the header "Content-Type" should be equal to "application/json; charset=utf-8"
And the JSON should be equal to:
"""
[
{
"ddi": "121",
"ddie164": "+34121",
"description": null,
"id": 3,
"company": 3,
"ddiProvider": 1,
"country": 68
},
{
"ddi": "123",
"ddie164": "+34123",
"description": "Description for DDI 123",
"id": 1,
"company": 1,
"ddiProvider": 1,
"country": 68
},
{
"ddi": "124",
"ddie164": "+34124",
"description": null,
"id": 2,
"company": 4,
"ddiProvider": 1,
"country": 68
}
]
"""

@createSchema
Scenario: Users mass import
Given I add Brand Authorization header
When I add "Content-Type" header equal to "multipart/form-data; boundary=------IvozProviderFormBoundaryFUBrG71LG0e8DuZ8"
And I add "Accept" header equal to "application/json"
And I send a "POST" multipart request to "/users/mass_import" with body:
"""
------IvozProviderFormBoundaryFUBrG71LG0e8DuZ8
Content-Disposition: form-data; name="company"
1
------IvozProviderFormBoundaryFUBrG71LG0e8DuZ8
Content-Disposition: form-data; name="csv"; filename="massImport.csv"
Content-Type: text/csv
Name,Lastname,name@irontec.com,terminalName,Z7+KJn8m3k,YealinkT21P_E2,a00000000052,2002,ES,946002050,DDIProviderName
John,Doe,jon@irontec.com,terminalName2,Z7+KJn8m3k,YealinkT21P_E2,a00000000053,2003,ES,946002051,DDIProviderName
------IvozProviderFormBoundaryFUBrG71LG0e8DuZ8--
"""
Then the response status code should be 201
And the response should be in JSON
And the header "Content-Type" should be equal to "application/json; charset=utf-8"
And the JSON should be equal to:
"""
{
"success": true,
"errorMsg": "",
"failed": 0
}
"""

Scenario: Retrieve the user json list
Given I add Brand Authorization header
When I add "Accept" header equal to "application/json"
And I send a "GET" request to "users"
Then the response status code should be 200
And the response should be in JSON
And the header "Content-Type" should be equal to "application/json; charset=utf-8"
And the JSON should be equal to:
"""
[
{
"name": "Alice",
"lastname": "Allison",
"email": "alice@democompany.com",
"active": true,
"id": 1,
"company": 1,
"terminal": 1,
"extension": null,
"outgoingDdi": 3,
"location": null,
"status": [
{
"contact": "sip:yealinktest@10.10.1.106:5060",
"received": "sip:212.64.172.23:5060",
"publicReceived": true,
"expires": "2031-01-01 00:59:59",
"userAgent": "Yealink SIP-T23G 44.80.0.130"
}
]
},
{
"name": "Bob",
"lastname": "Bobson",
"email": "bob@democompany.com",
"active": true,
"id": 2,
"company": 1,
"terminal": 2,
"extension": null,
"outgoingDdi": null,
"location": 1,
"status": []
},
{
"name": "Joe",
"lastname": "Doe",
"email": "joe@democompany.com",
"active": true,
"id": 3,
"company": 1,
"terminal": 4,
"extension": 2,
"outgoingDdi": null,
"location": 1,
"status": []
},
{
"name": "John",
"lastname": "Doe",
"email": "jon@irontec.com",
"active": false,
"id": 5,
"company": 1,
"terminal": 6,
"extension": 7,
"outgoingDdi": 5,
"location": null,
"status": []
},
{
"name": "Name",
"lastname": "Lastname",
"email": "name@irontec.com",
"active": false,
"id": 4,
"company": 1,
"terminal": 5,
"extension": 6,
"outgoingDdi": 4,
"location": null,
"status": []
}
]
"""

Scenario: Retrieve the ddi json list
Given I add Brand Authorization header
When I add "Accept" header equal to "application/json"
And I send a "GET" request to "ddis"
Then the response status code should be 200
And the response should be in JSON
And the header "Content-Type" should be equal to "application/json; charset=utf-8"
And the JSON should be equal to:
"""
[
{
"ddi": "121",
"ddie164": "+34121",
"description": null,
"id": 3,
"company": 3,
"ddiProvider": 1,
"country": 68
},
{
"ddi": "123",
"ddie164": "+34123",
"description": "Description for DDI 123",
"id": 1,
"company": 1,
"ddiProvider": 1,
"country": 68
},
{
"ddi": "124",
"ddie164": "+34124",
"description": null,
"id": 2,
"company": 4,
"ddiProvider": 1,
"country": 68
},
{
"ddi": "946002050",
"ddie164": "+34946002050",
"description": null,
"id": 4,
"company": 1,
"ddiProvider": 1,
"country": 68
},
{
"ddi": "946002051",
"ddie164": "+34946002051",
"description": null,
"id": 5,
"company": 1,
"ddiProvider": 1,
"country": 68
}
]
"""