Skip to content

Commit

Permalink
feat(rest.identity.provider): Added new Identity rest APIs and Reques…
Browse files Browse the repository at this point in the history
…t Handler (#4878)

* First commit.

* Some fixes and tests.

* Added condition on shouldInvokeSetUserConfigSuccessfully

* Added new module in the list

* fixed tests.

* Added the possibility to inject the identityService (mainly for testing purposes)

* Fix tests

* Fixed data test

* fixed module name

* updated expected data

* Fix tests

* fixed method names

* Changed API to meet `JaxRsRequest` handler behavior

* Fixed deleteUser path and tests.

* Fixed test

* Fixed test

* Changed getUserConfig return type

* Removed Gson

* fixed test manifest.mf

* Trying fix tests

* fixed method path

* removed wrong body

* Test alternate delete

* Test alternate delete

* Yet another fix

* Changed getDefinedPermissions returned object

* Fixed methods name.

* fixed test

* Fixed absurd bug in test.

* fixed identity.provider pom.xml

* deleteUser has again a path parameter

* Fixed deleteUser

* Revert "deleteUser has again a path parameter"

This reverts commit fa214e8.

* removed comment

* Fixed error and copyright

* Fixed bug in UserAdminHelper#createUser

* Added check on requestHandlerMethod

* Added new getUser method

* Fixed test

* added missing @produces annotation.

* fixed test

* Fix test

* Fix test

* YA Fix test

* YA Fix test

* added tearDown with @afterclass

* attempt to fix test

* fix getUserConfigResponse

* changed tests order

* Added policy greedy

* Refactored API

* Test updated.

* Fixed test

* Added password validation before user creation.

* Fixed some bugs.
Added new `/password-requirements` method.

* Added missing method to mock.

* Fixed expected json

* Refactored updateUser to reduce complexity.

* fixed test

* Keep original identity field values if they are not specified

Signed-off-by: Nicola Timeus <[email protected]>

* Added tests and several minor fixes.

* Added rest.identity permission configuration in the snapshot_0.xml files.

* Added rest.identity.provider to emulator configuration

* Applied cleanup

* Fixed sonar lint issue

Signed-off-by: Nicola Timeus <[email protected]>

* Minor naming changes

Signed-off-by: Nicola Timeus <[email protected]>

---------

Signed-off-by: Nicola Timeus <[email protected]>
Co-authored-by: Nicola Timeus <[email protected]>
  • Loading branch information
salvatore-coppola and nicolatimeus authored Oct 31, 2023
1 parent d74484b commit 17538d5
Show file tree
Hide file tree
Showing 48 changed files with 2,514 additions and 24 deletions.
1 change: 1 addition & 0 deletions kura/distrib/config/kura.build.properties
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ org.eclipse.kura.rest.command.provider.version=1.0.0-SNAPSHOT
org.eclipse.kura.rest.packages.provider.version=1.0.0-SNAPSHOT
org.eclipse.kura.rest.position.provider.version=1.0.0-SNAPSHOT
org.eclipse.kura.rest.security.provider.version=1.0.0-SNAPSHOT
org.eclipse.kura.rest.identity.provider.version=1.0.0-SNAPSHOT
org.eclipse.kura.rest.service.listing.provider.version=1.0.0-SNAPSHOT
org.eclipse.kura.rest.system.provider.version=1.0.0-SNAPSHOT
org.eclipse.kura.request.handler.jaxrs.version=1.3.0-SNAPSHOT
Expand Down
7 changes: 7 additions & 0 deletions kura/distrib/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -623,6 +623,11 @@
<artifactId>org.eclipse.kura.rest.security.provider</artifactId>
<version>${org.eclipse.kura.rest.security.provider.version}</version>
</artifactItem>
<artifactItem>
<groupId>org.eclipse.kura</groupId>
<artifactId>org.eclipse.kura.rest.identity.provider</artifactId>
<version>${org.eclipse.kura.rest.identity.provider.version}</version>
</artifactItem>
<artifactItem>
<groupId>org.eclipse.kura</groupId>
<artifactId>org.eclipse.kura.rest.service.listing.provider</artifactId>
Expand Down Expand Up @@ -827,6 +832,7 @@
<move file="target/plugins/org.eclipse.kura.rest.command.provider.jar" tofile="target/plugins/org.eclipse.kura.rest.command.provider_${org.eclipse.kura.rest.command.provider.version}.jar" />
<move file="target/plugins/org.eclipse.kura.rest.packages.provider.jar" tofile="target/plugins/org.eclipse.kura.rest.packages.provider_${org.eclipse.kura.rest.packages.provider.version}.jar" />
<move file="target/plugins/org.eclipse.kura.rest.position.provider.jar" tofile="target/plugins/org.eclipse.kura.rest.position.provider_${org.eclipse.kura.rest.position.provider.version}.jar" />
<move file="target/plugins/org.eclipse.kura.rest.identity.provider.jar" tofile="target/plugins/org.eclipse.kura.rest.identity.provider_${org.eclipse.kura.rest.identity.provider.version}.jar" />
<move file="target/plugins/org.eclipse.kura.rest.security.provider.jar" tofile="target/plugins/org.eclipse.kura.rest.security.provider_${org.eclipse.kura.rest.security.provider.version}.jar" />
<move file="target/plugins/org.eclipse.kura.rest.service.listing.provider.jar" tofile="target/plugins/org.eclipse.kura.rest.service.listing.provider_${org.eclipse.kura.rest.service.listing.provider.version}.jar" />
<move file="target/plugins/org.eclipse.kura.rest.system.provider.jar" tofile="target/plugins/org.eclipse.kura.rest.system.provider_${org.eclipse.kura.rest.system.provider.version}.jar" />
Expand Down Expand Up @@ -2543,6 +2549,7 @@
<copy file="${project.build.directory}/plugins/org.eclipse.kura.rest.command.provider_${org.eclipse.kura.rest.command.provider.version}.jar" todir="${project.build.directory}/staging/target-definition/equinox_3.16.0/repository/plugins" />
<copy file="${project.build.directory}/plugins/org.eclipse.kura.rest.packages.provider_${org.eclipse.kura.rest.packages.provider.version}.jar" todir="${project.build.directory}/staging/target-definition/equinox_3.16.0/repository/plugins" />
<copy file="${project.build.directory}/plugins/org.eclipse.kura.rest.position.provider_${org.eclipse.kura.rest.position.provider.version}.jar" todir="${project.build.directory}/staging/target-definition/equinox_3.16.0/repository/plugins" />
<copy file="${project.build.directory}/plugins/org.eclipse.kura.rest.identity.provider_${org.eclipse.kura.rest.identity.provider.version}.jar" todir="${project.build.directory}/staging/target-definition/equinox_3.16.0/repository/plugins" />
<copy file="${project.build.directory}/plugins/org.eclipse.kura.rest.security.provider_${org.eclipse.kura.rest.security.provider.version}.jar" todir="${project.build.directory}/staging/target-definition/equinox_3.16.0/repository/plugins" />
<copy file="${project.build.directory}/plugins/org.eclipse.kura.rest.service.listing.provider_${org.eclipse.kura.rest.service.listing.provider.version}.jar" todir="${project.build.directory}/staging/target-definition/equinox_3.16.0/repository/plugins" />
<copy file="${project.build.directory}/plugins/org.eclipse.kura.rest.system.provider_${org.eclipse.kura.rest.system.provider.version}.jar" todir="${project.build.directory}/staging/target-definition/equinox_3.16.0/repository/plugins" />
Expand Down
17 changes: 11 additions & 6 deletions kura/distrib/src/main/ant/build_equinox_distrib.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1320,9 +1320,11 @@ fi]]>
<entry key="osgi.bundles" operation="+"
value=", reference:file:${kura.install.dir}/${kura.symlink}/${plugins.folder}/org.eclipse.kura.rest.position.provider_${org.eclipse.kura.rest.position.provider.version}.jar@4:start" />
<entry key="osgi.bundles" operation="+"
value=", reference:file:${kura.install.dir}/${kura.symlink}/${plugins.folder}/org.eclipse.kura.rest.security.provider_${org.eclipse.kura.rest.security.provider.version}.jar@4:start" />
<entry key="osgi.bundles" operation="+"
value=", reference:file:${kura.install.dir}/${kura.symlink}/${plugins.folder}/org.eclipse.kura.rest.service.listing.provider_${org.eclipse.kura.rest.service.listing.provider.version}.jar@4:start" />
value=", reference:file:${kura.install.dir}/${kura.symlink}/${plugins.folder}/org.eclipse.kura.rest.security.provider_${org.eclipse.kura.rest.security.provider.version}.jar@4:start" />
<entry key="osgi.bundles" operation="+"
value=", reference:file:${kura.install.dir}/${kura.symlink}/${plugins.folder}/org.eclipse.kura.rest.identity.provider_${org.eclipse.kura.rest.identity.provider.version}.jar@4:start" />
<entry key="osgi.bundles" operation="+"
value=", reference:file:${kura.install.dir}/${kura.symlink}/${plugins.folder}/org.eclipse.kura.rest.service.listing.provider_${org.eclipse.kura.rest.service.listing.provider.version}.jar@4:start" />
<entry key="osgi.bundles" operation="+"
value=", reference:file:${kura.install.dir}/${kura.symlink}/${plugins.folder}/org.eclipse.kura.rest.system.provider_${org.eclipse.kura.rest.system.provider.version}.jar@4:start" />
<entry key="osgi.bundles" operation="+"
Expand Down Expand Up @@ -1425,10 +1427,13 @@ fi]]>
prefix="${build.output.name}/${plugins.folder}" />
<zipfileset
file="${project.build.directory}/plugins/org.eclipse.kura.rest.security.provider_${org.eclipse.kura.rest.security.provider.version}.jar"
prefix="${build.output.name}/${plugins.folder}" />
prefix="${build.output.name}/${plugins.folder}" />
<zipfileset
file="${project.build.directory}/plugins/org.eclipse.kura.rest.service.listing.provider_${org.eclipse.kura.rest.service.listing.provider.version}.jar"
prefix="${build.output.name}/${plugins.folder}" />
file="${project.build.directory}/plugins/org.eclipse.kura.rest.identity.provider_${org.eclipse.kura.rest.identity.provider.version}.jar"
prefix="${build.output.name}/${plugins.folder}" />
<zipfileset
file="${project.build.directory}/plugins/org.eclipse.kura.rest.service.listing.provider_${org.eclipse.kura.rest.service.listing.provider.version}.jar"
prefix="${build.output.name}/${plugins.folder}" />
<zipfileset
file="${project.build.directory}/plugins/org.eclipse.kura.rest.system.provider_${org.eclipse.kura.rest.system.provider.version}.jar"
prefix="${build.output.name}/${plugins.folder}" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,7 @@
<setEntry value="org.eclipse.kura.request.handler.jaxrs@default:default"/>
<setEntry value="org.eclipse.kura.rest.asset.provider@default:default"/>
<setEntry value="org.eclipse.kura.rest.configuration.provider@default:default"/>
<setEntry value="org.eclipse.kura.rest.identity.provider@default:default"/>
<setEntry value="org.eclipse.kura.rest.inventory.provider@default:default"/>
<setEntry value="org.eclipse.kura.rest.command.provider@default:default"/>
<setEntry value="org.eclipse.kura.rest.position.provider@default:default"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -463,7 +463,7 @@
<esf:value>[{"name":"kura.user.admin","credentials":{"kura.password":"jGl25bVBBBW96Qi9Te4V37Fnqchz/Eu4qB9vKrRIqRg="},"properties":{"kura.need.password.change":"true"}},{"name":"kura.user.appadmin","credentials":{"kura.password":"3hPckF8Zc+IF3pVineBvck3zJERUl8itosySULE1hpM="},"properties":{"kura.need.password.change":"true"}},{"name":"kura.user.netadmin","credentials":{"kura.password":"3PgDKAMCxgRWBHiT1dEBS97bPqt7xckgdwrADJiDoWg="},"properties":{"kura.need.password.change":"true"}}]</esf:value>
</esf:property>
<esf:property array="false" encrypted="false" name="groups.config" type="String">
<esf:value>[{"name":"kura.permission.kura.admin","basicMembers":["kura.user.admin"]},{"name":"kura.permission.kura.cloud.connection.admin","basicMembers":["kura.user.appadmin","kura.user.netadmin"]},{"name":"kura.permission.kura.device","basicMembers":["kura.user.netadmin"]},{"name":"kura.permission.kura.maintenance"},{"name":"kura.permission.kura.network.admin","basicMembers":["kura.user.netadmin"]},{"name":"kura.permission.kura.packages.admin","basicMembers":["kura.user.appadmin"]},{"name":"kura.permission.kura.wires.admin","basicMembers":["kura.user.appadmin"]},{"name":"kura.permission.rest.assets"},{"name":"kura.permission.rest.command"},{"name":"kura.permission.rest.configuration"},{"name":"kura.permission.rest.inventory"},{"name":"kura.permission.rest.keystores"},{"name":"kura.permission.rest.network.status"},{"name":"kura.permission.rest.position"},{"name":"kura.permission.rest.system"},{"name":"kura.permission.rest.tamper.detection"},{"name":"kura.permission.rest.wires.admin"}]</esf:value>
<esf:value>[{"name":"kura.permission.kura.admin","basicMembers":["kura.user.admin"]},{"name":"kura.permission.kura.cloud.connection.admin","basicMembers":["kura.user.appadmin","kura.user.netadmin"]},{"name":"kura.permission.kura.device","basicMembers":["kura.user.netadmin"]},{"name":"kura.permission.kura.maintenance"},{"name":"kura.permission.kura.network.admin","basicMembers":["kura.user.netadmin"]},{"name":"kura.permission.kura.packages.admin","basicMembers":["kura.user.appadmin"]},{"name":"kura.permission.kura.wires.admin","basicMembers":["kura.user.appadmin"]},{"name":"kura.permission.rest.assets"},{"name":"kura.permission.rest.command"},{"name":"kura.permission.rest.configuration"},{"name":"kura.permission.rest.identity"},{"name":"kura.permission.rest.inventory"},{"name":"kura.permission.rest.keystores"},{"name":"kura.permission.rest.network.status"},{"name":"kura.permission.rest.position"},{"name":"kura.permission.rest.system"},{"name":"kura.permission.rest.tamper.detection"},{"name":"kura.permission.rest.wires.admin"}]</esf:value>
</esf:property>
</esf:properties>
</esf:configuration>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -456,7 +456,7 @@
<esf:value>[{"name":"kura.user.admin","credentials":{"kura.password":"jGl25bVBBBW96Qi9Te4V37Fnqchz/Eu4qB9vKrRIqRg="},"properties":{"kura.need.password.change":"true"}},{"name":"kura.user.appadmin","credentials":{"kura.password":"3hPckF8Zc+IF3pVineBvck3zJERUl8itosySULE1hpM="},"properties":{"kura.need.password.change":"true"}},{"name":"kura.user.netadmin","credentials":{"kura.password":"3PgDKAMCxgRWBHiT1dEBS97bPqt7xckgdwrADJiDoWg="},"properties":{"kura.need.password.change":"true"}}]</esf:value>
</esf:property>
<esf:property array="false" encrypted="false" name="groups.config" type="String">
<esf:value>[{"name":"kura.permission.kura.admin","basicMembers":["kura.user.admin"]},{"name":"kura.permission.kura.cloud.connection.admin","basicMembers":["kura.user.appadmin","kura.user.netadmin"]},{"name":"kura.permission.kura.device","basicMembers":["kura.user.netadmin"]},{"name":"kura.permission.kura.maintenance"},{"name":"kura.permission.kura.network.admin","basicMembers":["kura.user.netadmin"]},{"name":"kura.permission.kura.packages.admin","basicMembers":["kura.user.appadmin"]},{"name":"kura.permission.kura.wires.admin","basicMembers":["kura.user.appadmin"]},{"name":"kura.permission.rest.assets"},{"name":"kura.permission.rest.command"},{"name":"kura.permission.rest.configuration"},{"name":"kura.permission.rest.inventory"},{"name":"kura.permission.rest.keystores"},{"name":"kura.permission.rest.network.status"},{"name":"kura.permission.rest.position"},{"name":"kura.permission.rest.tamper.detection"},{"name":"kura.permission.rest.wires.admin"}]</esf:value>
<esf:value>[{"name":"kura.permission.kura.admin","basicMembers":["kura.user.admin"]},{"name":"kura.permission.kura.cloud.connection.admin","basicMembers":["kura.user.appadmin","kura.user.netadmin"]},{"name":"kura.permission.kura.device","basicMembers":["kura.user.netadmin"]},{"name":"kura.permission.kura.maintenance"},{"name":"kura.permission.kura.network.admin","basicMembers":["kura.user.netadmin"]},{"name":"kura.permission.kura.packages.admin","basicMembers":["kura.user.appadmin"]},{"name":"kura.permission.kura.wires.admin","basicMembers":["kura.user.appadmin"]},{"name":"kura.permission.rest.assets"},{"name":"kura.permission.rest.command"},{"name":"kura.permission.rest.configuration"},{"name":"kura.permission.rest.identity"},{"name":"kura.permission.rest.inventory"},{"name":"kura.permission.rest.keystores"},{"name":"kura.permission.rest.network.status"},{"name":"kura.permission.rest.position"},{"name":"kura.permission.rest.tamper.detection"},{"name":"kura.permission.rest.wires.admin"}]</esf:value>
</esf:property>
</esf:properties>
</esf:configuration>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -382,7 +382,7 @@
<esf:value>[{"name":"kura.user.admin","credentials":{"kura.password":"jGl25bVBBBW96Qi9Te4V37Fnqchz/Eu4qB9vKrRIqRg="},"properties":{"kura.need.password.change":"true"}},{"name":"kura.user.appadmin","credentials":{"kura.password":"3hPckF8Zc+IF3pVineBvck3zJERUl8itosySULE1hpM="},"properties":{"kura.need.password.change":"true"}},{"name":"kura.user.netadmin","credentials":{"kura.password":"3PgDKAMCxgRWBHiT1dEBS97bPqt7xckgdwrADJiDoWg="},"properties":{"kura.need.password.change":"true"}}]</esf:value>
</esf:property>
<esf:property array="false" encrypted="false" name="groups.config" type="String">
<esf:value>[{"name":"kura.permission.kura.admin","basicMembers":["kura.user.admin"]},{"name":"kura.permission.kura.cloud.connection.admin","basicMembers":["kura.user.appadmin","kura.user.netadmin"]},{"name":"kura.permission.kura.device","basicMembers":["kura.user.netadmin"]},{"name":"kura.permission.kura.maintenance"},{"name":"kura.permission.kura.network.admin","basicMembers":["kura.user.netadmin"]},{"name":"kura.permission.kura.packages.admin","basicMembers":["kura.user.appadmin"]},{"name":"kura.permission.kura.wires.admin","basicMembers":["kura.user.appadmin"]},{"name":"kura.permission.rest.assets"},{"name":"kura.permission.rest.command"},{"name":"kura.permission.rest.configuration"},{"name":"kura.permission.rest.inventory"},{"name":"kura.permission.rest.keystores"},{"name":"kura.permission.rest.network.status"},{"name":"kura.permission.rest.position"},{"name":"kura.permission.rest.tamper.detection"},{"name":"kura.permission.rest.wires.admin"}]</esf:value>
<esf:value>[{"name":"kura.permission.kura.admin","basicMembers":["kura.user.admin"]},{"name":"kura.permission.kura.cloud.connection.admin","basicMembers":["kura.user.appadmin","kura.user.netadmin"]},{"name":"kura.permission.kura.device","basicMembers":["kura.user.netadmin"]},{"name":"kura.permission.kura.maintenance"},{"name":"kura.permission.kura.network.admin","basicMembers":["kura.user.netadmin"]},{"name":"kura.permission.kura.packages.admin","basicMembers":["kura.user.appadmin"]},{"name":"kura.permission.kura.wires.admin","basicMembers":["kura.user.appadmin"]},{"name":"kura.permission.rest.assets"},{"name":"kura.permission.rest.command"},{"name":"kura.permission.rest.configuration"},{"name":"kura.permission.rest.identity"},{"name":"kura.permission.rest.inventory"},{"name":"kura.permission.rest.keystores"},{"name":"kura.permission.rest.network.status"},{"name":"kura.permission.rest.position"},{"name":"kura.permission.rest.tamper.detection"},{"name":"kura.permission.rest.wires.admin"}]</esf:value>
</esf:property>
</esf:properties>
</esf:configuration>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -337,7 +337,7 @@
<esf:value>[{"name":"kura.user.admin","credentials":{"kura.password":"jGl25bVBBBW96Qi9Te4V37Fnqchz/Eu4qB9vKrRIqRg="},"properties":{"kura.need.password.change":"true"}},{"name":"kura.user.appadmin","credentials":{"kura.password":"3hPckF8Zc+IF3pVineBvck3zJERUl8itosySULE1hpM="},"properties":{"kura.need.password.change":"true"}}]</esf:value>
</esf:property>
<esf:property array="false" encrypted="false" name="groups.config" type="String">
<esf:value>[{"name":"kura.permission.kura.admin","basicMembers":["kura.user.admin"]},{"name":"kura.permission.kura.cloud.connection.admin","basicMembers":["kura.user.appadmin"]},{"name":"kura.permission.kura.device"},{"name":"kura.permission.kura.maintenance"},{"name":"kura.permission.kura.packages.admin","basicMembers":["kura.user.appadmin"]},{"name":"kura.permission.kura.wires.admin","basicMembers":["kura.user.appadmin"]},{"name":"kura.permission.rest.assets"},{"name":"kura.permission.rest.command"},{"name":"kura.permission.rest.configuration"},{"name":"kura.permission.rest.inventory"},{"name":"kura.permission.rest.keystores"},{"name":"kura.permission.rest.position"},{"name":"kura.permission.rest.system"},{"name":"kura.permission.rest.tamper.detection"},{"name":"kura.permission.rest.wires.admin"}]</esf:value>
<esf:value>[{"name":"kura.permission.kura.admin","basicMembers":["kura.user.admin"]},{"name":"kura.permission.kura.cloud.connection.admin","basicMembers":["kura.user.appadmin"]},{"name":"kura.permission.kura.device"},{"name":"kura.permission.kura.maintenance"},{"name":"kura.permission.kura.packages.admin","basicMembers":["kura.user.appadmin"]},{"name":"kura.permission.kura.wires.admin","basicMembers":["kura.user.appadmin"]},{"name":"kura.permission.rest.assets"},{"name":"kura.permission.rest.command"},{"name":"kura.permission.rest.configuration"},{"name":"kura.permission.rest.identity"},{"name":"kura.permission.rest.inventory"},{"name":"kura.permission.rest.keystores"},{"name":"kura.permission.rest.position"},{"name":"kura.permission.rest.system"},{"name":"kura.permission.rest.tamper.detection"},{"name":"kura.permission.rest.wires.admin"}]</esf:value>
</esf:property>
</esf:properties>
</esf:configuration>
Expand Down
Loading

0 comments on commit 17538d5

Please sign in to comment.