From 9ac35f1ce795048ef318c415ab1d2ef5b902888c Mon Sep 17 00:00:00 2001 From: Glenn Rice Date: Mon, 22 Aug 2022 20:32:14 -0500 Subject: [PATCH] Adapt the unit test action to not use a docker image. --- .github/workflows/unit-tests.yml | 72 +++++++++++++++++++++----- docker/webwork3.dockerfile | 24 ++++++--- lib/DB/Schema/Result/Attempt.pm | 2 +- lib/DB/Schema/Result/CourseSettings.pm | 2 +- lib/DB/Schema/Result/CourseUser.pm | 2 +- lib/DB/Schema/Result/PoolProblem.pm | 2 +- lib/DB/Schema/Result/ProblemSet.pm | 4 +- lib/DB/Schema/Result/SetProblem.pm | 2 +- lib/DB/Schema/Result/UserProblem.pm | 2 +- lib/DB/Schema/Result/UserSet.pm | 2 +- t/db/001_courses.t | 3 +- t/db/004_course_users.t | 4 +- t/db/006_quizzes.t | 10 +++- t/mojolicious/001_login.t | 11 ++-- t/mojolicious/002_courses.t | 12 ++--- t/mojolicious/003_users.t | 14 ++--- t/mojolicious/008_problems.t | 18 +++---- t/mojolicious/009_user_problems.t | 10 ++-- t/mojolicious/010_problem_pools.t | 4 +- 19 files changed, 129 insertions(+), 71 deletions(-) diff --git a/.github/workflows/unit-tests.yml b/.github/workflows/unit-tests.yml index 8f97781f..66d773a9 100644 --- a/.github/workflows/unit-tests.yml +++ b/.github/workflows/unit-tests.yml @@ -2,17 +2,65 @@ name: Unit Tests and Coverage on: push: - branches: [ main ] + branches: [main] pull_request: - branches: [ main ] + branches: [main] jobs: unit-tests: - runs-on: ubuntu-latest - # If we are going to use a prebuilt image like this we need a webwork repository on docker hub - container: drgrice1/webwork3 + runs-on: ubuntu-20.04 steps: - - uses: actions/checkout@v2 + - name: Checkout webwork3 source code + uses: actions/checkout@v2 + + # Disabling these things speeds up the setup considerably, and they are not needed for the throw away machine. + - name: Disable man-db and initramfs updates + run: | + sudo sed -i 's/yes/no/g' /etc/initramfs-tools/update-initramfs.conf + sudo rm -f /var/lib/man-db/auto-update + + - name: Install dependencies + run: | + sudo apt-get update + sudo apt-get install -qy --no-install-recommends --no-install-suggests \ + cpanminus \ + libarray-utils-perl \ + libcapture-tiny-perl \ + libclass-accessor-lite-perl \ + libclone-perl \ + libcpanel-json-xs-perl \ + libcrypt-ssleay-perl \ + libdata-dump-perl \ + libdatetime-format-strptime-perl \ + libdbd-sqlite3-perl \ + libdbix-class-inflatecolumn-serializer-perl \ + libdbix-class-perl \ + libdbix-dbschema-perl \ + libdevel-cover-perl \ + libexception-class-perl \ + libextutils-config-perl \ + libextutils-helpers-perl \ + libextutils-installpaths-perl \ + libfurl-perl \ + libhttp-parser-xs-perl \ + libio-socket-ssl-perl \ + liblist-moreutils-perl \ + libmodule-build-tiny-perl \ + libnet-ssleay-perl \ + libsql-translator-perl \ + libtest-exception-perl \ + libtest-harness-perl \ + libtext-csv-perl \ + libtry-tiny-perl \ + libyaml-libyaml-perl + cpanm --sudo --notest \ + DBIx::Class::DynamicSubclass \ + Mojolicious \ + Mojolicious::Plugin::NotYAMLConfig \ + Mojolicious::Plugin::DBIC \ + Mojolicious::Plugin::Authentication \ + Devel::Cover::Report::Codecov + - name: Run perl unit tests env: HARNESS_PERL_SWITCHES: -MDevel::Cover @@ -20,24 +68,20 @@ jobs: perl t/db/build_db.pl prove -r t - # we probably don'te need to upload the codecov data - # - uses: actions/upload-artifact@v2 - # with: - # name: coverage-report - # path: cover_db/ - - name: Push coverage analysis if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' }} env: CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} run: cover -report codecov - # Install node (for npm) and use it to install eslint and stylelint dependencies. - - name: Use Node.js + # Install node (for npm). + - name: Set up node uses: actions/setup-node@v2 with: node-version: '16' + - name: Install Dependencies run: npm ci + - name: Run typescript (client-side) tests run: npm run test diff --git a/docker/webwork3.dockerfile b/docker/webwork3.dockerfile index d5ec402f..28c92f76 100644 --- a/docker/webwork3.dockerfile +++ b/docker/webwork3.dockerfile @@ -1,6 +1,6 @@ FROM ubuntu:20.04 -# the following are needed to make sure the timezone packages don't ask for your timezone. +# The following are needed to make sure the timezone packages don't ask for your timezone. ENV DEBIAN_FRONTEND noninteractive ENV DEBCONF_NONINTERACTIVE_SEEN true ENV HARNESS_PERL_SWITCHES -MDevel::Cover @@ -8,32 +8,42 @@ ENV HARNESS_PERL_SWITCHES -MDevel::Cover RUN apt-get update && \ apt-get install -qy --no-install-recommends --no-install-suggests \ build-essential=12.8ubuntu1 \ - ca-certificates=20210119~20.04.1 \ + ca-certificates=20211016~20.04.1 \ cpanminus=1.7044-1 \ - git=1:2.25.1-1ubuntu3.1 \ + git=1:2.25.1-1ubuntu3.5 \ libarray-utils-perl=0.5-1 \ + libcapture-tiny-perl=0.48-1 \ + libclass-accessor-lite-perl=0.08-1 \ libclone-perl=0.43-2 \ + libcpanel-json-xs-perl=4.19-1build1 \ libcrypt-ssleay-perl=0.73.06-1build3 \ libdata-dump-perl=1.23-1 \ libdatetime-format-strptime-perl=1.7600-1 \ - libdbd-mysql-perl=4.050-3 \ + # libdbd-mysql-perl=4.050-3 \ libdbd-sqlite3-perl=1.64-1build1 \ - libdbix-class-perl=0.082841-1 \ libdbix-class-inflatecolumn-serializer-perl=0.09-1 \ + libdbix-class-perl=0.082841-1 \ libdbix-dbschema-perl=0.45-1 \ libdevel-cover-perl=1.33-1build1 \ libexception-class-perl=1.44-1 \ libjson-perl=4.02000-2 \ + libextutils-config-perl=0.008-2 \ + libextutils-helpers-perl=0.026-1 \ + libextutils-installpaths-perl=0.012-1 \ + libfurl-perl=3.13-2 \ + libhttp-parser-xs-perl=0.17-1build5 \ + libio-socket-ssl-perl=2.067-1 \ + libmodule-build-tiny-perl=0.039-1 \ libnet-ssleay-perl=1.88-2ubuntu1 \ libsql-translator-perl=1.60-1 \ - libssl-dev=1.1.1f-1ubuntu2.5 \ + libssl-dev=1.1.1f-1ubuntu2.16 \ libtest-exception-perl=0.43-1 \ libtest-harness-perl=3.42-2 \ libtext-csv-perl=2.00-1 \ libtry-tiny-perl=0.30-1 \ libyaml-libyaml-perl=0.81+repack-1 \ # mariadb-server=1:10.3.31-0ubuntu0.20.04.1 \ # if desired to use a full database - openssl=1.1.1f-1ubuntu2.5 && \ + openssl=1.1.1f-1ubuntu2.16 && \ rm -rf /var/lib/apt/lists/* && \ cpanm --notest \ DBIx::Class::DynamicSubclass \ diff --git a/lib/DB/Schema/Result/Attempt.pm b/lib/DB/Schema/Result/Attempt.pm index ff879e1f..0b6ada18 100644 --- a/lib/DB/Schema/Result/Attempt.pm +++ b/lib/DB/Schema/Result/Attempt.pm @@ -59,7 +59,7 @@ Note: a problem should have only one of a library_id, problem_path or problem_po __PACKAGE__->table('attempt'); -__PACKAGE__->load_components('InflateColumn::Serializer', 'Core'); +__PACKAGE__->load_components(qw/InflateColumn::Serializer Core/); __PACKAGE__->add_columns( attempt_id => { diff --git a/lib/DB/Schema/Result/CourseSettings.pm b/lib/DB/Schema/Result/CourseSettings.pm index eacdb07e..fbcbc0a7 100644 --- a/lib/DB/Schema/Result/CourseSettings.pm +++ b/lib/DB/Schema/Result/CourseSettings.pm @@ -49,7 +49,7 @@ C: a JSON object that stores email settings __PACKAGE__->table('course_settings'); -__PACKAGE__->load_components('InflateColumn::Serializer', 'Core'); +__PACKAGE__->load_components(qw/InflateColumn::Serializer Core/); __PACKAGE__->add_columns( course_settings_id => { diff --git a/lib/DB/Schema/Result/CourseUser.pm b/lib/DB/Schema/Result/CourseUser.pm index 123266eb..ceb52c97 100644 --- a/lib/DB/Schema/Result/CourseUser.pm +++ b/lib/DB/Schema/Result/CourseUser.pm @@ -88,7 +88,7 @@ C: whether or not the user shows old answer (boolean) __PACKAGE__->table('course_user'); -__PACKAGE__->load_components('InflateColumn::Serializer', 'Core'); +__PACKAGE__->load_components(qw/InflateColumn::Serializer Core/); __PACKAGE__->add_columns( course_user_id => { diff --git a/lib/DB/Schema/Result/PoolProblem.pm b/lib/DB/Schema/Result/PoolProblem.pm index 13855576..728e4706 100644 --- a/lib/DB/Schema/Result/PoolProblem.pm +++ b/lib/DB/Schema/Result/PoolProblem.pm @@ -48,7 +48,7 @@ Note: the C can only have one of the two fields __PACKAGE__->table('pool_problem'); -__PACKAGE__->load_components('InflateColumn::Serializer', 'Core'); +__PACKAGE__->load_components(qw/InflateColumn::Serializer Core/); __PACKAGE__->add_columns( pool_problem_id => { diff --git a/lib/DB/Schema/Result/ProblemSet.pm b/lib/DB/Schema/Result/ProblemSet.pm index e2f620dc..57664aef 100644 --- a/lib/DB/Schema/Result/ProblemSet.pm +++ b/lib/DB/Schema/Result/ProblemSet.pm @@ -71,11 +71,9 @@ L which gives properties common to re =cut -__PACKAGE__->load_components(qw/DynamicSubclass Core/); - __PACKAGE__->table('problem_set'); -__PACKAGE__->load_components(qw/DynamicSubclass Core/, qw/InflateColumn::Serializer Core/); +__PACKAGE__->load_components(qw/DynamicSubclass Core InflateColumn::Serializer InflateColumn::Boolean Core/); __PACKAGE__->add_columns( set_id => { diff --git a/lib/DB/Schema/Result/SetProblem.pm b/lib/DB/Schema/Result/SetProblem.pm index 00c4855c..8b616373 100644 --- a/lib/DB/Schema/Result/SetProblem.pm +++ b/lib/DB/Schema/Result/SetProblem.pm @@ -65,7 +65,7 @@ Note: a problem should have only one of a library_id, problem_path or problem_po __PACKAGE__->table('set_problem'); -__PACKAGE__->load_components('InflateColumn::Serializer', 'Core'); +__PACKAGE__->load_components(qw/InflateColumn::Serializer Core/); __PACKAGE__->add_columns( set_problem_id => { diff --git a/lib/DB/Schema/Result/UserProblem.pm b/lib/DB/Schema/Result/UserProblem.pm index 5633ee7d..381c3480 100644 --- a/lib/DB/Schema/Result/UserProblem.pm +++ b/lib/DB/Schema/Result/UserProblem.pm @@ -15,7 +15,7 @@ use base qw/DBIx::Class::Core DB::Validation/; __PACKAGE__->table('user_problem'); -__PACKAGE__->load_components('InflateColumn::Serializer', 'Core'); +__PACKAGE__->load_components(qw/InflateColumn::Serializer Core/); __PACKAGE__->add_columns( user_problem_id => { diff --git a/lib/DB/Schema/Result/UserSet.pm b/lib/DB/Schema/Result/UserSet.pm index 2bed2a10..4df5a9a8 100644 --- a/lib/DB/Schema/Result/UserSet.pm +++ b/lib/DB/Schema/Result/UserSet.pm @@ -58,7 +58,7 @@ types have different params fields. __PACKAGE__->table('user_set'); -__PACKAGE__->load_components('InflateColumn::Serializer', 'Core'); +__PACKAGE__->load_components(qw/InflateColumn::Serializer InflateColumn::Boolean Core/); __PACKAGE__->add_columns( user_set_id => { diff --git a/t/db/001_courses.t b/t/db/001_courses.t index 0b2b72d8..65f1b7bb 100644 --- a/t/db/001_courses.t +++ b/t/db/001_courses.t @@ -18,6 +18,7 @@ use Test::More; use Test::Exception; use YAML::XS qw/LoadFile/; use DateTime::Format::Strptime; +use Mojo::JSON qw/true false/; use DB::Schema; @@ -90,7 +91,7 @@ throws_ok { # Add a course my $new_course_params = { course_name => 'Geometry', - visible => 1, + visible => true, course_dates => {} }; diff --git a/t/db/004_course_users.t b/t/db/004_course_users.t index b79c4aa9..0aca1109 100644 --- a/t/db/004_course_users.t +++ b/t/db/004_course_users.t @@ -42,7 +42,7 @@ my $user_rs = $schema->resultset('User'); # Get a list of users from the CSV file my @students = loadCSV("$main::ww3_dir/t/db/sample_data/students.csv"); for my $student (@students) { - $student->{is_admin} = 0; + $student->{is_admin} = false; $student->{course_user_params} = $student->{params}; delete $student->{params}; } @@ -124,7 +124,7 @@ my $user_params = { last_name => 'Quimby', email => 'mayor_joe@springfield.gov', student_id => '12345', - is_admin => 0 + is_admin => false }; my $course_user_params = { diff --git a/t/db/006_quizzes.t b/t/db/006_quizzes.t index 7ca3abc8..0a89267f 100644 --- a/t/db/006_quizzes.t +++ b/t/db/006_quizzes.t @@ -45,7 +45,13 @@ my $user_rs = $schema->resultset('User'); my @all_problem_sets; -my @quizzes = loadCSV("$main::ww3_dir/t/db/sample_data/quizzes.csv"); +my @quizzes = loadCSV( + "$main::ww3_dir/t/db/sample_data/quizzes.csv", + { + boolean_fields => ['set_visible'], + param_boolean_fields => ['timed'] + } +); for my $quiz (@quizzes) { $quiz->{set_type} = 'QUIZ'; } @@ -248,7 +254,7 @@ my $updated_quiz = $problem_set_rs->updateProblemSet( params => $updated_params ); -$new_quiz->{set_visible} = 0; +$new_quiz->{set_visible} = false; $new_quiz->{set_params} = {}; removeIDs($updated_quiz); is_deeply($new_quiz, $updated_quiz, 'updateQuiz: successfully update the quiz'); diff --git a/t/mojolicious/001_login.t b/t/mojolicious/001_login.t index 6efa4da1..8b1c4507 100644 --- a/t/mojolicious/001_login.t +++ b/t/mojolicious/001_login.t @@ -5,8 +5,7 @@ use Mojo::Base -strict; use Test::More; use Test::Mojo; use YAML::XS qw/LoadFile/; - -use YAML::XS qw/LoadFile/; +use Mojo::JSON qw/true false/; BEGIN { use File::Basename qw/dirname/; @@ -36,11 +35,11 @@ $t->post_ok('/webwork3/api/login')->status_is(500, 'error status')->content_type $t->post_ok('/webwork3/api/login' => json => { username => 'lisa', password => 'lisa' })->status_is(200) ->content_type_is('application/json;charset=UTF-8')->json_is( '' => { - logged_in => 1, + logged_in => true, user => { email => 'lisa@google.com', first_name => 'Lisa', - is_admin => 0, + is_admin => false, last_name => 'Simpson', student_id => '23', user_id => 3, @@ -53,7 +52,7 @@ $t->post_ok('/webwork3/api/login' => json => { username => 'lisa', password => ' # Test logout $t->post_ok('/webwork3/api/logout')->status_is(200)->content_type_is('application/json;charset=UTF-8')->json_is( '' => { - logged_in => 0, + logged_in => false, message => 'Successfully logged out.' }, 'logout' @@ -63,7 +62,7 @@ $t->post_ok('/webwork3/api/logout')->status_is(200)->content_type_is('applicatio $t->post_ok('/webwork3/api/login' => json => { username => 'lisa', password => 'wrong_password' })->status_is(200) ->content_type_is('application/json;charset=UTF-8')->json_is( '' => { - logged_in => 0, + logged_in => false, message => 'Incorrect username or password.' }, 'invalid credentials' diff --git a/t/mojolicious/002_courses.t b/t/mojolicious/002_courses.t index bf84f35a..0626865a 100644 --- a/t/mojolicious/002_courses.t +++ b/t/mojolicious/002_courses.t @@ -28,14 +28,14 @@ my $t = Test::Mojo->new(WeBWorK3 => $config); # Authenticate with the admin user. $t->post_ok('/webwork3/api/login' => json => { username => 'admin', password => 'admin' })->status_is(200) - ->content_type_is('application/json;charset=UTF-8')->json_is('/logged_in' => 1)->json_is('/user/user_id' => 1) - ->json_is('/user/is_admin' => 1); + ->content_type_is('application/json;charset=UTF-8')->json_is('/logged_in' => true)->json_is('/user/user_id' => 1) + ->json_is('/user/is_admin' => true); $t->get_ok('/webwork3/api/courses')->content_type_is('application/json;charset=UTF-8') - ->json_is('/0/course_name' => 'Precalculus')->json_is('/0/visible' => 1); + ->json_is('/0/course_name' => 'Precalculus')->json_is('/0/visible' => true); $t->get_ok('/webwork3/api/courses/1')->content_type_is('application/json;charset=UTF-8') - ->json_is('/course_name' => 'Precalculus')->json_is('/visible' => 1); + ->json_is('/course_name' => 'Precalculus')->json_is('/visible' => true); # Add a new course my $new_course = { @@ -124,8 +124,8 @@ $t->get_ok('/webwork3/api/courses/4/settings')->status_is(200)->content_type_is( $t->post_ok('/webwork3/api/courses' => json => $new_course)->status_is(403)->json_is('/has_permission' => 0); $t->put_ok('/webwork3/api/courses/4' => json => { course_name => 'XXX' })->status_is(403) - ->json_is('/has_permission' => false); + ->json_is('/has_permission' => 0); -$t->delete_ok('/webwork3/api/courses/4')->status_is(403)->json_is('/has_permission' => false); +$t->delete_ok('/webwork3/api/courses/4')->status_is(403)->json_is('/has_permission' => 0); done_testing; diff --git a/t/mojolicious/003_users.t b/t/mojolicious/003_users.t index 1e2ded44..b35681ec 100644 --- a/t/mojolicious/003_users.t +++ b/t/mojolicious/003_users.t @@ -38,8 +38,8 @@ my $t = Test::Mojo->new(WeBWorK3 => $config); # Test all of the user routes with an admin user. $t->post_ok('/webwork3/api/login' => json => { username => 'admin', password => 'admin' })->status_is(200) - ->content_type_is('application/json;charset=UTF-8')->json_is('/logged_in' => 1)->json_is('/user/user_id' => 1) - ->json_is('/user/is_admin' => 1); + ->content_type_is('application/json;charset=UTF-8')->json_is('/logged_in' => true)->json_is('/user/user_id' => 1) + ->json_is('/user/is_admin' => true); my @all_users = $schema->resultset('User')->getAllGlobalUsers(); @@ -56,7 +56,7 @@ my $new_user = { last_name => 'Simpson', username => 'maggie', student_id => '1234123423', - is_admin => 0 + is_admin => false }; $t->post_ok('/webwork3/api/users' => json => $new_user)->status_is(200) @@ -158,10 +158,10 @@ $t->delete_ok("/webwork3/api/users/$another_new_user_id")->status_is(200) # Test that a non-admin user cannot access all of the routes # Logout the admin user and relogin as a non-admin. -$t->post_ok('/webwork3/api/logout')->status_is(200)->json_is('/logged_in' => 0); +$t->post_ok('/webwork3/api/logout')->status_is(200)->json_is('/logged_in' => false); $t->post_ok('/webwork3/api/login' => json => { username => 'lisa', password => 'lisa' })->status_is(200) - ->content_type_is('application/json;charset=UTF-8')->json_is('/logged_in' => 1) - ->json_is('/user/username' => 'lisa')->json_is('/user/is_admin' => 0); + ->content_type_is('application/json;charset=UTF-8')->json_is('/logged_in' => true) + ->json_is('/user/username' => 'lisa')->json_is('/user/is_admin' => false); $t->get_ok('/webwork3/api/users')->content_type_is('application/json;charset=UTF-8')->status_is(403) ->json_is('/has_permission' => 0); @@ -182,7 +182,7 @@ $t->delete_ok('/webwork3/api/users/1')->content_type_is('application/json;charse $t->get_ok('/webwork3/api/users/3/courses')->status_is(200)->content_type_is('application/json;charset=UTF-8'); # Relogin as the admin and delete the added users -$t->post_ok('/webwork3/api/logout')->status_is(200)->json_is('/logged_in' => 0); +$t->post_ok('/webwork3/api/logout')->status_is(200)->json_is('/logged_in' => false); $t->post_ok('/webwork3/api/login' => json => { username => 'admin', password => 'admin' })->status_is(200); # The following routes test that global users can be handled by an instructor in the course diff --git a/t/mojolicious/008_problems.t b/t/mojolicious/008_problems.t index 72fbb83c..0e130aa5 100644 --- a/t/mojolicious/008_problems.t +++ b/t/mojolicious/008_problems.t @@ -41,8 +41,8 @@ my $t = Test::Mojo->new(WeBWorK3 => $config); # First run tests as logged in as an instructor $t->post_ok('/webwork3/api/login' => json => { username => 'lisa', password => 'lisa' })->status_is(200) - ->content_type_is('application/json;charset=UTF-8')->json_is('/logged_in' => 1) - ->json_is('/user/username' => 'lisa')->json_is('/user/is_admin' => 0); + ->content_type_is('application/json;charset=UTF-8')->json_is('/logged_in' => true) + ->json_is('/user/username' => 'lisa')->json_is('/user/is_admin' => false); # Load all problems from the CVS files. my @problems_from_csv = loadCSV( @@ -111,10 +111,10 @@ $t->put_ok( ->json_is('/problem_number' => $new_problem->{problem_number})->json_is('/problem_params/weight' => 3); # Make sure that a student cannot access the global problem routes -$t->post_ok('/webwork3/api/logout')->status_is(200)->json_is('/logged_in' => 0); +$t->post_ok('/webwork3/api/logout')->status_is(200)->json_is('/logged_in' => false); $t->post_ok('/webwork3/api/login' => json => { username => 'ralph', password => 'ralph' })->status_is(200) - ->content_type_is('application/json;charset=UTF-8')->json_is('/logged_in' => 1) - ->json_is('/user/username' => 'ralph')->json_is('/user/is_admin' => 0); + ->content_type_is('application/json;charset=UTF-8')->json_is('/logged_in' => true) + ->json_is('/user/username' => 'ralph')->json_is('/user/is_admin' => false); my $logged_in_user = $t->tx->res->json('/user'); @@ -157,10 +157,10 @@ $t->delete_ok("/webwork3/api/courses/4/sets/$hw1->{set_id}/problems/$new_problem # Make sure that a student not enrolled in the course has access to getting global problems # for that course. -$t->post_ok('/webwork3/api/logout')->status_is(200)->json_is('/logged_in' => 0); +$t->post_ok('/webwork3/api/logout')->status_is(200)->json_is('/logged_in' => false); $t->post_ok('/webwork3/api/login' => json => { username => 'ned', password => 'ned' })->status_is(200) - ->content_type_is('application/json;charset=UTF-8')->json_is('/logged_in' => 1)->json_is('/user/username' => 'ned') - ->json_is('/user/is_admin' => 0); + ->content_type_is('application/json;charset=UTF-8')->json_is('/logged_in' => true) + ->json_is('/user/username' => 'ned')->json_is('/user/is_admin' => false); $logged_in_user = $t->tx->res->json('/user'); @@ -174,7 +174,7 @@ is(scalar(grep { $_->{course_name} eq 'Arithmetic' } @$user_courses), 0, 'The us $t->get_ok('/webwork3/api/courses/4/problems')->status_is(403)->content_type_is('application/json;charset=UTF-8'); # Finally, delete the new problem to restore the db to it's pretest state. -$t->post_ok('/webwork3/api/logout')->status_is(200)->json_is('/logged_in' => 0); +$t->post_ok('/webwork3/api/logout')->status_is(200)->json_is('/logged_in' => false); $t->post_ok('/webwork3/api/login' => json => { username => 'admin', password => 'admin' })->status_is(200); $t->delete_ok("/webwork3/api/courses/4/sets/$hw1->{set_id}/problems/$new_problem->{set_problem_id}")->status_is(200) diff --git a/t/mojolicious/009_user_problems.t b/t/mojolicious/009_user_problems.t index 7066715a..1210baab 100644 --- a/t/mojolicious/009_user_problems.t +++ b/t/mojolicious/009_user_problems.t @@ -41,8 +41,8 @@ my $t = Test::Mojo->new(WeBWorK3 => $config); # First run tests as logged in as an instructor $t->post_ok('/webwork3/api/login' => json => { username => 'lisa', password => 'lisa' })->status_is(200) - ->content_type_is('application/json;charset=UTF-8')->json_is('/logged_in' => 1) - ->json_is('/user/username' => 'lisa')->json_is('/user/is_admin' => 0); + ->content_type_is('application/json;charset=UTF-8')->json_is('/logged_in' => true) + ->json_is('/user/username' => 'lisa')->json_is('/user/is_admin' => false); # Load all problems from the CVS files. my @problems_from_csv = loadCSV( @@ -174,7 +174,7 @@ $t->put_ok( ->json_is('/seed' => 789); # Check that a student has the correct access -$t->post_ok('/webwork3/api/logout')->status_is(200)->json_is('/logged_in' => 0); +$t->post_ok('/webwork3/api/logout')->status_is(200)->json_is('/logged_in' => false); $t->post_ok('/webwork3/api/login' => json => { username => 'ralph', password => 'ralph' })->status_is(200); # get all of ralph's problems @@ -208,7 +208,7 @@ $t->delete_ok( ->status_is(403); # Make sure that a user that is in the course, cannot get or update a user problem that is not one's own. -$t->post_ok('/webwork3/api/logout')->status_is(200)->json_is('/logged_in' => 0); +$t->post_ok('/webwork3/api/logout')->status_is(200)->json_is('/logged_in' => false); $t->post_ok('/webwork3/api/login' => json => { username => 'moe', password => 'moe' })->status_is(200); # Check that moe is in the course @@ -233,7 +233,7 @@ $t->put_ok( => json => { status => 0.5 })->status_is(403); # Switch back to the instructor and delete the user problem -$t->post_ok('/webwork3/api/logout')->status_is(200)->json_is('/logged_in' => 0); +$t->post_ok('/webwork3/api/logout')->status_is(200)->json_is('/logged_in' => false); $t->post_ok('/webwork3/api/login' => json => { username => 'lisa', password => 'lisa' })->status_is(200); $t->delete_ok( diff --git a/t/mojolicious/010_problem_pools.t b/t/mojolicious/010_problem_pools.t index 83e3e992..917780b0 100644 --- a/t/mojolicious/010_problem_pools.t +++ b/t/mojolicious/010_problem_pools.t @@ -150,7 +150,7 @@ $t->put_ok( )->status_is(200)->content_type_is('application/json;charset=UTF-8')->json_is('/params/library_id' => 8932); # Make sure that students don't have access to Problem Pools -$t->post_ok('/webwork3/api/logout')->status_is(200)->json_is('/logged_in' => 0); +$t->post_ok('/webwork3/api/logout')->status_is(200)->json_is('/logged_in' => false); $t->post_ok('/webwork3/api/login' => json => { username => 'ralph', password => 'ralph' })->status_is(200); $t->get_ok('/webwork3/api/courses/4/pools')->status_is(403); @@ -189,7 +189,7 @@ $t->delete_ok( )->status_is(403); # Cleanup. Log back in as the instructor and delete added pool and problem -$t->post_ok('/webwork3/api/logout')->status_is(200)->json_is('/logged_in' => 0); +$t->post_ok('/webwork3/api/logout')->status_is(200)->json_is('/logged_in' => false); $t->post_ok('/webwork3/api/login' => json => { username => 'lisa', password => 'lisa' })->status_is(200); # Delete the pool problem.