Skip to content

Add integration tests of invalid REST integer parameters.#1765

Merged
aaronweeden merged 1 commit into
ubccr:xdmod11.0from
aaronweeden:add-int-param-tests
Dec 1, 2023
Merged

Add integration tests of invalid REST integer parameters.#1765
aaronweeden merged 1 commit into
ubccr:xdmod11.0from
aaronweeden:add-int-param-tests

Conversation

@aaronweeden

@aaronweeden aaronweeden commented Aug 30, 2023

Copy link
Copy Markdown
Contributor

Description

This PR adds new integration tests that test invalid integer parameters obtained via the getIntParam() method of BaseControllerProvider.

This PR also fixes a bug in DashboardControllerProvider in which an exception name was misspelled; this bug was exposed by the new tests.

This PR also refactors some parameter validation in WarehouseControllerProvider to be more consistent with parameter validation elsewhere.

This PR is a basis for #1768.

Tests performed

I developed the tests incrementally while running in the tools-ext-01.ccr.xdmod.org/xdmod10.0:rockylinux8.5-0.5 Docker container upgraded to the latest XDMoD.

Also, in a Docker container running tools-ext-01.ccr.xdmod.org/xdmod-10.5.0-x86_64:rockylinux8.5-0.3:

  1. Run the following commands:
    export COMPOSER_ALLOW_SUPERUSER=1
    export XDMOD_REALMS='jobs,storage,cloud'
    export XDMOD_IS_CORE=yes
    export XDMOD_INSTALL_DIR=/xdmod
    export XDMOD_TEST_MODE=upgrade
    openssl genrsa -rand /proc/cpuinfo:/proc/dma:/proc/filesystems:/proc/interrupts:/proc/ioports:/proc/uptime 2048 > /etc/pki/tls/private/localhost.key
    /usr/bin/openssl req -new -key /etc/pki/tls/private/localhost.key -x509 -sha256 -days 365 -set_serial $RANDOM -extensions v3_req -out /etc/pki/tls/certs/localhost.crt -subj "/C=XX/L=Default City/O=Default Company Ltd"
    git clone https://github.com/ubccr/xdmod /xdmod
    cd /xdmod
    composer install
    mkdir ~/phpunit
    mkdir /tmp/screenshots
    ~/bin/buildrpm xdmod
    ./tests/ci/bootstrap.sh
    ./tests/ci/validate.sh
    composer install --no-progress
    mv ./configuration/organization.json ./configuration/organization.json.old
    mv ./configuration/portal_settings.ini ./configuration/portal_settings.ini.old
    cp /etc/xdmod/portal_settings.ini ./configuration/portal_settings.ini
    cp /etc/xdmod/organization.json ./configuration/organization.json
    ./tests/ci/scripts/qa-test-setup.sh
    ./tests/regression/runtests.sh
    cd tests/integration
    ../../vendor/bin/phpunit --testsuite default --group UserAdminTest.createUsers --debug > /before.txt
    ../../vendor/bin/phpunit --testsuite default --exclude-group UserAdminTest.createUsers --debug >> /before.txt
    git clone https://github.com/aaronweeden/xdmod -b add-int-param-tests /xdmod-new
    unalias rm
    rm -r lib
    cp -r /xdmod-new/tests/integration/lib .
    rm -r /usr/share/xdmod/classes/Rest/Controllers
    cp -r {/xdmod-new,/usr/share/xdmod}/classes/Rest/Controllers
    ../../vendor/bin/phpunit --testsuite default --group UserAdminTest.createUsers --debug > /after.txt
    ../../vendor/bin/phpunit --testsuite default --exclude-group UserAdminTest.createUsers --debug >> /after.txt
    
  2. Compare /before.txt and /after.txt and make sure the differences are correct:
    1. Different random values for ControllerTest::testEnumTargetAddresses.
    2. New tests in AdminControllerProviderTest, DashboardControllerProviderTest, and WarehouseControllerProviderTest (the latter of which replace WarehouseControllerProviderTest::testGetAggregateDataMalformedRequests).
    3. Last group of tests take about 0.25 min more and go from 722 tests -> 787 tests, 570956 assertions -> 571156 assertions.

Checklist:

  • The pull request description is suitable for a Changelog entry
  • The milestone is set correctly on the pull request
  • The appropriate labels have been added to the pull request

@aaronweeden aaronweeden added the qa / testing Updates/additions to tests label Aug 30, 2023
@aaronweeden aaronweeden added this to the 11.0.0 milestone Aug 30, 2023
@aaronweeden aaronweeden added the bug Bugfixes label Oct 5, 2023
@aaronweeden aaronweeden changed the base branch from xdmod10.5 to xdmod11.0 October 5, 2023 20:37
@aaronweeden aaronweeden force-pushed the add-int-param-tests branch 2 times, most recently from ab38a3e to 039c588 Compare October 5, 2023 23:29
@aaronweeden aaronweeden marked this pull request as ready for review October 6, 2023 00:08
@aaronweeden aaronweeden changed the title Add integration tests for invalid REST integer parameters. Add integration tests of invalid REST integer parameters. Oct 6, 2023
@aaronweeden aaronweeden force-pushed the add-int-param-tests branch 2 times, most recently from 8ec7783 to ac939fb Compare October 13, 2023 21:16
@aaronweeden aaronweeden force-pushed the add-int-param-tests branch 2 times, most recently from 196b542 to 7f3d7f3 Compare November 7, 2023 21:02
Comment thread classes/Rest/Controllers/WarehouseControllerProvider.php
@aaronweeden aaronweeden merged commit c97b01f into ubccr:xdmod11.0 Dec 1, 2023
@aaronweeden aaronweeden deleted the add-int-param-tests branch December 1, 2023 20:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Bugfixes qa / testing Updates/additions to tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants