Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

feat: implement product registration support #1809

Open
wants to merge 40 commits into
base: master
Choose a base branch
from

Conversation

imobachgs
Copy link
Contributor

@imobachgs imobachgs commented Dec 5, 2024

Warning

This code is still a work in progress, although it already works. However, make sure to remove the SLE 15 SP6 definition because it is there just for testing purposes.

The code is included in a testing ISO you can download from OBS.

Solution

This pull request implements support for product registration. It includes changes at several levels:

  • Adapt the Ruby part to handle the registration using /run/agama/zypp as target directory.
  • Add the information about whether a product should be registered or not in the product (and not through a separate D-Bus attribute). Propagate those changes to the HTTP API too.
  • Implement a registration page to the web user-interface.

Testing

You can use the web UI which sends the proper request to the backend or, if you prefer, you can play around with cURL:

TOKEN=$(curl -k --silent $AGAMA_URL/api/auth -d '{"password": "linux"}' \
	-H "Content-Type: application/json" | jq .token | tr -d '"')

echo "Content-Type: application/json" >headers.txt
echo -n "Authorization: Bearer " >>headers.txt
echo $TOKEN >>headers.txt

curl -k -H @headers.txt -X PUT \
	$AGAMA_URL/api/software/config \
	-d "{\"product\": \"SLES\"}"

curl -k -H @headers.txt -X POST \
	$AGAMA_URL/api/software/registration \
	-d "{\"key\": \"YOUR-REGISTRATION-CODE\", \"email\": \"[email protected]\"}"

Set $AGAMA_URL to the Agama HTTP API (e.g., https://192.168.122.10).

Screenshots

product-registration-page

imobachgs and others added 19 commits December 3, 2024 22:21
* Only for testing purposes.
Actually, at this moment the flag is only used for including a link to
the route in the main navigation or not depending on the
Product#registration value. But the idea is to limite the navigation too
in future iterations.
An initial version that basically consists on

- Main menu entry for registration
- Global alert visible on all pages except the registration page and
  those mounted at "supportive paths" (temporary name)
- Section with form for entering registration code and email
- Section to display registration information when available

Only basic workflow has been manually tested; unit tests will be added in upcoming commits.
Certain elements must not be rendered on paths that do not use the
"FullLayout". Other paths, considered "accessory" paths, have been
temporarily grouped under the "SUPPORTIVE_PATHS" constant to reduce code
duplication when excluding elements from them.

Although the approach needs improvement, starting with the naming,
let's use it where needed meanwhile.
@imobachgs imobachgs changed the title Product registration feat: implement product registration support Dec 5, 2024
@coveralls
Copy link

coveralls commented Dec 5, 2024

Pull Request Test Coverage Report for Build 12184382379

Warning: This coverage report may be inaccurate.

This pull request's base commit is no longer the HEAD commit of its target branch. This means it includes changes from outside the original pull request, including, potentially, unrelated coverage changes.

Details

  • 8 of 12 (66.67%) changed or added relevant lines in 4 files are covered.
  • 48 unchanged lines in 6 files lost coverage.
  • Overall coverage increased (+0.07%) to 71.143%

Changes Missing Coverage Covered Lines Changed/Added Lines %
rust/agama-lib/src/product/client.rs 0 4 0.0%
Files with Coverage Reduction New Missed Lines %
rust/agama-server/src/software/web.rs 1 0.0%
service/lib/agama/software/product.rb 1 97.3%
service/lib/agama/software/product_builder.rb 2 95.74%
service/lib/agama/registration.rb 6 92.0%
service/lib/agama/dbus/software/product.rb 10 85.85%
service/lib/agama/software/manager.rb 28 73.99%
Totals Coverage Status
Change from base Build 12147913808: 0.07%
Covered Lines: 17028
Relevant Lines: 23935

💛 - Coveralls

jreidinger and others added 9 commits December 5, 2024 10:17
Otherwise, it will trigger the useProduct hook which might not be
available yet like in the case of the login path, in which the
QueryClient has not been initialized yet.
Work-around issue with suse-connect cannot read credentials file.
But not rendering the link to the registration section when the user is
already there.

This commit also add the missing unit tests, covering all scenarios
implemented until now.
To use the proper value according to the recently updated type.
Basically using "no" instead of "No".
dgdavid and others added 12 commits December 5, 2024 12:56
To make them work again now that it is making use of useLocation
ReactRouterDom hook and to ensure it does not try to mount
ProductRegistrationAlert component at certain paths.
* Promote title
* Remove no longer needed hint
By using installerRender instead of plainRender when needed and pleasing
TypeScript and linters.
For using the right value according to the type. Overlooked in previous
commits.
@imobachgs imobachgs marked this pull request as ready for review December 16, 2024 17:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants