Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Comptoir du Libre v2 - Current version
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Comptoir
Comptoir du Libre v2 - Current version
Commits
12aab391
Commit
12aab391
authored
2 years ago
by
Fabrice Gangler
Browse files
Options
Downloads
Patches
Plain Diff
WIP - don't works (secu unit test for external ressource)
parent
2763833c
No related branches found
No related tags found
No related merge requests found
Pipeline
#59619
canceled
1 year ago
Stage: test
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
tests/TestCase/Controller/Api/V1/SoftwaresControllerTest.php
+122
-0
122 additions, 0 deletions
tests/TestCase/Controller/Api/V1/SoftwaresControllerTest.php
with
122 additions
and
0 deletions
tests/TestCase/Controller/Api/V1/SoftwaresControllerTest.php
+
122
−
0
View file @
12aab391
...
...
@@ -1924,4 +1924,126 @@ class SoftwaresControllerTest extends ApiIntegrationTestCase
$this
->
setConnectedCompanySession
();
$this
->
commonCheckForHtmlFormEditSoftwareWithExtraFormData
(
'providerFor'
);
}
/**
* Test HTML form:
* for the different user types ("Person", "Association", "Administration" and "Company"),
* edit a software by sending an HTTP Post request (the UI of the form is not tested)
* with "userOf" or "ProviderFor" parameters equal to "yes".
*
* - (1) Edit a software by sending an HTTP Post request (the UI of the form is not tested)
* - (1) Check that the main data is correctly recorded in the database.
* - (1) Check if current HTTP response is a redirection to the software URL.
* - For this user and this new software:
* - (2) Check if there are 1 records in 'RelationshipsSoftwaresUsers' table
* - (2) Check if there are 1 records in 'RelationshipsSoftwaresUsers' table, with correct relationship ID
*
* (1) via commonCheckForHtmlFormEditSoftware()
* (2) via commonCheckForHtmlFormEditSoftwareWithExtraFormData()
*
* @group user
* @group user_person
* @group software
* @group software_edit
* @group software_methode_edit
* @group software_methode_edit
* @group wip
*/
public
function
testHtmlFormEditSoftwareUpdateExternalRessources
()
{
// "Person" user with "admin" role
$this
->
setAdminSessionOfPersonType
();
// Grab a software in the database before updating it.
$softwareId
=
7
;
$software
=
$this
->
Softwares
->
find
()
->
where
([
'id'
=>
$softwareId
])
->
toList
()[
0
];
// dump($software); exit();
$alea
=
mt_rand
();
$newSoftwareName
=
$software
->
get
(
'softwarename'
)
.
"
$alea
"
;
$dataForm
=
[
'softwarename'
=>
$newSoftwareName
,
'url_repository'
=>
$software
->
get
(
'url_repository'
)
.
"/
$alea
"
,
'description'
=>
$software
->
get
(
'description'
)
.
"
$alea
"
,
'licence_id'
=>
$software
->
get
(
'licence_id'
),
"url_website"
=>
$software
->
get
(
'url_website'
)
.
"/
$alea
"
,
"tag_string"
=>
$software
->
get
(
'tag_string'
)
.
"
$alea
$alea$alea
"
,
'sill'
=>
1
,
'wikidata'
=>
''
,
'framalibre'
=>
''
,
'wikipedia_en'
=>
''
,
'wikipedia_fr'
=>
''
,
// 'sill' => $software->get('sill'),
// 'wikidata' => $software->get('wikidata') ."$alea",
// 'framalibre' => $software->get('framalibre') ,
// 'wikipedia_en' => $software->get('wikipedia_fr') ,
// 'wikipedia_fr' => $software->get('wikipedia_fr') ,
// 'sill' => $alea,
// 'wikidata' => $software->get('wikidata') ."$alea",
// 'framalibre' => $software->get('framalibre') ."$alea",
// 'wikipedia_en' => $software->get('wikipedia_fr') ."$alea",
// 'wikipedia_fr' => $software->get('wikipedia_fr') ."$alea",
];
// Edit software
$this
->
put
(
"/fr/softwares/edit/
$softwareId
"
,
$dataForm
);
$this
->
assertEventFired
(
'Model.Software.modified'
,
$this
->
Softwares
->
eventManager
());
// Cheking that the software now exists with its new name
// in the database and grab it's ID.
$this
->
assertEquals
(
1
,
$this
->
Softwares
->
find
()
->
where
([
'softwarename'
=>
$newSoftwareName
])
->
count
()
);
$softwareUpdated
=
$this
->
Softwares
->
find
()
->
where
([
'id'
=>
$softwareId
])
->
limit
(
1
)
->
toList
()[
0
];
$this
->
assertEquals
(
$softwareId
,
$softwareUpdated
->
id
);
// Cheking if current HTTP response is a redirection to the software URL
$redirectTo
=
"/fr/softwares/
$softwareId
"
;
$this
->
currentResponseIsRedirectionToAnotherUrl
(
$redirectTo
);
// Check that the main data is correctly recorded in the database.
$dataInDb
=
[
'softwarename'
=>
$softwareUpdated
->
get
(
'softwarename'
),
'url_repository'
=>
$softwareUpdated
->
get
(
'url_repository'
),
'description'
=>
$softwareUpdated
->
get
(
'description'
),
'licence_id'
=>
$softwareUpdated
->
get
(
'licence_id'
),
"url_website"
=>
$softwareUpdated
->
get
(
'url_website'
),
"tag_string"
=>
$softwareUpdated
->
get
(
'tag_string'
),
'sill'
=>
$software
->
get
(
'sill'
),
'wikidata'
=>
$software
->
get
(
'wikidata'
),
'framalibre'
=>
$software
->
get
(
'framalibre'
),
'wikipedia_en'
=>
$software
->
get
(
'wikipedia_fr'
),
'wikipedia_fr'
=>
$software
->
get
(
'wikipedia_fr'
),
];
dump
(
$alea
);
dump
(
$dataForm
);
dump
(
$dataInDb
);
$this
->
assertTrue
(
$this
->
arraysAreSimilar
(
$dataForm
,
$dataInDb
));
// "Person" user with "admin" role
$this
->
setAdminSessionOfPersonType
();
// "Person" user without "admin" role
$this
->
setConnectedPersonSession
();
// "Administration" user without "admin" role
$this
->
setConnectedAdministrationSession
();
// "Administration" user with "admin" role
$this
->
setAdminSessionOfAdministrationType
();
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment