Parametrización de los parámetros de conexión a la base de datos declarados en behat.yml y enviados mediante los features.
This commit is contained in:
@@ -2,5 +2,36 @@
|
|||||||
default:
|
default:
|
||||||
context:
|
context:
|
||||||
parameters:
|
parameters:
|
||||||
base_url: http://192.168.11.181/api/1.0/michelangelo/
|
base_url: http://michelangelo-be.colosa.net/api/1.0/michelangelo/
|
||||||
access_token: cd5cff9b2e3ebabf49e276e47e977fab5988c00e
|
access_token: e79057f4276661bedb6154eed3834f6cbd738853
|
||||||
|
client_id: x-pm-local-client
|
||||||
|
client_secret: 179ad45c6ce2cb97cf1029e212046e81
|
||||||
|
#uploadFilesFolder: /opt/uploadfiles
|
||||||
|
#cd5cff9b2e3ebabf49e276e47e977fab5988c00e
|
||||||
|
login_url: http://michelangelo-be.colosa.net/sysmichelangelo/en/neoclassic/login/login
|
||||||
|
authentication_url: http://michelangelo-be.colosa.net/sysmichelangelo/en/neoclassic/login/authentication.php
|
||||||
|
oauth_app_url: http://michelangelo-be.colosa.net/sysmichelangelo/en/neoclassic/oauth2/clientSetupAjax
|
||||||
|
oauth_authorization_url: http://michelangelo-be.colosa.net/michelangelo/oauth2/authorize
|
||||||
|
user_name: admin
|
||||||
|
user_password: sample123*
|
||||||
|
|
||||||
|
# Database connection parameters
|
||||||
|
# To Mysql
|
||||||
|
mys_db_type: mysql
|
||||||
|
mys_db_server: michelangelo-be.colosa.net
|
||||||
|
mys_db_name: michelangelo
|
||||||
|
mys_db_username: root
|
||||||
|
mys_db_password:
|
||||||
|
mys_db_port: 3306
|
||||||
|
mys_db_encode: utf8
|
||||||
|
mys_db_description: Mysql connection
|
||||||
|
|
||||||
|
# To SQL Server
|
||||||
|
sqlsrv_db_type: mssql
|
||||||
|
sqlsrv_db_server: 192.168.11.99
|
||||||
|
sqlsrv_db_name: wf_michelangelo
|
||||||
|
sqlsrv_db_username: sa
|
||||||
|
sqlsrv_db_password: mafe12345
|
||||||
|
sqlsrv_db_port: 1433
|
||||||
|
sqlsrv_db_encode: utf8
|
||||||
|
sqlsrv_db_description: Microsoft SQL Server connection
|
||||||
@@ -9,25 +9,30 @@ Feature: DataBase Connections
|
|||||||
And the response has 0 record
|
And the response has 0 record
|
||||||
|
|
||||||
|
|
||||||
Scenario: Create a new database connection
|
Scenario Outline: Create a new database connection
|
||||||
Given that I have a valid access_token
|
Given that I have a valid access_token
|
||||||
And POST this data:
|
And POST this data:
|
||||||
"""
|
"""
|
||||||
{
|
{
|
||||||
"dbs_type": "mysql",
|
"dbs_type": "<dbs_type>",
|
||||||
"dbs_server": "michelangelo-be.colosa.net",
|
"dbs_server": "<dbs_server>",
|
||||||
"dbs_database_name": "test",
|
"dbs_database_name": "<dbs_database_name>",
|
||||||
"dbs_username": "testuser",
|
"dbs_username": "<dbs_username>",
|
||||||
"dbs_password": "sample",
|
"dbs_password": "<dbs_password>",
|
||||||
"dbs_port": 3306,
|
"dbs_port": <dbs_port>,
|
||||||
"dbs_encode": "utf8",
|
"dbs_encode": "<dbs_encode>",
|
||||||
"dbs_description": "conection correcta"
|
"dbs_description": "<dbs_description>"
|
||||||
}
|
}
|
||||||
"""
|
"""
|
||||||
And I request "project/74737540052e1641ab88249082085472/database-connection"
|
And I request "project/74737540052e1641ab88249082085472/database-connection"
|
||||||
Then the response status code should be 201
|
Then the response status code should be 201
|
||||||
And store "dbs_uid" in session array
|
And store "dbs_uid" in session array
|
||||||
|
|
||||||
|
Examples:
|
||||||
|
| dbs_type | dbs_server | dbs_database_name | dbs_username | dbs_password | dbs_port | dbs_encode | dbs_description |
|
||||||
|
| <mys_db_type> | <mys_db_server> | <mys_db_name> | <mys_db_username> | <mys_db_password> | <mys_db_port> | <mys_db_encode> | <mys_db_description> |
|
||||||
|
|
||||||
|
|
||||||
@3: TEST FOR GET DATABASE CONNECTIONS /----------------------------------------------------------------------
|
@3: TEST FOR GET DATABASE CONNECTIONS /----------------------------------------------------------------------
|
||||||
Scenario: List all the database connections (result 1 database connection)
|
Scenario: List all the database connections (result 1 database connection)
|
||||||
Given that I have a valid access_token
|
Given that I have a valid access_token
|
||||||
@@ -37,19 +42,19 @@ Feature: DataBase Connections
|
|||||||
And the response has 1 record
|
And the response has 1 record
|
||||||
|
|
||||||
@4: TEST FOR PUT DATABASE CONNECTION /-----------------------------------------------------------------------
|
@4: TEST FOR PUT DATABASE CONNECTION /-----------------------------------------------------------------------
|
||||||
Scenario: Update a database connection
|
Scenario Outline: Update a database connection
|
||||||
Given that I have a valid access_token
|
Given that I have a valid access_token
|
||||||
And PUT this data:
|
And PUT this data:
|
||||||
"""
|
"""
|
||||||
{
|
{
|
||||||
"dbs_type": "mysql",
|
"dbs_type": "<dbs_type>",
|
||||||
"dbs_server": "michelangelo-be.colosa.net",
|
"dbs_server": "<dbs_server>",
|
||||||
"dbs_database_name": "test",
|
"dbs_database_name": "<dbs_database_name>",
|
||||||
"dbs_username": "testuser",
|
"dbs_username": "<dbs_username>",
|
||||||
"dbs_password": "sample",
|
"dbs_password": "<dbs_password>",
|
||||||
"dbs_port": 3306,
|
"dbs_port": <dbs_port>,
|
||||||
"dbs_encode": "utf8",
|
"dbs_encode": "<dbs_encode>",
|
||||||
"dbs_description": "conection correcta a workflow"
|
"dbs_description": "<dbs_description>"
|
||||||
}
|
}
|
||||||
"""
|
"""
|
||||||
And that I want to update a resource with the key "dbs_uid" stored in session array
|
And that I want to update a resource with the key "dbs_uid" stored in session array
|
||||||
@@ -58,6 +63,10 @@ Feature: DataBase Connections
|
|||||||
And the response charset is "UTF-8"
|
And the response charset is "UTF-8"
|
||||||
And the type is "object"
|
And the type is "object"
|
||||||
|
|
||||||
|
Examples:
|
||||||
|
| dbs_type | dbs_server | dbs_database_name | dbs_username | dbs_password | dbs_port | dbs_encode | dbs_description |
|
||||||
|
| <mys_db_type> | <mys_db_server> | <mys_db_name> | <mys_db_username> | <mys_db_password> | <mys_db_port> | <mys_db_encode> | <mys_db_description> |
|
||||||
|
|
||||||
|
|
||||||
Scenario: Get a database connection (with change in "dbs_description" and "dbs_database_name")
|
Scenario: Get a database connection (with change in "dbs_description" and "dbs_database_name")
|
||||||
Given that I have a valid access_token
|
Given that I have a valid access_token
|
||||||
|
|||||||
@@ -1,29 +1,34 @@
|
|||||||
@ProcessMakerMichelangelo @RestAPI
|
@ProcessMakerMichelangelo @RestAPI
|
||||||
Feature: DataBase Connections Main Tests MySQL
|
Feature: DataBase Connections Main Tests Mysql
|
||||||
Requirements:
|
Requirements:
|
||||||
a workspace with the process 74737540052e1641ab88249082085472 ("Data Base Connenctions") already loaded
|
A workspace with previous creation of process with ID=74737540052e1641ab88249082085472 ("Data Base Connections") already loaded
|
||||||
and workspace with the project 87648819953a85c0abc01d3080475981 ("testExecutionOfDerivationScreen") already loaded
|
and workspace with the project 87648819953a85c0abc01d3080475981 ("testExecutionOfDerivationScreen") already loaded
|
||||||
there are zero Database Connections in the process
|
there are zero Database Connections in the processes.
|
||||||
|
|
||||||
Background:
|
Background:
|
||||||
Given that I have a valid access_token
|
Given that I have a valid access_token
|
||||||
|
|
||||||
Scenario Outline: Get the DataBase Connections List when there are exactly zero DataBase Connections
|
|
||||||
Given I request "project/<project>/database-connections"
|
|
||||||
Then the response status code should be 200
|
|
||||||
And the response charset is "UTF-8"
|
|
||||||
And the response has <record> record
|
|
||||||
|
|
||||||
Examples:
|
# GET /api/1.0/{workspace}/project/<project-id>/database-connections
|
||||||
|
# Get list DataBase Connections
|
||||||
|
Scenario Outline: Get the DataBase Connections List when there are exactly zero DataBase Connections
|
||||||
|
Given I request "project/<project>/database-connections"
|
||||||
|
Then the response status code should be 200
|
||||||
|
And the response charset is "UTF-8"
|
||||||
|
And the response has <record> record
|
||||||
|
|
||||||
| test_description | project | record |
|
Examples:
|
||||||
| List DB in the process Data Base Connenctions .pm | 74737540052e1641ab88249082085472 | 0 |
|
|
||||||
| List DB in the process testExecutionOfDerivationScreen .pmx | 87648819953a85c0abc01d3080475981 | 0 |
|
| project | record |
|
||||||
|
| 74737540052e1641ab88249082085472 | 1 |
|
||||||
|
| 87648819953a85c0abc01d3080475981 | 1 |
|
||||||
|
|
||||||
|
|
||||||
Scenario Outline: Test database connection to test
|
# POST /api/1.0/{workspace}/project/<project-id>/database-connection/test
|
||||||
Given POST this data:
|
# Test DataBase Connection
|
||||||
"""
|
Scenario Outline: Test database connection to test
|
||||||
|
Given POST this data:
|
||||||
|
"""
|
||||||
{
|
{
|
||||||
"dbs_type": "<dbs_type>",
|
"dbs_type": "<dbs_type>",
|
||||||
"dbs_server": "<dbs_server>",
|
"dbs_server": "<dbs_server>",
|
||||||
@@ -35,138 +40,13 @@ Feature: DataBase Connections Main Tests MySQL
|
|||||||
"dbs_description": "<dbs_description>"
|
"dbs_description": "<dbs_description>"
|
||||||
}
|
}
|
||||||
"""
|
"""
|
||||||
And I request "project/<project>/database-connection/test"
|
And I request "project/<project>/database-connection/test"
|
||||||
Then if database-connection with id "<dbs_uid_number>" is active
|
Then database-connection with id "<dbs_uid_number>" is active
|
||||||
Then the response status code should be 200
|
Then the response status code should be 200
|
||||||
And the response charset is "UTF-8"
|
And the response charset is "UTF-8"
|
||||||
And the content type is "application/json"
|
And the content type is "application/json"
|
||||||
|
|
||||||
Examples:
|
Examples:
|
||||||
|
| dbs_uid_number | project | dbs_type | dbs_server | dbs_database_name | dbs_username | dbs_password | dbs_port | dbs_encode | dbs_description |
|
||||||
| test_description | dbs_uid_number | project | dbs_type | dbs_server | dbs_database_name | dbs_username | dbs_password | dbs_port | dbs_encode | dbs_description |
|
| 46110938554821d2ddb8d01076533986 | 74737540052e1641ab88249082085472 | <mys_db_type> | <mys_db_server> | <mys_db_name> | <mys_db_username> | <mys_db_password> | <mys_db_port> | <mys_db_encode> | <mys_db_description> |
|
||||||
| Test SQL Server db connection .pm | 1 | 74737540052e1641ab88249082085472 | microsoft sql server | 192.168.11.99 | wf_michelangelo | sa | mafe12345 | 1433 | utf8 | SQL Server connection |
|
| 40639901154821d2e3bb7e8061116901 | 87648819953a85c0abc01d3080475981 | <mys_db_type> | <mys_db_server> | <mys_db_name> | <mys_db_username> | <mys_db_password> | <mys_db_port> | <mys_db_encode> | <mys_db_description> |
|
||||||
| Test SQL Server db connection .pmx | 2 | 87648819953a85c0abc01d3080475981 | microsoft sql server | 192.168.11.99 | wf_michelangelo | sa | mafe12345 | 1433 | utf8 | SQL Server connection |
|
|
||||||
|
|
||||||
|
|
||||||
Scenario Outline: Create a new database connection
|
|
||||||
Given database-connection with id "<dbs_uid_number>" is active
|
|
||||||
And POST this data:
|
|
||||||
"""
|
|
||||||
{
|
|
||||||
"dbs_type": "<dbs_type>",
|
|
||||||
"dbs_server": "<dbs_server>",
|
|
||||||
"dbs_database_name": "<dbs_database_name>",
|
|
||||||
"dbs_username": "<dbs_username>",
|
|
||||||
"dbs_password": "<dbs_password>",
|
|
||||||
"dbs_port": <dbs_port>,
|
|
||||||
"dbs_encode": "<dbs_encode>",
|
|
||||||
"dbs_description": "<dbs_description>"
|
|
||||||
}
|
|
||||||
"""
|
|
||||||
And I request "project/<project>/database-connection"
|
|
||||||
Then the response status code should be 201
|
|
||||||
And the response charset is "UTF-8"
|
|
||||||
And the content type is "application/json"
|
|
||||||
And the type is "object"
|
|
||||||
And store "dbs_uid" in session array as variable "dbs_uid_<dbs_uid_number>"
|
|
||||||
|
|
||||||
Examples:
|
|
||||||
|
|
||||||
| test_description | dbs_uid_number | project | dbs_type | dbs_server | dbs_database_name | dbs_username | dbs_password | dbs_port | dbs_encode | dbs_description |
|
|
||||||
| Create SQL Server db connection .pm | 1 | 74737540052e1641ab88249082085472 | mssql | 192.168.11.99 | wf_michelangelo | sa | mafe12345 | 1433 | utf8 | SQL Server connection |
|
|
||||||
| Create SQL Server db connection .pmx | 2 | 87648819953a85c0abc01d3080475981 | mssql | 192.168.11.99 | wf_michelangelo | sa | mafe12345 | 1433 | utf8 | SQL Server connection |
|
|
||||||
|
|
||||||
|
|
||||||
Scenario Outline: Get the DataBase Connections List when there are exactly one DataBase Connections in each process
|
|
||||||
Given database-connection with id "<dbs_uid_number>" is active
|
|
||||||
And I request "project/<project>/database-connections"
|
|
||||||
Then the response status code should be 200
|
|
||||||
And the response charset is "UTF-8"
|
|
||||||
And the response has <record> record
|
|
||||||
|
|
||||||
Examples:
|
|
||||||
|
|
||||||
| test_description | project | record | dbs_uid_number |
|
|
||||||
| List DB in the process Data Base Connenctions .pm | 74737540052e1641ab88249082085472 | 1 | 1 |
|
|
||||||
| List DB in the process testExecutionOfDerivationScreen .pmx | 87648819953a85c0abc01d3080475981 | 1 | 2 |
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Scenario Outline: Update a database connection
|
|
||||||
Given database-connection with id "<dbs_uid_number>" is active
|
|
||||||
And PUT this data:
|
|
||||||
"""
|
|
||||||
{
|
|
||||||
"dbs_type": "<dbs_type>",
|
|
||||||
"dbs_server": "<dbs_server>",
|
|
||||||
"dbs_database_name": "<dbs_database_name>",
|
|
||||||
"dbs_username": "<dbs_username>",
|
|
||||||
"dbs_password": "<dbs_password>",
|
|
||||||
"dbs_port": <dbs_port>,
|
|
||||||
"dbs_encode": "<dbs_encode>",
|
|
||||||
"dbs_description": "<dbs_description>"
|
|
||||||
}
|
|
||||||
"""
|
|
||||||
And that I want to update a resource with the key "dbs_uid" stored in session array as variable "dbs_uid_<dbs_uid_number>"
|
|
||||||
And I request "project/<project>/database-connection"
|
|
||||||
Then the response status code should be 200
|
|
||||||
And the response charset is "UTF-8"
|
|
||||||
And the type is "object"
|
|
||||||
|
|
||||||
Examples:
|
|
||||||
|
|
||||||
| test_description | dbs_uid_number | project | dbs_type | dbs_server | dbs_database_name | dbs_username | dbs_password | dbs_port | dbs_encode | dbs_description |
|
|
||||||
| Update sql server db connection .pm | 1 | 74737540052e1641ab88249082085472 | mssql | 192.168.11.99 | wf_michelangelo | sa | mafe12345 | 1433 | utf8 | update SQL Server connection |
|
|
||||||
| Update sql server db connection .pmx | 2 | 87648819953a85c0abc01d3080475981 | mssql | 192.168.11.99 | wf_michelangelo | sa | mafe12345 | 1433 | utf8 | update SQL Server connection |
|
|
||||||
|
|
||||||
|
|
||||||
Scenario Outline: Get a single database connection and check some properties
|
|
||||||
Given database-connection with id "<dbs_uid_number>" is active
|
|
||||||
And that I want to get a resource with the key "dbs_uid" stored in session array as variable "dbs_uid_<dbs_uid_number>"
|
|
||||||
And I request "project/<project>/database-connection"
|
|
||||||
Then the response status code should be 200
|
|
||||||
And the response charset is "UTF-8"
|
|
||||||
And the type is "object"
|
|
||||||
And that "dbs_type" is set to "<dbs_type>"
|
|
||||||
And that "dbs_server" is set to "<dbs_server>"
|
|
||||||
And that "dbs_database_name" is set to "<dbs_database_name>"
|
|
||||||
And that "dbs_username" is set to "<dbs_username>"
|
|
||||||
And that "dbs_password" is set to "<dbs_password>"
|
|
||||||
And that "dbs_port" is set to "<dbs_port>"
|
|
||||||
And that "dbs_encode" is set to "<dbs_encode>"
|
|
||||||
And that "dbs_description" is set to "<dbs_description>"
|
|
||||||
|
|
||||||
Examples:
|
|
||||||
|
|
||||||
| test_description | dbs_uid_number | project | dbs_type | dbs_server | dbs_database_name | dbs_username | dbs_password | dbs_port | dbs_encode | dbs_description |
|
|
||||||
| Update sql server db connection .pm | 1 | 74737540052e1641ab88249082085472 | mssql | 192.168.11.99 | wf_michelangelo | sa | mafe12345 | 1433 | utf8 | update SQL Server connection |
|
|
||||||
| Update sql server db connection .pmx | 2 | 87648819953a85c0abc01d3080475981 | mssql | 192.168.11.99 | wf_michelangelo | sa | mafe12345 | 1433 | utf8 | update SQL Server connection |
|
|
||||||
|
|
||||||
|
|
||||||
Scenario Outline: Delete all Database Connection created previously in this script
|
|
||||||
Given database-connection with id "<dbs_uid_number>" is active
|
|
||||||
And that I want to delete a resource with the key "dbs_uid" stored in session array as variable "dbs_uid_<dbs_uid_number>"
|
|
||||||
And I request "project/<project>/database-connection"
|
|
||||||
Then the response status code should be 200
|
|
||||||
And the response charset is "UTF-8"
|
|
||||||
And the type is "object"
|
|
||||||
|
|
||||||
Examples:
|
|
||||||
|
|
||||||
| project | dbs_uid_number |
|
|
||||||
| 74737540052e1641ab88249082085472 | 1 |
|
|
||||||
| 87648819953a85c0abc01d3080475981 | 2 |
|
|
||||||
|
|
||||||
|
|
||||||
Scenario Outline: Get the DataBase Connections List when there are exactly zero DataBase Connections
|
|
||||||
Given database-connection with id "<dbs_uid_number>" is active
|
|
||||||
And I request "project/<project>/database-connections"
|
|
||||||
Then the response status code should be 200
|
|
||||||
And the response charset is "UTF-8"
|
|
||||||
And the response has <record> record
|
|
||||||
|
|
||||||
Examples:
|
|
||||||
|
|
||||||
| test_description | project | record | dbs_uid_number |
|
|
||||||
| List DB in the process Data Base Connenctions .pm | 74737540052e1641ab88249082085472 | 0 | 1 |
|
|
||||||
| List DB in the process testExecutionOfDerivationScreen .pmx | 87648819953a85c0abc01d3080475981 | 0 | 2 |
|
|
||||||
@@ -1,29 +1,33 @@
|
|||||||
@ProcessMakerMichelangelo @RestAPI
|
@ProcessMakerMichelangelo @RestAPI
|
||||||
Feature: DataBase Connections Main Tests SQL Server
|
Feature: DataBase Connections Main Tests SQL Server
|
||||||
Requirements:
|
Requirements:
|
||||||
a workspace with the process 74737540052e1641ab88249082085472 ("Data Base Connenctions") already loaded
|
A workspace with previous creation of process with ID=74737540052e1641ab88249082085472 ("Data Base Connections") already loaded
|
||||||
and workspace with the project 87648819953a85c0abc01d3080475981 ("testExecutionOfDerivationScreen") already loaded
|
and workspace with the project 87648819953a85c0abc01d3080475981 ("testExecutionOfDerivationScreen") already loaded
|
||||||
there are zero Database Connections in the processes
|
there are zero Database Connections in the processes.
|
||||||
|
|
||||||
Background:
|
Background:
|
||||||
Given that I have a valid access_token
|
Given that I have a valid access_token
|
||||||
|
|
||||||
Scenario Outline: Get the DataBase Connections List when there are exactly zero DataBase Connections
|
|
||||||
Given I request "project/<project>/database-connections"
|
|
||||||
Then the response status code should be 200
|
|
||||||
And the response charset is "UTF-8"
|
|
||||||
And the response has <record> record
|
|
||||||
|
|
||||||
Examples:
|
# GET /api/1.0/{workspace}/project/<project-id>/database-connections
|
||||||
|
# Get list DataBase Connections
|
||||||
|
Scenario Outline: Get the DataBase Connections List when there are exactly zero DataBase Connections
|
||||||
|
Given I request "project/<project>/database-connections"
|
||||||
|
Then the response status code should be 200
|
||||||
|
And the response charset is "UTF-8"
|
||||||
|
And the response has <record> record
|
||||||
|
|
||||||
| test_description | project | record |
|
Examples:
|
||||||
| List DB in the process Data Base Connenctions .pm | 74737540052e1641ab88249082085472 | 0 |
|
| project | record |
|
||||||
| List DB in the process testExecutionOfDerivationScreen .pmx | 87648819953a85c0abc01d3080475981 | 0 |
|
| 106912358530c9b14ac15d3001790900 | 0 |
|
||||||
|
| 1265557095225ff5c688f46031700471 | 0 |
|
||||||
|
|
||||||
|
|
||||||
Scenario Outline: Test database connection to test
|
# POST /api/1.0/{workspace}/project/<project-id>/database-connection/test
|
||||||
Given POST this data:
|
# Test DataBase Connection
|
||||||
"""
|
Scenario Outline: Test database connection to test
|
||||||
|
Given POST this data:
|
||||||
|
"""
|
||||||
{
|
{
|
||||||
"dbs_type": "<dbs_type>",
|
"dbs_type": "<dbs_type>",
|
||||||
"dbs_server": "<dbs_server>",
|
"dbs_server": "<dbs_server>",
|
||||||
@@ -35,23 +39,24 @@ Feature: DataBase Connections Main Tests SQL Server
|
|||||||
"dbs_description": "<dbs_description>"
|
"dbs_description": "<dbs_description>"
|
||||||
}
|
}
|
||||||
"""
|
"""
|
||||||
And I request "project/<project>/database-connection/test"
|
And I request "project/<project>/database-connection/test"
|
||||||
Then if database-connection with id "<dbs_uid_number>" is active
|
Then if database-connection with id "<dbs_uid_number>" is active
|
||||||
Then the response status code should be 200
|
Then the response status code should be 200
|
||||||
And the response charset is "UTF-8"
|
And the response charset is "UTF-8"
|
||||||
And the content type is "application/json"
|
And the content type is "application/json"
|
||||||
|
|
||||||
Examples:
|
Examples:
|
||||||
|
| dbs_uid_number | project | dbs_type | dbs_server | dbs_database_name | dbs_username | dbs_password | dbs_port | dbs_encode | dbs_description |
|
||||||
| test_description | dbs_uid_number | project | dbs_type | dbs_server | dbs_database_name | dbs_username | dbs_password | dbs_port | dbs_encode | dbs_description |
|
| 1 | 106912358530c9b14ac15d3001790900 | <sqlsrv_db_type> | <sqlsrv_db_server> | <sqlsrv_db_name> | <sqlsrv_db_username> | <sqlsrv_db_password> | <sqlsrv_db_port> | <sqlsrv_db_encode> | <sqlsrv_db_description> |
|
||||||
| Test SQL Server db connection .pm | 1 | 74737540052e1641ab88249082085472 | microsoft sql server | 192.168.11.99 | wf_michelangelo | sa | mafe12345 | 1433 | utf8 | SQL Server connection |
|
| 2 | 1265557095225ff5c688f46031700471 | <sqlsrv_db_type> | <sqlsrv_db_server> | <sqlsrv_db_name> | <sqlsrv_db_username> | <sqlsrv_db_password> | <sqlsrv_db_port> | <sqlsrv_db_encode> | <sqlsrv_db_description> |
|
||||||
| Test SQL Server db connection .pmx | 2 | 87648819953a85c0abc01d3080475981 | microsoft sql server | 192.168.11.99 | wf_michelangelo | sa | mafe12345 | 1433 | utf8 | SQL Server connection |
|
|
||||||
|
|
||||||
|
|
||||||
Scenario Outline: Create a new database connection
|
# POST /api/1.0/{workspace}/project/<project-id>/database-connection
|
||||||
Given database-connection with id "<dbs_uid_number>" is active
|
# Create new DataBase Connection
|
||||||
And POST this data:
|
Scenario Outline: Create a new database connection
|
||||||
"""
|
Given database-connection with id "<dbs_uid_number>" is active
|
||||||
|
And POST this data:
|
||||||
|
"""
|
||||||
{
|
{
|
||||||
"dbs_type": "<dbs_type>",
|
"dbs_type": "<dbs_type>",
|
||||||
"dbs_server": "<dbs_server>",
|
"dbs_server": "<dbs_server>",
|
||||||
@@ -63,38 +68,40 @@ Feature: DataBase Connections Main Tests SQL Server
|
|||||||
"dbs_description": "<dbs_description>"
|
"dbs_description": "<dbs_description>"
|
||||||
}
|
}
|
||||||
"""
|
"""
|
||||||
And I request "project/<project>/database-connection"
|
And I request "project/<project>/database-connection"
|
||||||
Then the response status code should be 201
|
Then the response status code should be 201
|
||||||
And the response charset is "UTF-8"
|
And the response charset is "UTF-8"
|
||||||
And the content type is "application/json"
|
And the content type is "application/json"
|
||||||
And the type is "object"
|
And the type is "object"
|
||||||
And store "dbs_uid" in session array as variable "dbs_uid_<dbs_uid_number>"
|
And store "dbs_uid" in session array as variable "dbs_uid_<dbs_uid_number>"
|
||||||
|
|
||||||
Examples:
|
Examples:
|
||||||
|
| dbs_uid_number | project | dbs_type | dbs_server | dbs_database_name | dbs_username | dbs_password | dbs_port | dbs_encode | dbs_description |
|
||||||
| test_description | dbs_uid_number | project | dbs_type | dbs_server | dbs_database_name | dbs_username | dbs_password | dbs_port | dbs_encode | dbs_description |
|
| 1 | 106912358530c9b14ac15d3001790900 | <sqlsrv_db_type> | <sqlsrv_db_server> | <sqlsrv_db_name> | <sqlsrv_db_username> | <sqlsrv_db_password> | <sqlsrv_db_port> | <sqlsrv_db_encode> | <sqlsrv_db_description> |
|
||||||
| Create SQL Server db connection .pm | 1 | 74737540052e1641ab88249082085472 | mssql | 192.168.11.99 | wf_michelangelo | sa | mafe12345 | 1433 | utf8 | SQL Server connection |
|
| 2 | 1265557095225ff5c688f46031700471 | <sqlsrv_db_type> | <sqlsrv_db_server> | <sqlsrv_db_name> | <sqlsrv_db_username> | <sqlsrv_db_password> | <sqlsrv_db_port> | <sqlsrv_db_encode> | <sqlsrv_db_description> |
|
||||||
| Create SQL Server db connection .pmx | 2 | 87648819953a85c0abc01d3080475981 | mssql | 192.168.11.99 | wf_michelangelo | sa | mafe12345 | 1433 | utf8 | SQL Server connection |
|
|
||||||
|
|
||||||
|
|
||||||
Scenario Outline: Get the DataBase Connections List when there are exactly one DataBase Connections in each process
|
# GET /api/1.0/{workspace}/project/<project-id>/database-connection
|
||||||
Given database-connection with id "<dbs_uid_number>" is active
|
# Get DataBase Connections list of each process
|
||||||
And I request "project/<project>/database-connections"
|
Scenario Outline: Get the DataBase Connections List when there are exactly one DataBase Connections in each process
|
||||||
Then the response status code should be 200
|
Given database-connection with id "<dbs_uid_number>" is active
|
||||||
And the response charset is "UTF-8"
|
And I request "project/<project>/database-connections"
|
||||||
And the response has <record> record
|
Then the response status code should be 200
|
||||||
|
And the response charset is "UTF-8"
|
||||||
|
And the response has <record> record
|
||||||
|
|
||||||
Examples:
|
Examples:
|
||||||
|
| project | record | dbs_uid_number |
|
||||||
| test_description | project | record | dbs_uid_number |
|
| 106912358530c9b14ac15d3001790900 | 1 | 1 |
|
||||||
| List DB in the process Data Base Connenctions .pm | 74737540052e1641ab88249082085472 | 1 | 1 |
|
| 1265557095225ff5c688f46031700471 | 1 | 2 |
|
||||||
| List DB in the process testExecutionOfDerivationScreen .pmx | 87648819953a85c0abc01d3080475981 | 1 | 2 |
|
|
||||||
|
|
||||||
|
|
||||||
Scenario Outline: Update a database connection
|
# PUT /api/1.0/{workspace}/project/<project-id>/database-connection
|
||||||
Given database-connection with id "<dbs_uid_number>" is active
|
# Update a DataBase Connection
|
||||||
And PUT this data:
|
Scenario Outline: Update a database connection
|
||||||
"""
|
Given database-connection with id "<dbs_uid_number>" is active
|
||||||
|
And PUT this data:
|
||||||
|
"""
|
||||||
{
|
{
|
||||||
"dbs_type": "<dbs_type>",
|
"dbs_type": "<dbs_type>",
|
||||||
"dbs_server": "<dbs_server>",
|
"dbs_server": "<dbs_server>",
|
||||||
@@ -106,66 +113,68 @@ Feature: DataBase Connections Main Tests SQL Server
|
|||||||
"dbs_description": "<dbs_description>"
|
"dbs_description": "<dbs_description>"
|
||||||
}
|
}
|
||||||
"""
|
"""
|
||||||
And that I want to update a resource with the key "dbs_uid" stored in session array as variable "dbs_uid_<dbs_uid_number>"
|
And that I want to update a resource with the key "dbs_uid" stored in session array as variable "dbs_uid_<dbs_uid_number>"
|
||||||
And I request "project/<project>/database-connection"
|
And I request "project/<project>/database-connection"
|
||||||
Then the response status code should be 200
|
Then the response status code should be 200
|
||||||
And the response charset is "UTF-8"
|
And the response charset is "UTF-8"
|
||||||
And the type is "object"
|
And the type is "object"
|
||||||
|
|
||||||
Examples:
|
Examples:
|
||||||
|
| dbs_uid_number | project | dbs_type | dbs_server | dbs_database_name | dbs_username | dbs_password | dbs_port | dbs_encode | dbs_description |
|
||||||
| test_description | dbs_uid_number | project | dbs_type | dbs_server | dbs_database_name | dbs_username | dbs_password | dbs_port | dbs_encode | dbs_description |
|
| 1 | 106912358530c9b14ac15d3001790900 | <sqlsrv_db_type> | <sqlsrv_db_server> | <sqlsrv_db_name> | <sqlsrv_db_username> | <sqlsrv_db_password> | <sqlsrv_db_port> | <sqlsrv_db_encode> | <sqlsrv_db_description> |
|
||||||
| Update sql server db connection .pm | 1 | 74737540052e1641ab88249082085472 | mssql | 192.168.11.99 | wf_michelangelo | sa | mafe12345 | 1433 | utf8 | update SQL Server connection |
|
| 2 | 1265557095225ff5c688f46031700471 | <sqlsrv_db_type> | <sqlsrv_db_server> | <sqlsrv_db_name> | <sqlsrv_db_username> | <sqlsrv_db_password> | <sqlsrv_db_port> | <sqlsrv_db_encode> | <sqlsrv_db_description> |
|
||||||
| Update sql server db connection .pmx | 2 | 87648819953a85c0abc01d3080475981 | mssql | 192.168.11.99 | wf_michelangelo | sa | mafe12345 | 1433 | utf8 | update SQL Server connection |
|
|
||||||
|
|
||||||
|
|
||||||
Scenario Outline: Get a single database connection and check some properties
|
# GET /api/1.0/{workspace}/project/<project-id>/database-connection
|
||||||
Given database-connection with id "<dbs_uid_number>" is active
|
# Get a single DataBase Connection and their properties
|
||||||
And that I want to get a resource with the key "dbs_uid" stored in session array as variable "dbs_uid_<dbs_uid_number>"
|
Scenario Outline: Get a single database connection and check some properties
|
||||||
And I request "project/<project>/database-connection"
|
Given database-connection with id "<dbs_uid_number>" is active
|
||||||
Then the response status code should be 200
|
And that I want to get a resource with the key "dbs_uid" stored in session array as variable "dbs_uid_<dbs_uid_number>"
|
||||||
And the response charset is "UTF-8"
|
And I request "project/<project>/database-connection"
|
||||||
And the type is "object"
|
Then the response status code should be 200
|
||||||
And that "dbs_type" is set to "<dbs_type>"
|
And the response charset is "UTF-8"
|
||||||
And that "dbs_server" is set to "<dbs_server>"
|
And the type is "object"
|
||||||
And that "dbs_database_name" is set to "<dbs_database_name>"
|
And that "dbs_type" is set to "<dbs_type>"
|
||||||
And that "dbs_username" is set to "<dbs_username>"
|
And that "dbs_server" is set to "<dbs_server>"
|
||||||
And that "dbs_password" is set to "<dbs_password>"
|
And that "dbs_database_name" is set to "<dbs_database_name>"
|
||||||
And that "dbs_port" is set to "<dbs_port>"
|
And that "dbs_username" is set to "<dbs_username>"
|
||||||
And that "dbs_encode" is set to "<dbs_encode>"
|
And that "dbs_password" is set to "<dbs_password>"
|
||||||
And that "dbs_description" is set to "<dbs_description>"
|
And that "dbs_port" is set to "<dbs_port>"
|
||||||
|
And that "dbs_encode" is set to "<dbs_encode>"
|
||||||
|
And that "dbs_description" is set to "<dbs_description>"
|
||||||
|
|
||||||
Examples:
|
Examples:
|
||||||
|
| dbs_uid_number | project | dbs_type | dbs_server | dbs_database_name | dbs_username | dbs_password | dbs_port | dbs_encode | dbs_description |
|
||||||
| test_description | dbs_uid_number | project | dbs_type | dbs_server | dbs_database_name | dbs_username | dbs_password | dbs_port | dbs_encode | dbs_description |
|
| 1 | 106912358530c9b14ac15d3001790900 | <sqlsrv_db_type> | <sqlsrv_db_server> | <sqlsrv_db_name> | <sqlsrv_db_username> | <sqlsrv_db_password> | <sqlsrv_db_port> | <sqlsrv_db_encode> | <sqlsrv_db_description> |
|
||||||
| Update sql server db connection .pm | 1 | 74737540052e1641ab88249082085472 | mssql | 192.168.11.99 | wf_michelangelo | sa | mafe12345 | 1433 | utf8 | update SQL Server connection |
|
| 2 | 1265557095225ff5c688f46031700471 | <sqlsrv_db_type> | <sqlsrv_db_server> | <sqlsrv_db_name> | <sqlsrv_db_username> | <sqlsrv_db_password> | <sqlsrv_db_port> | <sqlsrv_db_encode> | <sqlsrv_db_description> |
|
||||||
| Update sql server db connection .pmx | 2 | 87648819953a85c0abc01d3080475981 | mssql | 192.168.11.99 | wf_michelangelo | sa | mafe12345 | 1433 | utf8 | update SQL Server connection |
|
|
||||||
|
|
||||||
|
|
||||||
Scenario Outline: Delete all Database Connection created previously in this script
|
# DELETE /api/1.0/{workspace}/project/<project-id>/database-connection
|
||||||
Given database-connection with id "<dbs_uid_number>" is active
|
# Delete all DataBase Connections created in this script
|
||||||
And that I want to delete a resource with the key "dbs_uid" stored in session array as variable "dbs_uid_<dbs_uid_number>"
|
Scenario Outline: Delete all Database Connection created in this script
|
||||||
And I request "project/<project>/database-connection"
|
Given database-connection with id "<dbs_uid_number>" is active
|
||||||
Then the response status code should be 200
|
And that I want to delete a resource with the key "dbs_uid" stored in session array as variable "dbs_uid_<dbs_uid_number>"
|
||||||
And the response charset is "UTF-8"
|
And I request "project/<project>/database-connection"
|
||||||
And the type is "object"
|
Then the response status code should be 200
|
||||||
|
And the response charset is "UTF-8"
|
||||||
|
And the type is "object"
|
||||||
|
|
||||||
Examples:
|
Examples:
|
||||||
|
| project | dbs_uid_number |
|
||||||
| project | dbs_uid_number |
|
| 106912358530c9b14ac15d3001790900 | 1 |
|
||||||
| 74737540052e1641ab88249082085472 | 1 |
|
| 1265557095225ff5c688f46031700471 | 2 |
|
||||||
| 87648819953a85c0abc01d3080475981 | 2 |
|
|
||||||
|
|
||||||
|
|
||||||
Scenario Outline: Get the DataBase Connections List when there are exactly zero DataBase Connections
|
# GET /api/1.0/{workspace}/project/<project-id>/database-connection
|
||||||
Given database-connection with id "<dbs_uid_number>" is active
|
# Get DataBase Connections list
|
||||||
And I request "project/<project>/database-connections"
|
Scenario Outline: Get the DataBase Connections List when there are exactly zero DataBase Connections
|
||||||
Then the response status code should be 200
|
Given database-connection with id "<dbs_uid_number>" is active
|
||||||
And the response charset is "UTF-8"
|
And I request "project/<project>/database-connections"
|
||||||
And the response has <record> record
|
Then the response status code should be 200
|
||||||
|
And the response charset is "UTF-8"
|
||||||
|
And the response has <record> record
|
||||||
|
|
||||||
Examples:
|
Examples:
|
||||||
|
| project | record | dbs_uid_number |
|
||||||
| test_description | project | record | dbs_uid_number |
|
| 106912358530c9b14ac15d3001790900 | 0 | 1 |
|
||||||
| List DB in the process Data Base Connenctions .pm | 74737540052e1641ab88249082085472 | 0 | 1 |
|
| 1265557095225ff5c688f46031700471 | 0 | 2 |
|
||||||
| List DB in the process testExecutionOfDerivationScreen .pmx | 87648819953a85c0abc01d3080475981 | 0 | 2 |
|
|
||||||
@@ -5,8 +5,8 @@ Feature: DataBase Connections Negative Tests
|
|||||||
Given that I have a valid access_token
|
Given that I have a valid access_token
|
||||||
|
|
||||||
Scenario Outline: Test database connection to test
|
Scenario Outline: Test database connection to test
|
||||||
Given POST this data:
|
Given POST this data:
|
||||||
"""
|
"""
|
||||||
{
|
{
|
||||||
"dbs_type": "<dbs_type>",
|
"dbs_type": "<dbs_type>",
|
||||||
"dbs_server": "<dbs_server>",
|
"dbs_server": "<dbs_server>",
|
||||||
@@ -18,35 +18,38 @@ Feature: DataBase Connections Negative Tests
|
|||||||
"dbs_description": "<dbs_description>"
|
"dbs_description": "<dbs_description>"
|
||||||
}
|
}
|
||||||
"""
|
"""
|
||||||
And I request "project/<project>/database-connection"
|
And I request "project/<project>/database-connection"
|
||||||
Then the response status code should be <error_code>
|
Then the response status code should be <error_code>
|
||||||
And the response status message should have the following text "<error_message>"
|
And the response status message should have the following text "<error_message>"
|
||||||
|
|
||||||
|
Examples:
|
||||||
|
| test_description | project | dbs_type | dbs_server | dbs_database_name | dbs_username | dbs_password | dbs_port | dbs_encode | dbs_description | error_code | error_message |
|
||||||
|
| Field required dbs_type | 74737540052e1641ab88249082085472 | | <mys_db_server> | <mys_db_name> | <mys_db_username> | <mys_db_password> | <mys_db_port> | <mys_db_encode> | mysql connection | 400 | dbs_type |
|
||||||
|
| Field required dbs_server | 74737540052e1641ab88249082085472 | <mys_db_type> | | <mys_db_name> | <mys_db_username> | <mys_db_password> | <mys_db_port> | <mys_db_encode> | mysql connection | 400 | dbs_server |
|
||||||
|
| Field required dbs_database_name | 74737540052e1641ab88249082085472 | <mys_db_type> | <mys_db_server> | | <mys_db_username> | <mys_db_password> | <mys_db_port> | <mys_db_encode> | mysql connection | 400 | dbs_database_name |
|
||||||
|
| Field required dbs_encode | 74737540052e1641ab88249082085472 | <mys_db_type> | <mys_db_server> | <mys_db_name> | <mys_db_username> | <mys_db_password> | <mys_db_port> | | mysql connection | 400 | dbs_encode |
|
||||||
|
| Field required project | | <mys_db_type> | <mys_db_server> | <mys_db_name> | <mys_db_username> | <mys_db_password> | <mys_db_port> | <mys_db_encode> | mysql connection | 400 | prj_uid |
|
||||||
|
|
||||||
|
|
||||||
Examples:
|
Scenario Outline: Test database connection to test with parameter wrong port
|
||||||
|
Given POST this data:
|
||||||
| test_description | project | dbs_type | dbs_server | dbs_database_name | dbs_username | dbs_password | dbs_encode | dbs_description | error_code | error_message |
|
"""
|
||||||
| Field required dbs_type | 74737540052e1641ab88249082085472 | | michelangelo-be.colosa.net | test | testuser | sample | utf8 | mysql connection | 400 | dbs_type |
|
{
|
||||||
| Field required dbs_server | 74737540052e1641ab88249082085472 | mysql | | test | testuser | sample | utf8 | mysql connection | 400 | dbs_server |
|
"dbs_type": "<dbs_type>",
|
||||||
| Field required dbs_database_name | 74737540052e1641ab88249082085472 | mysql | michelangelo-be.colosa.net | | testuser | sample | utf8 | mysql connection | 400 | dbs_database_name |
|
"dbs_server": "<dbs_server>",
|
||||||
| Field required dbs_encode | 74737540052e1641ab88249082085472 | mysql | michelangelo-be.colosa.net | test | testuser | sample | | mysql connection | 400 | dbs_encode |
|
"dbs_database_name": "<dbs_database_name>",
|
||||||
| Field required project | | mysql | michelangelo-be.colosa.net | test | testuser | sample | utf8 | mysql connection | 400 | prj_uid |
|
"dbs_username": "<dbs_username>",
|
||||||
|
"dbs_password": "<dbs_password>",
|
||||||
|
"dbs_port": <dbs_port>,
|
||||||
Scenario: Test database connection to test with parameter wrong port
|
"dbs_encode": "<dbs_encode>",
|
||||||
Given POST this data:
|
"dbs_description": "<dbs_description>"
|
||||||
"""
|
|
||||||
{
|
|
||||||
"dbs_type": "mysql",
|
|
||||||
"dbs_server": "michelangelo-be.colosa.net",
|
|
||||||
"dbs_database_name": "test",
|
|
||||||
"dbs_username": "testuser",
|
|
||||||
"dbs_password": "sample",
|
|
||||||
"dbs_port": 10000,
|
|
||||||
"dbs_encode": "utf8",
|
|
||||||
"dbs_description": "mysql connection"
|
|
||||||
}
|
}
|
||||||
"""
|
"""
|
||||||
And I request "project/74737540052e1641ab88249082085472/database-connection"
|
And I request "project/74737540052e1641ab88249082085472/database-connection"
|
||||||
Then the response status code should be 400
|
Then the response status code should be 400
|
||||||
And the response status message should have the following text "port"
|
And the response status message should have the following text "port"
|
||||||
|
|
||||||
|
Examples:
|
||||||
|
| dbs_type | dbs_server | dbs_database_name | dbs_username | dbs_password | dbs_port | dbs_encode | dbs_description |
|
||||||
|
| <mys_db_type> | <mys_db_server> | <mys_db_name> | <mys_db_username> | <mys_db_password> | <mys_db_port> | <mys_db_encode> | <mys_db_description> |
|
||||||
|
| <mys_db_type> | <mys_db_server> | <mys_db_name> | <mys_db_username> | <mys_db_password> | <mys_db_port> | <mys_db_encode> | <mys_db_description> |
|
||||||
@@ -19,7 +19,6 @@ global $config;
|
|||||||
|
|
||||||
class RestContext extends BehatContext
|
class RestContext extends BehatContext
|
||||||
{
|
{
|
||||||
|
|
||||||
private $_startTime = null;
|
private $_startTime = null;
|
||||||
private $_restObject = null;
|
private $_restObject = null;
|
||||||
private $_headers = array();
|
private $_headers = array();
|
||||||
@@ -56,16 +55,16 @@ class RestContext extends BehatContext
|
|||||||
$this->_client
|
$this->_client
|
||||||
->getEventDispatcher()
|
->getEventDispatcher()
|
||||||
->addListener('request.error',
|
->addListener('request.error',
|
||||||
function (\Guzzle\Common\Event $event) {
|
function (\Guzzle\Common\Event $event) {
|
||||||
switch ($event['response']->getStatusCode()) {
|
switch ($event['response']->getStatusCode()) {
|
||||||
case 400:
|
case 400:
|
||||||
case 401:
|
case 401:
|
||||||
case 404:
|
case 404:
|
||||||
case 405:
|
case 405:
|
||||||
case 406:
|
case 406:
|
||||||
$event->stopPropagation();
|
$event->stopPropagation();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
$timezone = ini_get('date.timezone');
|
$timezone = ini_get('date.timezone');
|
||||||
if (empty($timezone)) {
|
if (empty($timezone)) {
|
||||||
date_default_timezone_set('UTC');
|
date_default_timezone_set('UTC');
|
||||||
@@ -316,11 +315,12 @@ class RestContext extends BehatContext
|
|||||||
$this->_headers['Content-Type'] = 'application/json; charset=utf-8';
|
$this->_headers['Content-Type'] = 'application/json; charset=utf-8';
|
||||||
$this->_requestBody = json_encode(
|
$this->_requestBody = json_encode(
|
||||||
is_object($this->_restObject)
|
is_object($this->_restObject)
|
||||||
? (array)$this->_restObject
|
? (array)$this->_restObject
|
||||||
: $this->_restObject
|
: $this->_restObject
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// BACKGROUND STEPS
|
||||||
/**
|
/**
|
||||||
* @Given /^that I have a valid access_token$/
|
* @Given /^that I have a valid access_token$/
|
||||||
*/
|
*/
|
||||||
@@ -382,8 +382,8 @@ class RestContext extends BehatContext
|
|||||||
: $this->_restObject;
|
: $this->_restObject;
|
||||||
$this->_request = $this->_client
|
$this->_request = $this->_client
|
||||||
->post($url, $this->_headers,
|
->post($url, $this->_headers,
|
||||||
(empty($this->_requestBody) ? $postFields :
|
(empty($this->_requestBody) ? $postFields :
|
||||||
$this->_requestBody));
|
$this->_requestBody));
|
||||||
$this->_response = $this->_request->send();
|
$this->_response = $this->_request->send();
|
||||||
break;
|
break;
|
||||||
case 'PUT' :
|
case 'PUT' :
|
||||||
@@ -397,8 +397,8 @@ class RestContext extends BehatContext
|
|||||||
$this->printDebug("URL F: $url\n");
|
$this->printDebug("URL F: $url\n");
|
||||||
$this->_request = $this->_client
|
$this->_request = $this->_client
|
||||||
->put($url, $this->_headers,
|
->put($url, $this->_headers,
|
||||||
(empty($this->_requestBody) ? $putFields :
|
(empty($this->_requestBody) ? $putFields :
|
||||||
$this->_requestBody));
|
$this->_requestBody));
|
||||||
$this->_response = $this->_request->send();
|
$this->_response = $this->_request->send();
|
||||||
break;
|
break;
|
||||||
case 'PATCH' :
|
case 'PATCH' :
|
||||||
@@ -407,8 +407,8 @@ class RestContext extends BehatContext
|
|||||||
: $this->_restObject;
|
: $this->_restObject;
|
||||||
$this->_request = $this->_client
|
$this->_request = $this->_client
|
||||||
->patch($url, $this->_headers,
|
->patch($url, $this->_headers,
|
||||||
(empty($this->_requestBody) ? $putFields :
|
(empty($this->_requestBody) ? $putFields :
|
||||||
$this->_requestBody));
|
$this->_requestBody));
|
||||||
$this->_response = $this->_request->send();
|
$this->_response = $this->_request->send();
|
||||||
break;
|
break;
|
||||||
case 'DELETE':
|
case 'DELETE':
|
||||||
@@ -946,7 +946,7 @@ class RestContext extends BehatContext
|
|||||||
public function theResponseStatusCodeShouldBe($httpStatus)
|
public function theResponseStatusCodeShouldBe($httpStatus)
|
||||||
{
|
{
|
||||||
if(!(isset($this->_response))){
|
if(!(isset($this->_response))){
|
||||||
throw new \Exception('HTTP code does not match ' . $httpStatus .
|
throw new \Exception('HTTP code does not match ' . $httpStatus .
|
||||||
' (actual: No response defined)'
|
' (actual: No response defined)'
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -998,6 +998,19 @@ class RestContext extends BehatContext
|
|||||||
*/
|
*/
|
||||||
public function postThisData(PyStringNode $string)
|
public function postThisData(PyStringNode $string)
|
||||||
{
|
{
|
||||||
|
/*
|
||||||
|
* Overwrite the $this->_requestBody = $string; line in order to replace line by line with test data.
|
||||||
|
* */
|
||||||
|
$linesValues = array();
|
||||||
|
foreach ($string->getLines() as $line) {
|
||||||
|
foreach ($this->_parameters as $param => $value) {
|
||||||
|
$line = str_replace('<'.$param.'>', $value, $line);
|
||||||
|
}
|
||||||
|
$linesValues[] = $line;
|
||||||
|
}
|
||||||
|
$string->setLines($linesValues);
|
||||||
|
|
||||||
|
|
||||||
$this->_restObjectMethod = 'post';
|
$this->_restObjectMethod = 'post';
|
||||||
$this->_headers['Content-Type'] = 'application/json; charset=UTF-8';
|
$this->_headers['Content-Type'] = 'application/json; charset=UTF-8';
|
||||||
$this->_requestBody = $string;
|
$this->_requestBody = $string;
|
||||||
@@ -1008,6 +1021,19 @@ class RestContext extends BehatContext
|
|||||||
*/
|
*/
|
||||||
public function putThisData(PyStringNode $string)
|
public function putThisData(PyStringNode $string)
|
||||||
{
|
{
|
||||||
|
/*
|
||||||
|
* Overwrite the $this->_requestBody = $string; line in order to replace line by line with test data.
|
||||||
|
* */
|
||||||
|
$linesValues = array();
|
||||||
|
foreach ($string->getLines() as $line) {
|
||||||
|
foreach ($this->_parameters as $param => $value) {
|
||||||
|
$line = str_replace('<'.$param.'>', $value, $line);
|
||||||
|
}
|
||||||
|
$linesValues[] = $line;
|
||||||
|
}
|
||||||
|
$string->setLines($linesValues);
|
||||||
|
|
||||||
|
|
||||||
$this->_restObjectMethod = 'put';
|
$this->_restObjectMethod = 'put';
|
||||||
$this->_headers['Content-Type'] = 'application/json; charset=UTF-8';
|
$this->_headers['Content-Type'] = 'application/json; charset=UTF-8';
|
||||||
$this->_requestBody = $string;
|
$this->_requestBody = $string;
|
||||||
@@ -1016,7 +1042,7 @@ class RestContext extends BehatContext
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @Given /^I want to Insert a new "([^"]*)" with:$/
|
* @Given /^I want to Insert a new "([^"]*)" with:$/
|
||||||
*/
|
*/
|
||||||
public function iWantToInsertANewWith($url, PyStringNode $string)
|
public function iWantToInsertANewWith($url, PyStringNode $string)
|
||||||
@@ -1084,49 +1110,49 @@ class RestContext extends BehatContext
|
|||||||
//*********** WEN
|
//*********** WEN
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @Given /^POST data from file "([^"]*)"$/
|
* @Given /^POST data from file "([^"]*)"$/
|
||||||
*/
|
*/
|
||||||
public function postDataFromFile($jsonFile)
|
public function postDataFromFile($jsonFile)
|
||||||
{
|
{
|
||||||
$filePath = __DIR__ . "/../json/" . $jsonFile;
|
$filePath = __DIR__ . "/../json/" . $jsonFile;
|
||||||
|
|
||||||
if(file_exists($filePath))
|
if(file_exists($filePath))
|
||||||
{
|
{
|
||||||
$fileData = file_get_contents($filePath);
|
$fileData = file_get_contents($filePath);
|
||||||
$this->postThisData(new PyStringNode($fileData));
|
$this->postThisData(new PyStringNode($fileData));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
throw new \Exception("JSON File: $filePath not found\n\n" );
|
throw new \Exception("JSON File: $filePath not found\n\n" );
|
||||||
}
|
}
|
||||||
// throw new PendingException();
|
// throw new PendingException();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @Given /^PUT data from file "([^"]*)"$/
|
* @Given /^PUT data from file "([^"]*)"$/
|
||||||
*/
|
*/
|
||||||
public function putDataFromFile($jsonFile)
|
public function putDataFromFile($jsonFile)
|
||||||
{
|
{
|
||||||
$filePath = __DIR__ . "/../json/" . $jsonFile;
|
$filePath = __DIR__ . "/../json/" . $jsonFile;
|
||||||
|
|
||||||
if(file_exists($filePath))
|
if(file_exists($filePath))
|
||||||
{
|
{
|
||||||
$fileData = file_get_contents($filePath);
|
$fileData = file_get_contents($filePath);
|
||||||
$this->putThisData(new PyStringNode($fileData));
|
$this->putThisData(new PyStringNode($fileData));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
throw new \Exception("JSON File: $filePath not found\n\n" );
|
throw new \Exception("JSON File: $filePath not found\n\n" );
|
||||||
}
|
}
|
||||||
// throw new PendingException();
|
// throw new PendingException();
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* @Given /^This scenario is not implemented yet$/
|
* @Given /^This scenario is not implemented yet$/
|
||||||
* @Given /^this scenario is not implemented yet$/
|
* @Given /^this scenario is not implemented yet$/
|
||||||
*/
|
*/
|
||||||
public function thisScenarioIsNotImplementedYet()
|
public function thisScenarioIsNotImplementedYet()
|
||||||
{
|
{
|
||||||
throw new PendingException();
|
throw new PendingException();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -1187,13 +1213,13 @@ class RestContext extends BehatContext
|
|||||||
$this->_restObjectMethod = 'put';
|
$this->_restObjectMethod = 'put';
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @Given /^that I want to get a resource with the key "([^"]*)" stored in session array as variable "([^"]*)"$/
|
* @Given /^that I want to get a resource with the key "([^"]*)" stored in session array as variable "([^"]*)"$/
|
||||||
* @Given /^that I want to get a resource with the key "([^"]*)" stored in session array as variable "([^"]*)" in position (\d+)$/
|
* @Given /^that I want to get a resource with the key "([^"]*)" stored in session array as variable "([^"]*)" in position (\d+)$/
|
||||||
*/
|
*/
|
||||||
public function thatIWantToGetAResourceWithTheKeyStoredInSessionArrayAsVariable($varName, $sessionVarName, $position=null)
|
public function thatIWantToGetAResourceWithTheKeyStoredInSessionArrayAsVariable($varName, $sessionVarName, $position=null)
|
||||||
{
|
{
|
||||||
if (file_exists("session.data")) {
|
if (file_exists("session.data")) {
|
||||||
$sessionData = json_decode(file_get_contents("session.data"));
|
$sessionData = json_decode(file_get_contents("session.data"));
|
||||||
} else {
|
} else {
|
||||||
$sessionData = array();
|
$sessionData = array();
|
||||||
@@ -1244,7 +1270,7 @@ class RestContext extends BehatContext
|
|||||||
$this->_restObjectMethod = 'delete';
|
$this->_restObjectMethod = 'delete';
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @Given /^the response status message should have the following text "([^"]*)"$/
|
* @Given /^the response status message should have the following text "([^"]*)"$/
|
||||||
*/
|
*/
|
||||||
public function theResponseStatusMessageShouldHaveTheFollowingText($arg1)
|
public function theResponseStatusMessageShouldHaveTheFollowingText($arg1)
|
||||||
@@ -1288,7 +1314,7 @@ class RestContext extends BehatContext
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @Given /^I request "([^"]*)" with the key "([^"]*)" stored in session array as variable "([^"]*)"$/
|
* @Given /^I request "([^"]*)" with the key "([^"]*)" stored in session array as variable "([^"]*)"$/
|
||||||
* @Given /^I request "([^"]*)" with the key "([^"]*)" stored in session array as variable "([^"]*)" and url is "([^"]*)"$/
|
* @Given /^I request "([^"]*)" with the key "([^"]*)" stored in session array as variable "([^"]*)" and url is "([^"]*)"$/
|
||||||
* @Given /^I request "([^"]*)" with the key "([^"]*)" stored in session array as variable "([^"]*)"$/
|
* @Given /^I request "([^"]*)" with the key "([^"]*)" stored in session array as variable "([^"]*)"$/
|
||||||
@@ -1349,7 +1375,7 @@ class RestContext extends BehatContext
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @Given /^the property "([^"]*)" of "([^"]*)" is set to "([^"]*)"$/
|
* @Given /^the property "([^"]*)" of "([^"]*)" is set to "([^"]*)"$/
|
||||||
*/
|
*/
|
||||||
public function thePropertyOfIsSetTo($propertyName, $objName, $propertyValue)
|
public function thePropertyOfIsSetTo($propertyName, $objName, $propertyValue)
|
||||||
@@ -1400,8 +1426,8 @@ class RestContext extends BehatContext
|
|||||||
|
|
||||||
//UPLOAD FILE MANAGER
|
//UPLOAD FILE MANAGER
|
||||||
/**
|
/**
|
||||||
* @Given /^POST I want to upload the file "([^"]*)" to path "([^"]*)". Url "([^"]*)"$/
|
* @Given /^POST I want to upload the file "([^"]*)" to path "([^"]*)". Url "([^"]*)"$/
|
||||||
*/
|
*/
|
||||||
public function postIWantToUploadTheFileToPathPublicUrl($prfFile, $prfPath, $url)
|
public function postIWantToUploadTheFileToPathPublicUrl($prfFile, $prfPath, $url)
|
||||||
{
|
{
|
||||||
$prfFile = $this->getParameter('uploadFilesFolder') . $prfFile;
|
$prfFile = $this->getParameter('uploadFilesFolder') . $prfFile;
|
||||||
@@ -1433,14 +1459,14 @@ class RestContext extends BehatContext
|
|||||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
|
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
|
||||||
$postResult = curl_exec($ch);
|
$postResult = curl_exec($ch);
|
||||||
curl_close($ch);
|
curl_close($ch);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//UPLOAD IMAGE
|
//UPLOAD IMAGE
|
||||||
/**
|
/**
|
||||||
* @Given /^POST I want to upload the image "([^"]*)" to user "([^"]*)". Url "([^"]*)"$/
|
* @Given /^POST I want to upload the image "([^"]*)" to user "([^"]*)". Url "([^"]*)"$/
|
||||||
*/
|
*/
|
||||||
public function postIWantToUploadTheImageToUser($imageFile, $usrUid, $url)
|
public function postIWantToUploadTheImageToUser($imageFile, $usrUid, $url)
|
||||||
{
|
{
|
||||||
$imageFile = $this->getParameter('uploadFilesFolder') . $imageFile;
|
$imageFile = $this->getParameter('uploadFilesFolder') . $imageFile;
|
||||||
@@ -1458,17 +1484,17 @@ class RestContext extends BehatContext
|
|||||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
|
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
|
||||||
$postResult = curl_exec($ch);
|
$postResult = curl_exec($ch);
|
||||||
|
|
||||||
if( $postResult === false)
|
if( $postResult === false)
|
||||||
{
|
{
|
||||||
//trigger_error(curl_error($ch));
|
//trigger_error(curl_error($ch));
|
||||||
throw new Exception("Image upload failed ($imageFile):\n\n"
|
throw new Exception("Image upload failed ($imageFile):\n\n"
|
||||||
. curl_error($ch));
|
. curl_error($ch));
|
||||||
}
|
}
|
||||||
curl_close($ch);
|
curl_close($ch);
|
||||||
echo $postResult;
|
echo $postResult;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @Given /^POST I want to upload the image "([^"]*)" to user with the key "([^"]*)" stored in session array as variable "([^"]*)"\. Url "([^"]*)"$/
|
* @Given /^POST I want to upload the image "([^"]*)" to user with the key "([^"]*)" stored in session array as variable "([^"]*)"\. Url "([^"]*)"$/
|
||||||
*/
|
*/
|
||||||
public function postIWantToUploadTheImageToUserWithTheKeyStoredInSessionArrayAsVariableUsrUidUrl($imageFile, $varName, $sessionVarName, $url)
|
public function postIWantToUploadTheImageToUserWithTheKeyStoredInSessionArrayAsVariableUsrUidUrl($imageFile, $varName, $sessionVarName, $url)
|
||||||
@@ -1498,7 +1524,7 @@ class RestContext extends BehatContext
|
|||||||
$this->_restObjectMethod = 'delete';
|
$this->_restObjectMethod = 'delete';
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @Given /^store response count in session variable as "([^"]*)"$/
|
* @Given /^store response count in session variable as "([^"]*)"$/
|
||||||
*/
|
*/
|
||||||
public function storeResponseCountInSessionVariableAs($varName)
|
public function storeResponseCountInSessionVariableAs($varName)
|
||||||
@@ -1537,7 +1563,7 @@ class RestContext extends BehatContext
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @Given /^POST upload an input document "([^"]*)" to "([^"]*)"$/
|
* @Given /^POST upload an input document "([^"]*)" to "([^"]*)"$/
|
||||||
*/
|
*/
|
||||||
public function postUploadAnInputDocumentTo($file, $url, PyStringNode $string)
|
public function postUploadAnInputDocumentTo($file, $url, PyStringNode $string)
|
||||||
@@ -1617,7 +1643,7 @@ class RestContext extends BehatContext
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @Given /^store "([^"]*)" in session array as variable "([^"]*)" where an object has "([^"]*)" equal to "([^"]*)"$/
|
* @Given /^store "([^"]*)" in session array as variable "([^"]*)" where an object has "([^"]*)" equal to "([^"]*)"$/
|
||||||
*/
|
*/
|
||||||
public function storeInSessionArrayAsVariableWhereAnObjectHasEqualsTo($varName, $sessionVarName, $objectProperty, $objectValue)
|
public function storeInSessionArrayAsVariableWhereAnObjectHasEqualsTo($varName, $sessionVarName, $objectProperty, $objectValue)
|
||||||
@@ -1625,12 +1651,12 @@ class RestContext extends BehatContext
|
|||||||
|
|
||||||
$swFound=false;
|
$swFound=false;
|
||||||
if (file_exists("session.data")) {
|
if (file_exists("session.data")) {
|
||||||
$sessionData = json_decode(file_get_contents("session.data"));
|
$sessionData = json_decode(file_get_contents("session.data"));
|
||||||
} else {
|
} else {
|
||||||
$sessionData = new StdClass();
|
$sessionData = new StdClass();
|
||||||
}
|
}
|
||||||
|
|
||||||
$sessionData->$sessionVarName = array();
|
$sessionData->$sessionVarName = array();
|
||||||
|
|
||||||
|
|
||||||
foreach($this->_data as $obj){
|
foreach($this->_data as $obj){
|
||||||
@@ -1650,7 +1676,7 @@ class RestContext extends BehatContext
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @Given /^that "([^"]*)" property in object "([^"]*)" equals "([^"]*)"$/
|
* @Given /^that "([^"]*)" property in object "([^"]*)" equals "([^"]*)"$/
|
||||||
*/
|
*/
|
||||||
public function thatPropertyInObjectEquals($propertyName, $propertyParent, $value)
|
public function thatPropertyInObjectEquals($propertyName, $propertyParent, $value)
|
||||||
@@ -1696,7 +1722,7 @@ class RestContext extends BehatContext
|
|||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* @Given /^save exported process to "([^"]*)"$/
|
* @Given /^save exported process to "([^"]*)"$/
|
||||||
* @Given /^save exported process to "([^"]*)" as "([^"]*)"$/
|
* @Given /^save exported process to "([^"]*)" as "([^"]*)"$/
|
||||||
*/
|
*/
|
||||||
@@ -1722,7 +1748,7 @@ class RestContext extends BehatContext
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @Given /^POST a dynaform:$/
|
* @Given /^POST a dynaform:$/
|
||||||
*/
|
*/
|
||||||
public function postADynaform(PyStringNode $string)
|
public function postADynaform(PyStringNode $string)
|
||||||
@@ -1775,17 +1801,17 @@ class RestContext extends BehatContext
|
|||||||
$fp = fopen(sys_get_temp_dir() . "/behat.log", "a+");
|
$fp = fopen(sys_get_temp_dir() . "/behat.log", "a+");
|
||||||
fwrite($fp, $string . PHP_EOL);
|
fwrite($fp, $string . PHP_EOL);
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* @Then /^if database-connection with id "([^"]*)" is active$/
|
* @Then /^if database-connection with id "([^"]*)" is active$/
|
||||||
*/
|
*/
|
||||||
public function ifDatabaseConnectionWithIdIsActive($dbConnectionId)
|
public function ifDatabaseConnectionWithIdIsActive($dbConnectionId)
|
||||||
{
|
{
|
||||||
if(!(isset($this->_response))){
|
if(!(isset($this->_response))){
|
||||||
throw new \Exception('Empty result ' );
|
throw new \Exception('Empty result ' );
|
||||||
}
|
}
|
||||||
$message="";
|
$message="";
|
||||||
$sw_error=false;
|
$sw_error=false;
|
||||||
if($bodyResponse=json_decode($this->_response->getBody(true))){
|
if($bodyResponse=json_decode($this->_response->getBody(true))){
|
||||||
//print_r($bodyResponse);
|
//print_r($bodyResponse);
|
||||||
foreach($bodyResponse as $testDetail){
|
foreach($bodyResponse as $testDetail){
|
||||||
$message.=$testDetail->test;
|
$message.=$testDetail->test;
|
||||||
@@ -1798,22 +1824,21 @@ class RestContext extends BehatContext
|
|||||||
$message.=" | ";
|
$message.=" | ";
|
||||||
}
|
}
|
||||||
|
|
||||||
}else{
|
}else{
|
||||||
throw new \Exception('Empty result ' );
|
throw new \Exception('Empty result ' );
|
||||||
}
|
}
|
||||||
|
|
||||||
if (file_exists("session.data")) {
|
|
||||||
$sessionData = json_decode(file_get_contents("session.data"));
|
|
||||||
} else {
|
|
||||||
$sessionData = new StdClass();
|
|
||||||
}
|
|
||||||
if(!isset($sessionData->dbconnectionStatus)){
|
|
||||||
$sessionData->dbconnectionStatus = new StdClass();
|
|
||||||
}
|
|
||||||
$sessionData->dbconnectionStatus->$dbConnectionId = !$sw_error;
|
|
||||||
file_put_contents("session.data", json_encode($sessionData));
|
|
||||||
if($sw_error){
|
|
||||||
|
|
||||||
|
if (file_exists("session.data")) {
|
||||||
|
$sessionData = json_decode(file_get_contents("session.data"));
|
||||||
|
} else {
|
||||||
|
$sessionData = new StdClass();
|
||||||
|
}
|
||||||
|
if(!isset($sessionData->dbconnectionStatus)){
|
||||||
|
$sessionData->dbconnectionStatus = new StdClass();
|
||||||
|
}
|
||||||
|
$sessionData->dbconnectionStatus->$dbConnectionId = !$sw_error;
|
||||||
|
file_put_contents("session.data", json_encode($sessionData));
|
||||||
|
if($sw_error){
|
||||||
throw new PendingException($message);
|
throw new PendingException($message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1822,19 +1847,18 @@ class RestContext extends BehatContext
|
|||||||
*/
|
*/
|
||||||
public function databaseConnectionWithIdIsActive($dbConnectionId)
|
public function databaseConnectionWithIdIsActive($dbConnectionId)
|
||||||
{
|
{
|
||||||
if (file_exists("session.data")) {
|
/* if (file_exists("session.data")) {
|
||||||
$sessionData = json_decode(file_get_contents("session.data"));
|
$sessionData = json_decode(file_get_contents("session.data"));
|
||||||
} else {
|
} else {
|
||||||
$sessionData = new StdClass();
|
$sessionData = new StdClass();
|
||||||
}
|
}*/
|
||||||
|
|
||||||
if(!$sessionData->dbconnectionStatus->$dbConnectionId){
|
|
||||||
|
|
||||||
|
|
||||||
|
$sessionData = new StdClass();
|
||||||
|
if(!$sessionData->dbconnectionStatus->$dbConnectionId){
|
||||||
throw new PendingException("Skip inactive dbconnection: $dbConnectionId");
|
throw new PendingException("Skip inactive dbconnection: $dbConnectionId");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* @Given /^OAUTH register an application$/
|
* @Given /^OAUTH register an application$/
|
||||||
*/
|
*/
|
||||||
public function oauthRegisterAnApplication(PyStringNode $data)
|
public function oauthRegisterAnApplication(PyStringNode $data)
|
||||||
@@ -1852,130 +1876,130 @@ class RestContext extends BehatContext
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
$ch = curl_init();
|
$ch = curl_init();
|
||||||
curl_setopt($ch, CURLOPT_URL, $authentication_url);
|
curl_setopt($ch, CURLOPT_URL, $authentication_url);
|
||||||
curl_setopt($ch, CURLOPT_REFERER, $login_url);
|
curl_setopt($ch, CURLOPT_REFERER, $login_url);
|
||||||
curl_setopt($ch, CURLOPT_USERAGENT,'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Ubuntu Chromium/32.0.1700.107 Chrome/32.0.1700.107 Safari/537.36');
|
curl_setopt($ch, CURLOPT_USERAGENT,'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Ubuntu Chromium/32.0.1700.107 Chrome/32.0.1700.107 Safari/537.36');
|
||||||
curl_setopt($ch, CURLOPT_POST, true);
|
curl_setopt($ch, CURLOPT_POST, true);
|
||||||
curl_setopt($ch, CURLOPT_POSTFIELDS, "form[USR_USERNAME]=$user_name&form[USR_PASSWORD]=$user_password&form[USER_LANG]=en&form[URL]");
|
curl_setopt($ch, CURLOPT_POSTFIELDS, "form[USR_USERNAME]=$user_name&form[USR_PASSWORD]=$user_password&form[USER_LANG]=en&form[URL]");
|
||||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
||||||
curl_setopt($ch, CURLOPT_COOKIESESSION, true);
|
curl_setopt($ch, CURLOPT_COOKIESESSION, true);
|
||||||
curl_setopt($ch, CURLOPT_COOKIEJAR, $cookie_file);
|
curl_setopt($ch, CURLOPT_COOKIEJAR, $cookie_file);
|
||||||
curl_setopt($ch, CURLOPT_COOKIEFILE, $cookie_file);
|
curl_setopt($ch, CURLOPT_COOKIEFILE, $cookie_file);
|
||||||
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
|
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
|
||||||
$answer = curl_exec($ch);
|
$answer = curl_exec($ch);
|
||||||
$newurl = curl_getinfo($ch, CURLINFO_EFFECTIVE_URL);
|
$newurl = curl_getinfo($ch, CURLINFO_EFFECTIVE_URL);
|
||||||
|
|
||||||
|
|
||||||
if (strpos($newurl, "/login/login") !== false) {
|
if (strpos($newurl, "/login/login") !== false) {
|
||||||
throw new Exception('Bad credentials');
|
throw new Exception('Bad credentials');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//print "<textarea>$answer</textarea>";
|
//print "<textarea>$answer</textarea>";
|
||||||
if (curl_error($ch)) {
|
if (curl_error($ch)) {
|
||||||
throw new Exception(curl_error($ch));
|
throw new Exception(curl_error($ch));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Read the session saved in the cookie file
|
// Read the session saved in the cookie file
|
||||||
|
|
||||||
if(!file_exists($cookie_file)){
|
if(!file_exists($cookie_file)){
|
||||||
throw new Exception('Invalid Cookie/Session: '.$cookie_file);
|
throw new Exception('Invalid Cookie/Session: '.$cookie_file);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//another request preserving the session
|
//another request preserving the session
|
||||||
|
|
||||||
$data = json_decode((string) $data);
|
$data = json_decode((string) $data);
|
||||||
|
|
||||||
$name=$data->name;
|
$name=$data->name;
|
||||||
$description=$data->description;
|
$description=$data->description;
|
||||||
$webSite = $data->webSite;
|
$webSite = $data->webSite;
|
||||||
$redirectUri=$data->redirectUri;
|
$redirectUri=$data->redirectUri;
|
||||||
$applicationNumber=$data->applicationNumber;
|
$applicationNumber=$data->applicationNumber;
|
||||||
|
|
||||||
//1. Register application
|
//1. Register application
|
||||||
curl_setopt($ch, CURLOPT_URL, $oauth_app_url);
|
curl_setopt($ch, CURLOPT_URL, $oauth_app_url);
|
||||||
curl_setopt($ch, CURLOPT_POST, true);
|
curl_setopt($ch, CURLOPT_POST, true);
|
||||||
curl_setopt($ch, CURLOPT_POSTFIELDS, "option=INS&name=$name&description=$description&webSite=$webSite&redirectUri=$redirectUri");
|
curl_setopt($ch, CURLOPT_POSTFIELDS, "option=INS&name=$name&description=$description&webSite=$webSite&redirectUri=$redirectUri");
|
||||||
$answer = curl_exec($ch);
|
$answer = curl_exec($ch);
|
||||||
if (curl_error($ch)) {
|
if (curl_error($ch)) {
|
||||||
throw new Exception(curl_error($ch));
|
throw new Exception(curl_error($ch));
|
||||||
}
|
}
|
||||||
$newurl = curl_getinfo($ch, CURLINFO_EFFECTIVE_URL);
|
$newurl = curl_getinfo($ch, CURLINFO_EFFECTIVE_URL);
|
||||||
|
|
||||||
if (strpos($newurl, "/login/login") !== false) {
|
if (strpos($newurl, "/login/login") !== false) {
|
||||||
throw new Exception('Not authenticated');
|
throw new Exception('Not authenticated');
|
||||||
}
|
}
|
||||||
// json_decode(json)
|
// json_decode(json)
|
||||||
$response=json_decode($answer);
|
$response=json_decode($answer);
|
||||||
$this->printDebug("Register application:\n".$answer."\n");
|
$this->printDebug("Register application:\n".$answer."\n");
|
||||||
$this->_restObjectMethod = 'post';
|
$this->_restObjectMethod = 'post';
|
||||||
$this->_headers['Content-Type'] = 'application/json; charset=UTF-8';
|
$this->_headers['Content-Type'] = 'application/json; charset=UTF-8';
|
||||||
$this->_response = json_decode($answer);
|
$this->_response = json_decode($answer);
|
||||||
|
|
||||||
|
|
||||||
if (file_exists("session.data")) {
|
if (file_exists("session.data")) {
|
||||||
$sessionData = json_decode(file_get_contents("session.data"));
|
$sessionData = json_decode(file_get_contents("session.data"));
|
||||||
} else {
|
} else {
|
||||||
$sessionData = new StdClass();
|
$sessionData = new StdClass();
|
||||||
}
|
}
|
||||||
foreach($response->data as $key => $varValue){
|
foreach($response->data as $key => $varValue){
|
||||||
$sessionVarName=$key."_".$applicationNumber;
|
$sessionVarName=$key."_".$applicationNumber;
|
||||||
$sessionData->$sessionVarName = $varValue;
|
$sessionData->$sessionVarName = $varValue;
|
||||||
$this->printDebug("Save $sessionVarName = $varValue");
|
$this->printDebug("Save $sessionVarName = $varValue");
|
||||||
}
|
}
|
||||||
//print_r($sessionData);
|
//print_r($sessionData);
|
||||||
|
|
||||||
$clientId = $response->data->CLIENT_ID;
|
$clientId = $response->data->CLIENT_ID;
|
||||||
$clientSecret = $response->data->CLIENT_SECRET;
|
$clientSecret = $response->data->CLIENT_SECRET;
|
||||||
|
|
||||||
//2. Request Authorization
|
//2. Request Authorization
|
||||||
curl_setopt($ch, CURLOPT_URL, $oauth_authorization_url."?"."response_type=code&client_id=$clientId&scope=*");
|
curl_setopt($ch, CURLOPT_URL, $oauth_authorization_url."?"."response_type=code&client_id=$clientId&scope=*");
|
||||||
curl_setopt($ch, CURLOPT_POST, true);
|
curl_setopt($ch, CURLOPT_POST, true);
|
||||||
curl_setopt($ch, CURLOPT_POSTFIELDS, "allow=Accept&transaction_id=");
|
curl_setopt($ch, CURLOPT_POSTFIELDS, "allow=Accept&transaction_id=");
|
||||||
//print "response_type=code&client_id=$clientId&scope=*";
|
//print "response_type=code&client_id=$clientId&scope=*";
|
||||||
$answer = curl_exec($ch);
|
$answer = curl_exec($ch);
|
||||||
if (curl_error($ch)) {
|
if (curl_error($ch)) {
|
||||||
throw new Exception(curl_error($ch));
|
throw new Exception(curl_error($ch));
|
||||||
}
|
}
|
||||||
$newurl = curl_getinfo($ch, CURLINFO_EFFECTIVE_URL);
|
$newurl = curl_getinfo($ch, CURLINFO_EFFECTIVE_URL);
|
||||||
$codeA = explode("code=",$newurl);
|
$codeA = explode("code=",$newurl);
|
||||||
|
|
||||||
$code = $codeA[1];
|
$code = $codeA[1];
|
||||||
$this->printDebug("Authorization code:\n".$code."\n");
|
$this->printDebug("Authorization code:\n".$code."\n");
|
||||||
|
|
||||||
//3. Request Token
|
//3. Request Token
|
||||||
$headr = array();
|
$headr = array();
|
||||||
$headr[] = 'Content-Type: application/json';
|
$headr[] = 'Content-Type: application/json';
|
||||||
$headr[] = 'Authorization: Basic '.base64_encode("$clientId:$clientSecret");
|
$headr[] = 'Authorization: Basic '.base64_encode("$clientId:$clientSecret");
|
||||||
|
|
||||||
curl_setopt($ch, CURLOPT_HTTPHEADER,$headr);
|
curl_setopt($ch, CURLOPT_HTTPHEADER,$headr);
|
||||||
//curl_setopt($ch, CURLOPT_HEADER, false);
|
//curl_setopt($ch, CURLOPT_HEADER, false);
|
||||||
curl_setopt($ch, CURLOPT_URL, $baseUrl."oauth2/token");
|
curl_setopt($ch, CURLOPT_URL, $baseUrl."oauth2/token");
|
||||||
//curl_setopt($ch, CURLOPT_USERPWD, "$clientId:$clientSecret");
|
//curl_setopt($ch, CURLOPT_USERPWD, "$clientId:$clientSecret");
|
||||||
curl_setopt($ch, CURLOPT_POST, true);
|
curl_setopt($ch, CURLOPT_POST, true);
|
||||||
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode(array("grant_type"=>"authorization_code","code"=>$code)));
|
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode(array("grant_type"=>"authorization_code","code"=>$code)));
|
||||||
|
|
||||||
$answer = curl_exec($ch);
|
$answer = curl_exec($ch);
|
||||||
if (curl_error($ch)) {
|
if (curl_error($ch)) {
|
||||||
throw new Exception(curl_error($ch));
|
throw new Exception(curl_error($ch));
|
||||||
}
|
}
|
||||||
$newurl = curl_getinfo($ch, CURLINFO_EFFECTIVE_URL);
|
$newurl = curl_getinfo($ch, CURLINFO_EFFECTIVE_URL);
|
||||||
$this->printDebug("Request token:\n".$answer."\n");
|
$this->printDebug("Request token:\n".$answer."\n");
|
||||||
//print_r("Request token:\n".$newurl."\n");
|
//print_r("Request token:\n".$newurl."\n");
|
||||||
foreach(json_decode($answer) as $key => $varValue){
|
foreach(json_decode($answer) as $key => $varValue){
|
||||||
$sessionVarName=$key."_".$applicationNumber;
|
$sessionVarName=$key."_".$applicationNumber;
|
||||||
$sessionData->$sessionVarName = $varValue;
|
$sessionData->$sessionVarName = $varValue;
|
||||||
$this->printDebug("Save $sessionVarName = $varValue");
|
$this->printDebug("Save $sessionVarName = $varValue");
|
||||||
}
|
}
|
||||||
file_put_contents("session.data", json_encode($sessionData));
|
file_put_contents("session.data", json_encode($sessionData));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @Given /^I request a owner password credential grant$/
|
* @Given /^I request a owner password credential grant$/
|
||||||
*/
|
*/
|
||||||
public function iRequestAOwnerPasswordCredentialGrant()
|
public function iRequestAOwnerPasswordCredentialGrant()
|
||||||
@@ -1995,7 +2019,7 @@ file_put_contents("session.data", json_encode($sessionData));
|
|||||||
throw new Exception($this->_data->error." : ".$this->_data->error_description);
|
throw new Exception($this->_data->error." : ".$this->_data->error_description);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* @Given /^I request a client credential grant$/
|
* @Given /^I request a client credential grant$/
|
||||||
*/
|
*/
|
||||||
public function iRequestAClientCredentialGrant()
|
public function iRequestAClientCredentialGrant()
|
||||||
@@ -2015,7 +2039,7 @@ file_put_contents("session.data", json_encode($sessionData));
|
|||||||
throw new Exception($this->_data->error." : ".$this->_data->error_description);
|
throw new Exception($this->_data->error." : ".$this->_data->error_description);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* @Given /^I request a refresh token for "([^"]*)"$/
|
* @Given /^I request a refresh token for "([^"]*)"$/
|
||||||
*/
|
*/
|
||||||
public function iRequestARefreshToken($refreshTokenSession)
|
public function iRequestARefreshToken($refreshTokenSession)
|
||||||
@@ -2048,7 +2072,7 @@ file_put_contents("session.data", json_encode($sessionData));
|
|||||||
$headr['Authorization'] = 'Basic '.base64_encode("$clientId:$clientSecret");
|
$headr['Authorization'] = 'Basic '.base64_encode("$clientId:$clientSecret");
|
||||||
$request['refresh_token']=$varValue;
|
$request['refresh_token']=$varValue;
|
||||||
$this->_requestBody=json_encode($request);
|
$this->_requestBody=json_encode($request);
|
||||||
print_r($this->_requestBody);
|
print_r($this->_requestBody);
|
||||||
$this->iRequest($baseUrl."oauth2/token", "absolute", $headr);
|
$this->iRequest($baseUrl."oauth2/token", "absolute", $headr);
|
||||||
print_r($this->_data);
|
print_r($this->_data);
|
||||||
if(isset($this->_data->error)){
|
if(isset($this->_data->error)){
|
||||||
@@ -2056,7 +2080,7 @@ print_r($this->_requestBody);
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @Given /^OAUTH request implicit grant$/
|
* @Given /^OAUTH request implicit grant$/
|
||||||
*/
|
*/
|
||||||
public function oauthRequestImplicitGrant(PyStringNode $data)
|
public function oauthRequestImplicitGrant(PyStringNode $data)
|
||||||
@@ -2090,7 +2114,7 @@ print_r($this->_requestBody);
|
|||||||
|
|
||||||
//print_r($newurl);
|
//print_r($newurl);
|
||||||
if (strpos($newurl, "/login/login") !== false) {
|
if (strpos($newurl, "/login/login") !== false) {
|
||||||
throw new Exception('Bad credentials');
|
throw new Exception('Bad credentials');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -2113,7 +2137,7 @@ print_r($this->_requestBody);
|
|||||||
$response_type=$data->response_type;
|
$response_type=$data->response_type;
|
||||||
$client_id=$data->client_id;
|
$client_id=$data->client_id;
|
||||||
$scope = $data->scope;
|
$scope = $data->scope;
|
||||||
$implicit_grant_number = $data->implicit_grant_number;
|
$implicit_grant_number = $data->implicit_grant_number;
|
||||||
|
|
||||||
|
|
||||||
//1. Register application
|
//1. Register application
|
||||||
@@ -2129,26 +2153,26 @@ print_r($this->_requestBody);
|
|||||||
|
|
||||||
|
|
||||||
if (strpos($newurl, "/login/login") !== false) {
|
if (strpos($newurl, "/login/login") !== false) {
|
||||||
throw new Exception('Not authenticated');
|
throw new Exception('Not authenticated');
|
||||||
}
|
}
|
||||||
$parts = parse_url($newurl);
|
$parts = parse_url($newurl);
|
||||||
|
|
||||||
parse_str($parts['fragment'], $fragment);
|
parse_str($parts['fragment'], $fragment);
|
||||||
//print_r($fragment);
|
//print_r($fragment);
|
||||||
// json_decode(json)
|
// json_decode(json)
|
||||||
$response=json_decode($answer);
|
$response=json_decode($answer);
|
||||||
|
|
||||||
if (file_exists("session.data")) {
|
if (file_exists("session.data")) {
|
||||||
$sessionData = json_decode(file_get_contents("session.data"));
|
$sessionData = json_decode(file_get_contents("session.data"));
|
||||||
} else {
|
} else {
|
||||||
$sessionData = new StdClass();
|
$sessionData = new StdClass();
|
||||||
}
|
}
|
||||||
foreach($fragment as $key => $varValue){
|
foreach($fragment as $key => $varValue){
|
||||||
$sessionVarName=$key."_".$implicit_grant_number;
|
$sessionVarName=$key."_".$implicit_grant_number;
|
||||||
$sessionData->$sessionVarName = $varValue;
|
$sessionData->$sessionVarName = $varValue;
|
||||||
}
|
}
|
||||||
//print_r($sessionData);
|
//print_r($sessionData);
|
||||||
file_put_contents("session.data", json_encode($sessionData));
|
file_put_contents("session.data", json_encode($sessionData));
|
||||||
//print_r("\nRegister application:\n".$answer."\n$oauth_authorization_url?response_type=$response_type&client_id=$client_id&scope=$scope\n");
|
//print_r("\nRegister application:\n".$answer."\n$oauth_authorization_url?response_type=$response_type&client_id=$client_id&scope=$scope\n");
|
||||||
//print_r($newurl);
|
//print_r($newurl);
|
||||||
$this->_restObjectMethod = 'post';
|
$this->_restObjectMethod = 'post';
|
||||||
@@ -2158,7 +2182,7 @@ print_r($this->_requestBody);
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @Given /^that I assign an access token from session variable "([^"]*)"$/
|
* @Given /^that I assign an access token from session variable "([^"]*)"$/
|
||||||
*/
|
*/
|
||||||
public function thatIAssignAnAccessTokenFromSessionVariable($varName)
|
public function thatIAssignAnAccessTokenFromSessionVariable($varName)
|
||||||
|
|||||||
Reference in New Issue
Block a user