Skip to content

Fix: repair failing host authorization test - #79

Merged
stonebuzz merged 2 commits into
mainfrom
fix_test
Aug 27, 2026
Merged

Fix: repair failing host authorization test#79
stonebuzz merged 2 commits into
mainfrom
fix_test

Conversation

@Rom1-B

@Rom1-B Rom1-B commented Aug 25, 2026

Copy link
Copy Markdown
Contributor

Checklist before requesting a review

Please delete options that are not relevant.

  • I have performed a self-review of my code.
  • I have added tests (when available) that prove my fix is effective or that my feature works.
  • I have updated the CHANGELOG with a short functional description of the fix or new feature.
  • This change requires a documentation update.

Description

  • fixes #N/A
  • The HostTest::testOneHost unit test was failing because the authorization check added in a previous fix requires an authenticated user and a database mapping between the Centreon host and a GLPI item, neither of which the test provided.
  • The test now logs in as the test user and creates the required mapping through GLPI's DbTestCase helpers, which also isolates each test run inside a rolled-back transaction.

Screenshots (if appropriate):

@Rom1-B
Rom1-B requested a review from stonebuzz August 25, 2026 06:54
Comment thread tests/HostTest.php Outdated
Comment on lines +58 to +61
$auth = new Auth();
$auth->user = getItemByTypeName(User::class, 'glpi');
$auth->auth_succeded = true;
Session::init($auth);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not use the dedicated login() function, since we’re now using DbTestCase?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@stonebuzz
stonebuzz requested a review from Mary-Clb August 26, 2026 15:36
@Rom1-B
Rom1-B requested a review from stonebuzz August 27, 2026 07:34
@stonebuzz
stonebuzz merged commit e8a75b9 into main Aug 27, 2026
3 checks passed
@stonebuzz
stonebuzz deleted the fix_test branch August 27, 2026 09:01
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.

2 participants