From 1374c7283a607b1c1e71037a56861bb55386185c Mon Sep 17 00:00:00 2001 From: IDzyre Date: Thu, 6 Mar 2025 19:05:36 -0300 Subject: [PATCH 01/73] Add home creation ansible script --- .../playbooks/submitty_homework_creation.yml | 22 +++ .../files/config_files/file_homework.json | 162 ++++++++++++++++++ .../files/json_list.txt | 1 + .../tasks/create_gradeable.yml | 16 ++ .../submitty_homework_creation/tasks/main.yml | 34 ++++ 5 files changed, 235 insertions(+) create mode 100644 .setup/ansible/playbooks/submitty_homework_creation.yml create mode 100644 .setup/ansible/roles/submitty_homework_creation/files/config_files/file_homework.json create mode 100644 .setup/ansible/roles/submitty_homework_creation/files/json_list.txt create mode 100644 .setup/ansible/roles/submitty_homework_creation/tasks/create_gradeable.yml create mode 100644 .setup/ansible/roles/submitty_homework_creation/tasks/main.yml diff --git a/.setup/ansible/playbooks/submitty_homework_creation.yml b/.setup/ansible/playbooks/submitty_homework_creation.yml new file mode 100644 index 00000000000..2a4d42754f1 --- /dev/null +++ b/.setup/ansible/playbooks/submitty_homework_creation.yml @@ -0,0 +1,22 @@ +--- +- name: Submitty Homework Creation + hosts: localhost + connection: local + + roles: + # This role is defined in the Submitty Repo under .setup/ansible/roles + - role: submitty_homework_api # noqa syntax-check[specific] + - role: submitty_homework_api # noqa syntax-check[specific] + vars: + vcs: https://github.com/IDzyre/Tutorial.git # This is a fork of the Submitty tutorial repository with an added folder for the config files, I will ask on Monday if I could/should put it in the actual tutorial repository. + + vars_prompt: + - name: api_url + prompt: Enter the full API url (http://{domain.com}/api/{semester}/{course}/upload) + private: no + - name: passed_api_key + prompt: Enter your API key + private: yes + - name: vcs + prompt: Enter clone URL for Git repository if you are using one + private: no diff --git a/.setup/ansible/roles/submitty_homework_creation/files/config_files/file_homework.json b/.setup/ansible/roles/submitty_homework_creation/files/config_files/file_homework.json new file mode 100644 index 00000000000..9f7ec77f51b --- /dev/null +++ b/.setup/ansible/roles/submitty_homework_creation/files/config_files/file_homework.json @@ -0,0 +1,162 @@ +{ + "title": "Homework from file", + "type": "Electronic File", + "id": "file_homework", + "instructions_url": "", + "syllabus_bucket": "homework", + "autograding_config_path": "\/usr\/local\/submitty\/more_autograding_examples\/python_simple_homework\/config", + "bulk_upload": false, + "ta_grading": "true", + "grade_inquiries": "true", + "dates": { + "ta_view_start_date": "1970-01-01 23:59:59", + "grade_start_date": "9997-12-31 23:59:59", + "grade_due_date": "9998-12-31 23:59:59", + "grade_released_date": "9998-12-31 23:59:59", + "team_lock_date": "1971-01-01 23:59:59", + "submission_open_date": "1971-01-01 23:59:59", + "submission_due_date": "9996-12-31 23:59:59", + "grade_inquiry_start_date": "9999-01-01 23:59:59", + "grade_inquiry_due_date": "9999-01-06 23:59:59", + "has_due_date": true, + "has_release_date": true, + "late_submission_allowed": true, + "late_days": 0 + }, + "rubric": [ + { + "title": "Read Me", + "ta_comment": "Reward student for including docstrings.", + "student_comment": "Code should be organized into logical and intuitive functions.", + "lower_clamp": 0, + "default": 2, + "max_value": 2, + "upper_clamp": 2, + "text": false, + "peer_component": false, + "page": 0, + "is_itempool_linked": false, + "itempool": "", + "marks": [ + { + "points": 0, + "title": "Full Credit", + "publish": false + }, + { + "points": -1, + "title": "Minor errors in Read Me", + "publish": false + }, + { + "points": -2, + "title": "Major errors in Read Me or Read Me missing", + "publish": false + } + ] + }, + { + "title": "Coding Style", + "ta_comment": "Deduct points if the student uses global variables.", + "student_comment": "The use of builtin functions is prohibited for this exercise.", + "lower_clamp": 0, + "default": 5, + "max_value": 5, + "upper_clamp": 5, + "text": false, + "peer_component": false, + "page": 0, + "is_itempool_linked": false, + "itempool": "", + "marks": [ + { + "points": 0, + "title": "Full Credit", + "publish": false + }, + { + "points": -5, + "title": "Code is unreadable", + "publish": false + }, + { + "points": -3, + "title": "Code is very difficult to understand", + "publish": false + }, + { + "points": -1, + "title": "Code is difficult to understand", + "publish": false + } + ] + }, + { + "title": "Documentation", + "ta_comment": "Reward student for properly using divide and conquer in code.", + "student_comment": "Code should be broken down into functions that each solve a part of the problem.", + "lower_clamp": 0, + "default": 5, + "max_value": 5, + "upper_clamp": 5, + "text": false, + "peer_component": false, + "page": 0, + "is_itempool_linked": false, + "itempool": "", + "marks": [ + { + "points": 0, + "title": "Full Credit", + "publish": false + }, + { + "points": -5, + "title": "No documentation", + "publish": false + }, + { + "points": -3, + "title": "Very little documentation or documentation makes no sense", + "publish": false + }, + { + "points": -1, + "title": "Way too much documentation and\/or documentation makes no sense", + "publish": false + } + ] + }, + { + "title": "Extra Credit", + "ta_comment": "Deduct points if the student uses global variables.", + "student_comment": "A switch case should be used and not the if-else structure.", + "lower_clamp": 0, + "default": 0, + "max_value": 0, + "upper_clamp": 5, + "text": false, + "peer_component": false, + "page": 0, + "is_itempool_linked": false, + "itempool": "", + "marks": [ + { + "points": 0, + "title": "No Credit", + "publish": false + }, + { + "points": 2, + "title": "Extra credit done poorly", + "publish": false + }, + { + "points": 5, + "title": "Extra credit is acceptable", + "publish": false + } + ] + } + ] +} \ No newline at end of file diff --git a/.setup/ansible/roles/submitty_homework_creation/files/json_list.txt b/.setup/ansible/roles/submitty_homework_creation/files/json_list.txt new file mode 100644 index 00000000000..b22ba4b175c --- /dev/null +++ b/.setup/ansible/roles/submitty_homework_creation/files/json_list.txt @@ -0,0 +1 @@ +config_files/file_homework.json \ No newline at end of file diff --git a/.setup/ansible/roles/submitty_homework_creation/tasks/create_gradeable.yml b/.setup/ansible/roles/submitty_homework_creation/tasks/create_gradeable.yml new file mode 100644 index 00000000000..e79e7f15571 --- /dev/null +++ b/.setup/ansible/roles/submitty_homework_creation/tasks/create_gradeable.yml @@ -0,0 +1,16 @@ +- name: Create gradeables with API + ansible.builtin.uri: + url: "{{ api_url }}" + method: POST + body_format: json + body: "{{ lookup('file', var_json_file) }}" + return_content: yes + headers: + Authorization: "{{ api_key }}" + register: api_response + +- name: Fail when status is error + fail: + msg: "{{ (api_response.content | from_json).message }}" + when: + - (api_response.content | from_json).status != 'success' diff --git a/.setup/ansible/roles/submitty_homework_creation/tasks/main.yml b/.setup/ansible/roles/submitty_homework_creation/tasks/main.yml new file mode 100644 index 00000000000..6574bd701bf --- /dev/null +++ b/.setup/ansible/roles/submitty_homework_creation/tasks/main.yml @@ -0,0 +1,34 @@ +- name: Checkout repository containing config files + ansible.builtin.git: + repo: "{{ vcs }}" + dest: /tmp/Submitty + force: yes + update: yes + when: vcs != '' + +- name: Find files in the directory + ansible.builtin.find: + paths: "/tmp/Submitty/config_files/" # Replace with your directory path + file_type: file # Ensure you're finding files (not directories) + register: json_files + when: vcs != '' + +- name: Set a variable with the list of file paths + ansible.builtin.set_fact: + var_json_list: "{{ json_files.files | map(attribute='path') | list }}" + when: vcs != '' + +- name: Read JSON content from a file + ansible.builtin.set_fact: + var_json_list: "{{ lookup('file', 'json_list.txt') | split('\n') }}" + when: vcs == '' + +- name: Use task list to loop through gradeables + ansible.builtin.include_tasks: + file: create_gradeable.yml + loop: "{{ var_json_list }}" + loop_control: + loop_var: submitty_homework_api_json_file + vars: + var_json_file: "{{ submitty_homework_api_json_file }}" + api_key: "{{ passed_api_key }}" From 9741a98b0c287ca616e1dd4e7c5220fe42a5c6b6 Mon Sep 17 00:00:00 2001 From: IDzyre Date: Thu, 6 Mar 2025 22:16:17 -0300 Subject: [PATCH 02/73] linting --- .setup/ansible/playbooks/submitty_homework_creation.yml | 8 ++++---- .../submitty_homework_creation/tasks/create_gradeable.yml | 6 +++--- .../roles/submitty_homework_creation/tasks/main.yml | 1 + 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/.setup/ansible/playbooks/submitty_homework_creation.yml b/.setup/ansible/playbooks/submitty_homework_creation.yml index 2a4d42754f1..c3035271d6d 100644 --- a/.setup/ansible/playbooks/submitty_homework_creation.yml +++ b/.setup/ansible/playbooks/submitty_homework_creation.yml @@ -2,13 +2,13 @@ - name: Submitty Homework Creation hosts: localhost connection: local - + roles: # This role is defined in the Submitty Repo under .setup/ansible/roles - - role: submitty_homework_api # noqa syntax-check[specific] - - role: submitty_homework_api # noqa syntax-check[specific] + - role: submitty_homework_api + - role: submitty_homework_api vars: - vcs: https://github.com/IDzyre/Tutorial.git # This is a fork of the Submitty tutorial repository with an added folder for the config files, I will ask on Monday if I could/should put it in the actual tutorial repository. + vcs: https://github.com/IDzyre/Tutorial.git # This is a fork of the Submitty tutorial repository with an added folder for the config files, I will ask on Monday if I could/should put it in the actual tutorial repository. vars_prompt: - name: api_url diff --git a/.setup/ansible/roles/submitty_homework_creation/tasks/create_gradeable.yml b/.setup/ansible/roles/submitty_homework_creation/tasks/create_gradeable.yml index e79e7f15571..ae22cd27d42 100644 --- a/.setup/ansible/roles/submitty_homework_creation/tasks/create_gradeable.yml +++ b/.setup/ansible/roles/submitty_homework_creation/tasks/create_gradeable.yml @@ -5,12 +5,12 @@ body_format: json body: "{{ lookup('file', var_json_file) }}" return_content: yes - headers: + headers: Authorization: "{{ api_key }}" register: api_response - name: Fail when status is error - fail: + ansible.builtin.fail: msg: "{{ (api_response.content | from_json).message }}" - when: + when: - (api_response.content | from_json).status != 'success' diff --git a/.setup/ansible/roles/submitty_homework_creation/tasks/main.yml b/.setup/ansible/roles/submitty_homework_creation/tasks/main.yml index 6574bd701bf..bb2152612b4 100644 --- a/.setup/ansible/roles/submitty_homework_creation/tasks/main.yml +++ b/.setup/ansible/roles/submitty_homework_creation/tasks/main.yml @@ -4,6 +4,7 @@ dest: /tmp/Submitty force: yes update: yes + version: "main" when: vcs != '' - name: Find files in the directory From b9211133fb5bafd8194aaa68eca098d2b651949a Mon Sep 17 00:00:00 2001 From: IDzyre Date: Fri, 7 Mar 2025 10:42:50 -0300 Subject: [PATCH 03/73] Try to fix git linting? --- .setup/ansible/playbooks/submitty_homework_creation.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.setup/ansible/playbooks/submitty_homework_creation.yml b/.setup/ansible/playbooks/submitty_homework_creation.yml index c3035271d6d..d3e99259c6a 100644 --- a/.setup/ansible/playbooks/submitty_homework_creation.yml +++ b/.setup/ansible/playbooks/submitty_homework_creation.yml @@ -5,8 +5,8 @@ roles: # This role is defined in the Submitty Repo under .setup/ansible/roles - - role: submitty_homework_api - - role: submitty_homework_api + - role: submitty_homework_creation + - role: submitty_homework_creation vars: vcs: https://github.com/IDzyre/Tutorial.git # This is a fork of the Submitty tutorial repository with an added folder for the config files, I will ask on Monday if I could/should put it in the actual tutorial repository. From f579e592b52c8939d1232c8ef5d338b14b416d51 Mon Sep 17 00:00:00 2001 From: IDzyre Date: Tue, 11 Mar 2025 15:10:11 -0300 Subject: [PATCH 04/73] Fix ansible lint --- .../ansible/playbooks/submitty_homework_creation.yml | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/.setup/ansible/playbooks/submitty_homework_creation.yml b/.setup/ansible/playbooks/submitty_homework_creation.yml index d3e99259c6a..832ecaad53b 100644 --- a/.setup/ansible/playbooks/submitty_homework_creation.yml +++ b/.setup/ansible/playbooks/submitty_homework_creation.yml @@ -3,10 +3,14 @@ hosts: localhost connection: local - roles: + tasks: # This role is defined in the Submitty Repo under .setup/ansible/roles - - role: submitty_homework_creation - - role: submitty_homework_creation + - name: Create gradeable + ansible.builtin.include_role: + name: submitty_homework_creation + - name: Create gradeable + ansible.builtin.include_role: + name: submitty_homework_creation vars: vcs: https://github.com/IDzyre/Tutorial.git # This is a fork of the Submitty tutorial repository with an added folder for the config files, I will ask on Monday if I could/should put it in the actual tutorial repository. From 6195ef0067594294db225c9dbaa1f3a408642750 Mon Sep 17 00:00:00 2001 From: IDzyre Date: Tue, 11 Mar 2025 18:23:49 -0300 Subject: [PATCH 05/73] Change variable names --- .setup/ansible/playbooks/submitty_homework_creation.yml | 6 +++--- .../submitty_homework_creation/tasks/create_gradeable.yml | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.setup/ansible/playbooks/submitty_homework_creation.yml b/.setup/ansible/playbooks/submitty_homework_creation.yml index 832ecaad53b..38408b9e111 100644 --- a/.setup/ansible/playbooks/submitty_homework_creation.yml +++ b/.setup/ansible/playbooks/submitty_homework_creation.yml @@ -15,12 +15,12 @@ vcs: https://github.com/IDzyre/Tutorial.git # This is a fork of the Submitty tutorial repository with an added folder for the config files, I will ask on Monday if I could/should put it in the actual tutorial repository. vars_prompt: - - name: api_url + - name: submitty_homework_creation_api_url prompt: Enter the full API url (http://{domain.com}/api/{semester}/{course}/upload) private: no - - name: passed_api_key + - name: submitty_homework_creation_passed_api_key prompt: Enter your API key private: yes - - name: vcs + - name: submitty_homework_creation_vcs prompt: Enter clone URL for Git repository if you are using one private: no diff --git a/.setup/ansible/roles/submitty_homework_creation/tasks/create_gradeable.yml b/.setup/ansible/roles/submitty_homework_creation/tasks/create_gradeable.yml index ae22cd27d42..4375810b7a1 100644 --- a/.setup/ansible/roles/submitty_homework_creation/tasks/create_gradeable.yml +++ b/.setup/ansible/roles/submitty_homework_creation/tasks/create_gradeable.yml @@ -1,12 +1,12 @@ - name: Create gradeables with API ansible.builtin.uri: - url: "{{ api_url }}" + url: "{{ submitty_homework_creation_api_url }}" method: POST body_format: json body: "{{ lookup('file', var_json_file) }}" return_content: yes headers: - Authorization: "{{ api_key }}" + Authorization: "{{ submitty_homework_creation_api_key }}" register: api_response - name: Fail when status is error From e31dc0953b97cca3a5e1f8830dc24e46d843ee80 Mon Sep 17 00:00:00 2001 From: IDzyre Date: Fri, 25 Apr 2025 19:55:30 -0300 Subject: [PATCH 06/73] Remove git support --- .../playbooks/submitty_homework_creation.yml | 8 ------- .../submitty_homework_creation/tasks/main.yml | 22 ------------------- 2 files changed, 30 deletions(-) diff --git a/.setup/ansible/playbooks/submitty_homework_creation.yml b/.setup/ansible/playbooks/submitty_homework_creation.yml index 38408b9e111..86e03678c21 100644 --- a/.setup/ansible/playbooks/submitty_homework_creation.yml +++ b/.setup/ansible/playbooks/submitty_homework_creation.yml @@ -8,11 +8,6 @@ - name: Create gradeable ansible.builtin.include_role: name: submitty_homework_creation - - name: Create gradeable - ansible.builtin.include_role: - name: submitty_homework_creation - vars: - vcs: https://github.com/IDzyre/Tutorial.git # This is a fork of the Submitty tutorial repository with an added folder for the config files, I will ask on Monday if I could/should put it in the actual tutorial repository. vars_prompt: - name: submitty_homework_creation_api_url @@ -21,6 +16,3 @@ - name: submitty_homework_creation_passed_api_key prompt: Enter your API key private: yes - - name: submitty_homework_creation_vcs - prompt: Enter clone URL for Git repository if you are using one - private: no diff --git a/.setup/ansible/roles/submitty_homework_creation/tasks/main.yml b/.setup/ansible/roles/submitty_homework_creation/tasks/main.yml index bb2152612b4..4cfdfaa02bd 100644 --- a/.setup/ansible/roles/submitty_homework_creation/tasks/main.yml +++ b/.setup/ansible/roles/submitty_homework_creation/tasks/main.yml @@ -1,28 +1,6 @@ -- name: Checkout repository containing config files - ansible.builtin.git: - repo: "{{ vcs }}" - dest: /tmp/Submitty - force: yes - update: yes - version: "main" - when: vcs != '' - -- name: Find files in the directory - ansible.builtin.find: - paths: "/tmp/Submitty/config_files/" # Replace with your directory path - file_type: file # Ensure you're finding files (not directories) - register: json_files - when: vcs != '' - -- name: Set a variable with the list of file paths - ansible.builtin.set_fact: - var_json_list: "{{ json_files.files | map(attribute='path') | list }}" - when: vcs != '' - - name: Read JSON content from a file ansible.builtin.set_fact: var_json_list: "{{ lookup('file', 'json_list.txt') | split('\n') }}" - when: vcs == '' - name: Use task list to loop through gradeables ansible.builtin.include_tasks: From fdae65e2e15e6ec7f3b416c523f5f9d6441d6de2 Mon Sep 17 00:00:00 2001 From: IDzyre Date: Fri, 25 Apr 2025 20:05:51 -0300 Subject: [PATCH 07/73] Fix linting --- .setup/ansible/playbooks/submitty_homework_creation.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.setup/ansible/playbooks/submitty_homework_creation.yml b/.setup/ansible/playbooks/submitty_homework_creation.yml index 86e03678c21..95738afd859 100644 --- a/.setup/ansible/playbooks/submitty_homework_creation.yml +++ b/.setup/ansible/playbooks/submitty_homework_creation.yml @@ -6,7 +6,7 @@ tasks: # This role is defined in the Submitty Repo under .setup/ansible/roles - name: Create gradeable - ansible.builtin.include_role: + ansible.builtin.include_role: name: submitty_homework_creation vars_prompt: From 8caa9073426b30bf683e705b95df1cbef85ef860 Mon Sep 17 00:00:00 2001 From: IDzyre Date: Tue, 27 May 2025 22:21:51 -0300 Subject: [PATCH 08/73] Change json list file formatting --- .../roles/submitty_homework_creation/files/json_list.txt | 2 +- .setup/ansible/roles/submitty_homework_creation/tasks/main.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.setup/ansible/roles/submitty_homework_creation/files/json_list.txt b/.setup/ansible/roles/submitty_homework_creation/files/json_list.txt index b22ba4b175c..c2da9456261 100644 --- a/.setup/ansible/roles/submitty_homework_creation/files/json_list.txt +++ b/.setup/ansible/roles/submitty_homework_creation/files/json_list.txt @@ -1 +1 @@ -config_files/file_homework.json \ No newline at end of file +file_homework.json \ No newline at end of file diff --git a/.setup/ansible/roles/submitty_homework_creation/tasks/main.yml b/.setup/ansible/roles/submitty_homework_creation/tasks/main.yml index 4cfdfaa02bd..3c1ce9adfa7 100644 --- a/.setup/ansible/roles/submitty_homework_creation/tasks/main.yml +++ b/.setup/ansible/roles/submitty_homework_creation/tasks/main.yml @@ -1,6 +1,6 @@ - name: Read JSON content from a file ansible.builtin.set_fact: - var_json_list: "{{ lookup('file', 'json_list.txt') | split('\n') }}" + var_json_list: "config_files/{{ lookup('file', 'json_list.txt') | split('\n') }}" - name: Use task list to loop through gradeables ansible.builtin.include_tasks: From a57a86dbc2be89457a5113b589d07c9da4070571 Mon Sep 17 00:00:00 2001 From: IDzyre Date: Tue, 10 Jun 2025 10:23:02 -0800 Subject: [PATCH 09/73] testing get api key --- .github/workflows/api_key.yml | 26 +++++++++++++++++++ .github/workflows/ci.yml | 9 ++++++- .../Cypress-Ansible/ansible-course.spec.js | 2 +- 3 files changed, 35 insertions(+), 2 deletions(-) create mode 100644 .github/workflows/api_key.yml diff --git a/.github/workflows/api_key.yml b/.github/workflows/api_key.yml new file mode 100644 index 00000000000..3772444e392 --- /dev/null +++ b/.github/workflows/api_key.yml @@ -0,0 +1,26 @@ +name: Fetch API Key with Auth + +on: [push, workflow_dispatch] + +jobs: + fetch_key_and_run: + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v3 + + - name: Fetch API key with basic auth + id: get_key + run: | + echo "Fetching API key with basic auth..." + API_KEY=$(curl -s -u instructor:instructor http://localhost:1511/api/key) + echo "API_KEY=$API_KEY" + echo "api_key=$API_KEY" >> "$GITHUB_OUTPUT" + + - name: Use the API key + env: + API_KEY: ${{ steps.get_key.outputs.api_key }} + run: | + echo "Using API key: $API_KEY" + # Place your logic here that uses $API_KEY diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index d86d2fc4c32..91840ae97d4 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -926,12 +926,19 @@ jobs: ssh -T localhost sudo systemctl start postgresql - - name: Run ansible script + - name: Get API key shell: bash run: | + echo "x" + + - name: Run ansible scripts + shell: bash + run: | + SEMESTER=$(python3 -c 'from datetime import datetime; today = datetime.today(); semester = ("s" if today.month < 7 else "f") + str(today.year)[-2:]; print(semester)') cd .setup/ansible ansible-playbook --private-key /home/runner/.ssh/id_rsa -e 'ansible_user=runner submitty_install_submitty_version=${{ github.sha }} submitty_install_github_url=https://github.com/${{ github.repository }}.git' -i inventory/submitty playbooks/submitty_install.yml ansible-playbook --private-key /home/runner/.ssh/id_rsa -e 'ansible_user=runner' -i inventory/submitty playbooks/submitty_course_creation.yml + ansible-playbook --private-key /home/runner/.ssh/id_rsa -e 'ansible_user=runner' -i inventory/submitty playbooks/submitty_homework_creation.yml -e "localhost/api/${SEMESTER}/course/upload" - name: Set perms shell: bash diff --git a/site/cypress/e2e/Cypress-Ansible/ansible-course.spec.js b/site/cypress/e2e/Cypress-Ansible/ansible-course.spec.js index 9b40263e7f7..93403fcfc02 100644 --- a/site/cypress/e2e/Cypress-Ansible/ansible-course.spec.js +++ b/site/cypress/e2e/Cypress-Ansible/ansible-course.spec.js @@ -1,6 +1,6 @@ describe('Testing website when created by ansible scripts', () => { it('Should be able to login and see the course', () => { cy.login('instructor'); - cy.visit('term', 'course'); + cy.visit('term/course'); }); }); From 475d2516734b6571e68d764c15621dcfb3d09eb4 Mon Sep 17 00:00:00 2001 From: IDzyre Date: Tue, 10 Jun 2025 10:24:57 -0800 Subject: [PATCH 10/73] testing get api key --- .github/workflows/api_key.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/api_key.yml b/.github/workflows/api_key.yml index 3772444e392..1804bfe74dc 100644 --- a/.github/workflows/api_key.yml +++ b/.github/workflows/api_key.yml @@ -14,6 +14,7 @@ jobs: id: get_key run: | echo "Fetching API key with basic auth..." + curl -s http://localhost:1511/api/key API_KEY=$(curl -s -u instructor:instructor http://localhost:1511/api/key) echo "API_KEY=$API_KEY" echo "api_key=$API_KEY" >> "$GITHUB_OUTPUT" From 591c612712f0d266effe67dde8a0e0340c5db57a Mon Sep 17 00:00:00 2001 From: IDzyre Date: Tue, 10 Jun 2025 10:37:25 -0800 Subject: [PATCH 11/73] testing get api key --- .github/workflows/api_key.yml | 27 --------------------------- .github/workflows/ci.yml | 16 ++++++++++------ site/cypress/support/utils.js | 1 + 3 files changed, 11 insertions(+), 33 deletions(-) delete mode 100644 .github/workflows/api_key.yml diff --git a/.github/workflows/api_key.yml b/.github/workflows/api_key.yml deleted file mode 100644 index 1804bfe74dc..00000000000 --- a/.github/workflows/api_key.yml +++ /dev/null @@ -1,27 +0,0 @@ -name: Fetch API Key with Auth - -on: [push, workflow_dispatch] - -jobs: - fetch_key_and_run: - runs-on: ubuntu-latest - - steps: - - name: Checkout code - uses: actions/checkout@v3 - - - name: Fetch API key with basic auth - id: get_key - run: | - echo "Fetching API key with basic auth..." - curl -s http://localhost:1511/api/key - API_KEY=$(curl -s -u instructor:instructor http://localhost:1511/api/key) - echo "API_KEY=$API_KEY" - echo "api_key=$API_KEY" >> "$GITHUB_OUTPUT" - - - name: Use the API key - env: - API_KEY: ${{ steps.get_key.outputs.api_key }} - run: | - echo "Using API key: $API_KEY" - # Place your logic here that uses $API_KEY diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 91840ae97d4..0f5b449b5c2 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -926,11 +926,6 @@ jobs: ssh -T localhost sudo systemctl start postgresql - - name: Get API key - shell: bash - run: | - echo "x" - - name: Run ansible scripts shell: bash run: | @@ -938,7 +933,16 @@ jobs: cd .setup/ansible ansible-playbook --private-key /home/runner/.ssh/id_rsa -e 'ansible_user=runner submitty_install_submitty_version=${{ github.sha }} submitty_install_github_url=https://github.com/${{ github.repository }}.git' -i inventory/submitty playbooks/submitty_install.yml ansible-playbook --private-key /home/runner/.ssh/id_rsa -e 'ansible_user=runner' -i inventory/submitty playbooks/submitty_course_creation.yml - ansible-playbook --private-key /home/runner/.ssh/id_rsa -e 'ansible_user=runner' -i inventory/submitty playbooks/submitty_homework_creation.yml -e "localhost/api/${SEMESTER}/course/upload" + + - name: Get API key + shell: bash + run: | + API_KEY=(curl -s -X POST http://localhost:1511/api/token -H "Content-Type: application/x-www-form-urlencoded" -d "user_id=instructor&password=instructor" | grep -oP '"token"\s*:\s*"\K[^"]+') + + - name: Create Homework + shell: bash + run: + ansible-playbook --private-key /home/runner/.ssh/id_rsa -e 'ansible_user=runner' -i inventory/submitty playbooks/submitty_homework_creation.yml -e "localhost/api/${SEMESTER}/course/upload" -e "${API_KEY}"" - name: Set perms shell: bash diff --git a/site/cypress/support/utils.js b/site/cypress/support/utils.js index 1e1298cee9c..a82aa2a315a 100644 --- a/site/cypress/support/utils.js +++ b/site/cypress/support/utils.js @@ -43,6 +43,7 @@ export function getApiKey(user_id, password) { }).then((response) => { return response.body.data.token; }); + } /** From 737683878875c384f21d28abcbf9f6026c07c5d4 Mon Sep 17 00:00:00 2001 From: IDzyre Date: Thu, 12 Jun 2025 09:49:21 -0800 Subject: [PATCH 12/73] Testing api again --- .github/workflows/ci.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 0f5b449b5c2..175bf2522e0 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -937,12 +937,12 @@ jobs: - name: Get API key shell: bash run: | - API_KEY=(curl -s -X POST http://localhost:1511/api/token -H "Content-Type: application/x-www-form-urlencoded" -d "user_id=instructor&password=instructor" | grep -oP '"token"\s*:\s*"\K[^"]+') + echo 'RESPONSE=(curl -s -X POST http://localhost:1511/api/token -H "Content-Type: application/x-www-form-urlencoded" -d "user_id=instructor&password=instructor")' >> $GITHUB_ENV' - name: Create Homework shell: bash run: - ansible-playbook --private-key /home/runner/.ssh/id_rsa -e 'ansible_user=runner' -i inventory/submitty playbooks/submitty_homework_creation.yml -e "localhost/api/${SEMESTER}/course/upload" -e "${API_KEY}"" + ansible-playbook --private-key /home/runner/.ssh/id_rsa -e 'ansible_user=runner' -i inventory/submitty playbooks/submitty_homework_creation.yml -e "localhost/api/${SEMESTER}/course/upload" -e "${{ fromJson(env.RESPONSE).token }}" - name: Set perms shell: bash From be2f7cece7735bbbecbf08742ea2f899ab01b9d3 Mon Sep 17 00:00:00 2001 From: IDzyre Date: Mon, 16 Jun 2025 10:42:04 -0800 Subject: [PATCH 13/73] Fix ' --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 175bf2522e0..7956e495c14 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -937,7 +937,7 @@ jobs: - name: Get API key shell: bash run: | - echo 'RESPONSE=(curl -s -X POST http://localhost:1511/api/token -H "Content-Type: application/x-www-form-urlencoded" -d "user_id=instructor&password=instructor")' >> $GITHUB_ENV' + echo 'RESPONSE=(curl -s -X POST http://localhost:1511/api/token -H "Content-Type: application/x-www-form-urlencoded" -d "user_id=instructor&password=instructor")' >> $GITHUB_ENV - name: Create Homework shell: bash From 74b4b5eed91bc50d46288432bb1f8ca8694f965f Mon Sep 17 00:00:00 2001 From: Cameron Peterson <46759635+IDzyre@users.noreply.github.com> Date: Mon, 16 Jun 2025 10:59:04 -0800 Subject: [PATCH 14/73] Update ci.yml --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 7956e495c14..e2ee6c8d7fd 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -942,7 +942,7 @@ jobs: - name: Create Homework shell: bash run: - ansible-playbook --private-key /home/runner/.ssh/id_rsa -e 'ansible_user=runner' -i inventory/submitty playbooks/submitty_homework_creation.yml -e "localhost/api/${SEMESTER}/course/upload" -e "${{ fromJson(env.RESPONSE).token }}" + ansible-playbook --private-key /home/runner/.ssh/id_rsa -e 'ansible_user=runner' -i inventory/submitty playbooks/submitty_homework_creation.yml -e 'localhost/api/${SEMESTER}/course/upload' -e '${{ fromJson(env.RESPONSE).token }}' - name: Set perms shell: bash From 76e516a6853ca6c1f460dbd9c8479934e40afad2 Mon Sep 17 00:00:00 2001 From: Cameron Peterson <46759635+IDzyre@users.noreply.github.com> Date: Mon, 16 Jun 2025 11:16:00 -0800 Subject: [PATCH 15/73] Update ci.yml --- .github/workflows/ci.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index e2ee6c8d7fd..24279328b22 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -941,8 +941,7 @@ jobs: - name: Create Homework shell: bash - run: - ansible-playbook --private-key /home/runner/.ssh/id_rsa -e 'ansible_user=runner' -i inventory/submitty playbooks/submitty_homework_creation.yml -e 'localhost/api/${SEMESTER}/course/upload' -e '${{ fromJson(env.RESPONSE).token }}' + run: ansible-playbook --private-key /home/runner/.ssh/id_rsa -e "ansible_user=runner api_url=localhost/api/${SEMESTER}/course/upload token=${{ fromJson(env.RESPONSE).token }}" -i inventory/submitty playbooks/submitty_homework_creation.yml - name: Set perms shell: bash From 4c3cf801c38121222da32b4c0ff96ad64a0197ee Mon Sep 17 00:00:00 2001 From: Cameron Peterson <46759635+IDzyre@users.noreply.github.com> Date: Mon, 16 Jun 2025 11:29:53 -0800 Subject: [PATCH 16/73] Update ci.yml --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 24279328b22..fc7ca88b567 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -941,7 +941,7 @@ jobs: - name: Create Homework shell: bash - run: ansible-playbook --private-key /home/runner/.ssh/id_rsa -e "ansible_user=runner api_url=localhost/api/${SEMESTER}/course/upload token=${{ fromJson(env.RESPONSE).token }}" -i inventory/submitty playbooks/submitty_homework_creation.yml + run: ansible-playbook --private-key /home/runner/.ssh/id_rsa -e "ansible_user=runner api_url=localhost/api/${{SEMESTER}}/course/upload token=${{ fromJson(env.RESPONSE).token }}" -i inventory/submitty playbooks/submitty_homework_creation.yml - name: Set perms shell: bash From 0b992f31c9a2aed380d0119c208a27cd4fca2ded Mon Sep 17 00:00:00 2001 From: Cameron Peterson <46759635+IDzyre@users.noreply.github.com> Date: Mon, 16 Jun 2025 11:32:03 -0800 Subject: [PATCH 17/73] Update ci.yml --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index fc7ca88b567..f365b6a0ec8 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -929,7 +929,7 @@ jobs: - name: Run ansible scripts shell: bash run: | - SEMESTER=$(python3 -c 'from datetime import datetime; today = datetime.today(); semester = ("s" if today.month < 7 else "f") + str(today.year)[-2:]; print(semester)') + echo `SEMESTER=$(python3 -c 'from datetime import datetime; today = datetime.today(); semester = ("s" if today.month < 7 else "f") + str(today.year)[-2:]; print(semester)')` cd .setup/ansible ansible-playbook --private-key /home/runner/.ssh/id_rsa -e 'ansible_user=runner submitty_install_submitty_version=${{ github.sha }} submitty_install_github_url=https://github.com/${{ github.repository }}.git' -i inventory/submitty playbooks/submitty_install.yml ansible-playbook --private-key /home/runner/.ssh/id_rsa -e 'ansible_user=runner' -i inventory/submitty playbooks/submitty_course_creation.yml From be6159bc4a7977bd65e4b5e0b293236b15782d98 Mon Sep 17 00:00:00 2001 From: Cameron Peterson <46759635+IDzyre@users.noreply.github.com> Date: Mon, 16 Jun 2025 11:34:23 -0800 Subject: [PATCH 18/73] Update ci.yml --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index f365b6a0ec8..c06701c6063 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -941,7 +941,7 @@ jobs: - name: Create Homework shell: bash - run: ansible-playbook --private-key /home/runner/.ssh/id_rsa -e "ansible_user=runner api_url=localhost/api/${{SEMESTER}}/course/upload token=${{ fromJson(env.RESPONSE).token }}" -i inventory/submitty playbooks/submitty_homework_creation.yml + run: ansible-playbook --private-key /home/runner/.ssh/id_rsa -e "ansible_user=runner api_url=localhost/api/${{env.SEMESTER}}/course/upload token=${{ fromJson(env.RESPONSE).token }}" -i inventory/submitty playbooks/submitty_homework_creation.yml - name: Set perms shell: bash From 9c44dbd435ffc4f7d6564f4efd8c0410c8f1cf8d Mon Sep 17 00:00:00 2001 From: IDzyre Date: Tue, 17 Jun 2025 10:37:14 -0800 Subject: [PATCH 19/73] try fix xD --- .github/workflows/ci.yml | 28 ++++++++++++++++------------ 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index c06701c6063..8dc7c901813 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -926,22 +926,26 @@ jobs: ssh -T localhost sudo systemctl start postgresql - - name: Run ansible scripts - shell: bash + - name: Set SEMESTER environment variable + run: echo "SEMESTER=$(python3 -c 'from datetime import datetime; today = datetime.today(); semester = ("s" if today.month < 7 else "f") + str(today.year)[-2:]; print(semester)')" >> $GITHUB_ENV + + - name: Run Ansible scripts run: | - echo `SEMESTER=$(python3 -c 'from datetime import datetime; today = datetime.today(); semester = ("s" if today.month < 7 else "f") + str(today.year)[-2:]; print(semester)')` cd .setup/ansible - ansible-playbook --private-key /home/runner/.ssh/id_rsa -e 'ansible_user=runner submitty_install_submitty_version=${{ github.sha }} submitty_install_github_url=https://github.com/${{ github.repository }}.git' -i inventory/submitty playbooks/submitty_install.yml - ansible-playbook --private-key /home/runner/.ssh/id_rsa -e 'ansible_user=runner' -i inventory/submitty playbooks/submitty_course_creation.yml - - - name: Get API key - shell: bash + ansible-playbook --private-key /home/runner/.ssh/id_rsa -e "ansible_user=runner submitty_install_submitty_version=${{ github.sha }} submitty_install_github_url=https://github.com/${{ github.repository }}.git" -i inventory/submitty playbooks/submitty_install.yml + ansible-playbook --private-key /home/runner/.ssh/id_rsa -e "ansible_user=runner" -i inventory/submitty playbooks/submitty_course_creation.yml + + - name: Get API token + id: get_token run: | - echo 'RESPONSE=(curl -s -X POST http://localhost:1511/api/token -H "Content-Type: application/x-www-form-urlencoded" -d "user_id=instructor&password=instructor")' >> $GITHUB_ENV - + RESPONSE=$(curl -s -X POST http://localhost:1511/api/token -H "Content-Type: application/x-www-form-urlencoded" -d "user_id=instructor&password=instructor") + TOKEN=$(echo "$RESPONSE" | jq -r '.token') + echo "API_TOKEN=$TOKEN" >> $GITHUB_ENV + - name: Create Homework - shell: bash - run: ansible-playbook --private-key /home/runner/.ssh/id_rsa -e "ansible_user=runner api_url=localhost/api/${{env.SEMESTER}}/course/upload token=${{ fromJson(env.RESPONSE).token }}" -i inventory/submitty playbooks/submitty_homework_creation.yml + run: | + cd .setup/ansible + ansible-playbook --private-key /home/runner/.ssh/id_rsa -e "ansible_user=runner api_url=localhost/api/${{ env.SEMESTER }}/course/upload token=${{ env.API_TOKEN }}" -i inventory/submitty playbooks/submitty_homework_creation.yml - name: Set perms shell: bash From 887d6d8cce5e9f5f783cf2b2e79dd78c0da1befd Mon Sep 17 00:00:00 2001 From: IDzyre Date: Tue, 17 Jun 2025 11:04:38 -0800 Subject: [PATCH 20/73] try fix xD1 --- .github/workflows/ci.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 8dc7c901813..6d71371effe 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -934,6 +934,10 @@ jobs: cd .setup/ansible ansible-playbook --private-key /home/runner/.ssh/id_rsa -e "ansible_user=runner submitty_install_submitty_version=${{ github.sha }} submitty_install_github_url=https://github.com/${{ github.repository }}.git" -i inventory/submitty playbooks/submitty_install.yml ansible-playbook --private-key /home/runner/.ssh/id_rsa -e "ansible_user=runner" -i inventory/submitty playbooks/submitty_course_creation.yml + + - name: Validate image + run: | + curl --show-error --fail --include http://localhost/authentication/login - name: Get API token id: get_token @@ -969,10 +973,6 @@ jobs: run: | npm ci - - name: Validate image - run: | - curl --show-error --fail --include http://localhost/authentication/login - - name: Run Ansible cypress test uses: cypress-io/github-action@v6 with: From 419d830dc79f47c9a23bda4726a25be80420196b Mon Sep 17 00:00:00 2001 From: Cameron Peterson <46759635+IDzyre@users.noreply.github.com> Date: Wed, 18 Jun 2025 15:33:59 -0300 Subject: [PATCH 21/73] Update ci.yml --- .github/workflows/ci.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 6d71371effe..9f7d62491c6 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -942,14 +942,14 @@ jobs: - name: Get API token id: get_token run: | - RESPONSE=$(curl -s -X POST http://localhost:1511/api/token -H "Content-Type: application/x-www-form-urlencoded" -d "user_id=instructor&password=instructor") + RESPONSE=$(curl -s -X POST http://localhost/api/token -H "Content-Type: application/x-www-form-urlencoded" -d "user_id=instructor&password=instructor") TOKEN=$(echo "$RESPONSE" | jq -r '.token') echo "API_TOKEN=$TOKEN" >> $GITHUB_ENV - name: Create Homework run: | cd .setup/ansible - ansible-playbook --private-key /home/runner/.ssh/id_rsa -e "ansible_user=runner api_url=localhost/api/${{ env.SEMESTER }}/course/upload token=${{ env.API_TOKEN }}" -i inventory/submitty playbooks/submitty_homework_creation.yml + ansible-playbook --private-key /home/runner/.ssh/id_rsa -e "ansible_user=runner api_url=http://localhost/api/${{ env.SEMESTER }}/course/upload token=${{ env.API_TOKEN }}" -i inventory/submitty playbooks/submitty_homework_creation.yml - name: Set perms shell: bash From 2ca333739a91651c682f46e4a7109e87a3ed0f07 Mon Sep 17 00:00:00 2001 From: Cameron Peterson <46759635+IDzyre@users.noreply.github.com> Date: Wed, 18 Jun 2025 15:35:20 -0300 Subject: [PATCH 22/73] remove extra space --- site/cypress/support/utils.js | 1 - 1 file changed, 1 deletion(-) diff --git a/site/cypress/support/utils.js b/site/cypress/support/utils.js index a82aa2a315a..1e1298cee9c 100644 --- a/site/cypress/support/utils.js +++ b/site/cypress/support/utils.js @@ -43,7 +43,6 @@ export function getApiKey(user_id, password) { }).then((response) => { return response.body.data.token; }); - } /** From 202f81d352f3e0e19528f220a442472880ebde67 Mon Sep 17 00:00:00 2001 From: IDzyre Date: Wed, 18 Jun 2025 11:06:40 -0800 Subject: [PATCH 23/73] Fix lookup --- .../roles/submitty_homework_creation/tasks/create_gradeable.yml | 2 +- .setup/ansible/roles/submitty_homework_creation/tasks/main.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.setup/ansible/roles/submitty_homework_creation/tasks/create_gradeable.yml b/.setup/ansible/roles/submitty_homework_creation/tasks/create_gradeable.yml index 4375810b7a1..a79cd54ce63 100644 --- a/.setup/ansible/roles/submitty_homework_creation/tasks/create_gradeable.yml +++ b/.setup/ansible/roles/submitty_homework_creation/tasks/create_gradeable.yml @@ -3,7 +3,7 @@ url: "{{ submitty_homework_creation_api_url }}" method: POST body_format: json - body: "{{ lookup('file', var_json_file) }}" + body: "{{ lookup('file', 'config_files/' + var_json_file) }}" return_content: yes headers: Authorization: "{{ submitty_homework_creation_api_key }}" diff --git a/.setup/ansible/roles/submitty_homework_creation/tasks/main.yml b/.setup/ansible/roles/submitty_homework_creation/tasks/main.yml index 3c1ce9adfa7..4cfdfaa02bd 100644 --- a/.setup/ansible/roles/submitty_homework_creation/tasks/main.yml +++ b/.setup/ansible/roles/submitty_homework_creation/tasks/main.yml @@ -1,6 +1,6 @@ - name: Read JSON content from a file ansible.builtin.set_fact: - var_json_list: "config_files/{{ lookup('file', 'json_list.txt') | split('\n') }}" + var_json_list: "{{ lookup('file', 'json_list.txt') | split('\n') }}" - name: Use task list to loop through gradeables ansible.builtin.include_tasks: From 8c6386ad5a9a68515ad0eef3ee282df9c8921990 Mon Sep 17 00:00:00 2001 From: IDzyre Date: Wed, 18 Jun 2025 15:39:55 -0800 Subject: [PATCH 24/73] fix variable names --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 9f7d62491c6..7f95ccb11e5 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -949,7 +949,7 @@ jobs: - name: Create Homework run: | cd .setup/ansible - ansible-playbook --private-key /home/runner/.ssh/id_rsa -e "ansible_user=runner api_url=http://localhost/api/${{ env.SEMESTER }}/course/upload token=${{ env.API_TOKEN }}" -i inventory/submitty playbooks/submitty_homework_creation.yml + ansible-playbook --private-key /home/runner/.ssh/id_rsa -e "ansible_user=runner submitty_homework_creation_api_url=http://localhost/api/${{ env.SEMESTER }}/course/upload submitty_homework_creation_passed_api_key=${{ env.API_TOKEN }}" -i inventory/submitty playbooks/submitty_homework_creation.yml - name: Set perms shell: bash From e4764e76323a7839306f8fbfd980994e9daf6aea Mon Sep 17 00:00:00 2001 From: Cameron Peterson <46759635+IDzyre@users.noreply.github.com> Date: Mon, 23 Jun 2025 15:55:15 -0300 Subject: [PATCH 25/73] Fix api key --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 7f95ccb11e5..739a2646650 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -949,7 +949,7 @@ jobs: - name: Create Homework run: | cd .setup/ansible - ansible-playbook --private-key /home/runner/.ssh/id_rsa -e "ansible_user=runner submitty_homework_creation_api_url=http://localhost/api/${{ env.SEMESTER }}/course/upload submitty_homework_creation_passed_api_key=${{ env.API_TOKEN }}" -i inventory/submitty playbooks/submitty_homework_creation.yml + ansible-playbook --private-key /home/runner/.ssh/id_rsa -e "ansible_user=runner submitty_homework_creation_api_url=http://localhost/api/${{ env.SEMESTER }}/course/upload submitty_homework_creation_api_key=${{ env.API_TOKEN }}" -i inventory/submitty playbooks/submitty_homework_creation.yml - name: Set perms shell: bash From de53f5641c626e9e71f4f71c8517b88b569ede35 Mon Sep 17 00:00:00 2001 From: IDzyre Date: Mon, 23 Jun 2025 13:31:27 -0800 Subject: [PATCH 26/73] Try specifying course name --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 739a2646650..5cf1adf3c92 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -933,7 +933,7 @@ jobs: run: | cd .setup/ansible ansible-playbook --private-key /home/runner/.ssh/id_rsa -e "ansible_user=runner submitty_install_submitty_version=${{ github.sha }} submitty_install_github_url=https://github.com/${{ github.repository }}.git" -i inventory/submitty playbooks/submitty_install.yml - ansible-playbook --private-key /home/runner/.ssh/id_rsa -e "ansible_user=runner" -i inventory/submitty playbooks/submitty_course_creation.yml + ansible-playbook --private-key /home/runner/.ssh/id_rsa -e "ansible_user=runner submitty_course_creation_course=course" -i inventory/submitty playbooks/submitty_course_creation.yml - name: Validate image run: | From 3e5ded79fbcd4345b3410f9054cab5e1b35561dd Mon Sep 17 00:00:00 2001 From: IDzyre Date: Mon, 23 Jun 2025 14:30:41 -0800 Subject: [PATCH 27/73] fix url --- .github/workflows/ci.yml | 7 ++----- site/cypress/e2e/Cypress-Ansible/ansible-course.spec.js | 2 +- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 5cf1adf3c92..800268964d9 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -926,14 +926,11 @@ jobs: ssh -T localhost sudo systemctl start postgresql - - name: Set SEMESTER environment variable - run: echo "SEMESTER=$(python3 -c 'from datetime import datetime; today = datetime.today(); semester = ("s" if today.month < 7 else "f") + str(today.year)[-2:]; print(semester)')" >> $GITHUB_ENV - - name: Run Ansible scripts run: | cd .setup/ansible ansible-playbook --private-key /home/runner/.ssh/id_rsa -e "ansible_user=runner submitty_install_submitty_version=${{ github.sha }} submitty_install_github_url=https://github.com/${{ github.repository }}.git" -i inventory/submitty playbooks/submitty_install.yml - ansible-playbook --private-key /home/runner/.ssh/id_rsa -e "ansible_user=runner submitty_course_creation_course=course" -i inventory/submitty playbooks/submitty_course_creation.yml + ansible-playbook --private-key /home/runner/.ssh/id_rsa -e "ansible_user=runner" -i inventory/submitty playbooks/submitty_course_creation.yml - name: Validate image run: | @@ -949,7 +946,7 @@ jobs: - name: Create Homework run: | cd .setup/ansible - ansible-playbook --private-key /home/runner/.ssh/id_rsa -e "ansible_user=runner submitty_homework_creation_api_url=http://localhost/api/${{ env.SEMESTER }}/course/upload submitty_homework_creation_api_key=${{ env.API_TOKEN }}" -i inventory/submitty playbooks/submitty_homework_creation.yml + ansible-playbook --private-key /home/runner/.ssh/id_rsa -e "ansible_user=runner submitty_homework_creation_api_url=http://localhost/api/term/course/upload submitty_homework_creation_api_key=${{ env.API_TOKEN }}" -i inventory/submitty playbooks/submitty_homework_creation.yml - name: Set perms shell: bash diff --git a/site/cypress/e2e/Cypress-Ansible/ansible-course.spec.js b/site/cypress/e2e/Cypress-Ansible/ansible-course.spec.js index 93403fcfc02..55eac19d4dd 100644 --- a/site/cypress/e2e/Cypress-Ansible/ansible-course.spec.js +++ b/site/cypress/e2e/Cypress-Ansible/ansible-course.spec.js @@ -1,6 +1,6 @@ describe('Testing website when created by ansible scripts', () => { it('Should be able to login and see the course', () => { cy.login('instructor'); - cy.visit('term/course'); + cy.visit(['course']); }); }); From 0846236c88de0a196f326b0f768f903819f930fd Mon Sep 17 00:00:00 2001 From: IDzyre Date: Mon, 23 Jun 2025 14:32:04 -0800 Subject: [PATCH 28/73] fix url --- site/cypress/e2e/Cypress-Ansible/ansible-course.spec.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/site/cypress/e2e/Cypress-Ansible/ansible-course.spec.js b/site/cypress/e2e/Cypress-Ansible/ansible-course.spec.js index 55eac19d4dd..93403fcfc02 100644 --- a/site/cypress/e2e/Cypress-Ansible/ansible-course.spec.js +++ b/site/cypress/e2e/Cypress-Ansible/ansible-course.spec.js @@ -1,6 +1,6 @@ describe('Testing website when created by ansible scripts', () => { it('Should be able to login and see the course', () => { cy.login('instructor'); - cy.visit(['course']); + cy.visit('term/course'); }); }); From d32a2383bd7cc8efb1a10db4c71e44a9ecc0cfee Mon Sep 17 00:00:00 2001 From: IDzyre Date: Tue, 24 Jun 2025 10:15:53 -0800 Subject: [PATCH 29/73] echo token --- .github/workflows/ci.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 800268964d9..fc9f34af29e 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -965,6 +965,11 @@ jobs: restore-keys: | ${{ runner.os }}-cache-node-modules- + - name: Debug env + if: failure() + run: | + echo ${{ env.API_TOKEN }} + - name: Install node dependencies working-directory: ${{env.SUBMITTY_REPOSITORY}}/site run: | From 258f9f3b781467c8303f0e52af5bacd5f4bc65c1 Mon Sep 17 00:00:00 2001 From: IDzyre Date: Tue, 24 Jun 2025 10:37:28 -0800 Subject: [PATCH 30/73] test --- .github/workflows/ci.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index fc9f34af29e..0f16671a04a 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -940,7 +940,8 @@ jobs: id: get_token run: | RESPONSE=$(curl -s -X POST http://localhost/api/token -H "Content-Type: application/x-www-form-urlencoded" -d "user_id=instructor&password=instructor") - TOKEN=$(echo "$RESPONSE" | jq -r '.token') + echo "$RESPONSE" + TOKEN=$(echo "$RESPONSE" | jq -r '.data.token') echo "API_TOKEN=$TOKEN" >> $GITHUB_ENV - name: Create Homework From 0c7a5c6bb5cc880a985752389e2f55694bf8ef25 Mon Sep 17 00:00:00 2001 From: Cameron Peterson <46759635+IDzyre@users.noreply.github.com> Date: Thu, 3 Jul 2025 11:19:08 -0800 Subject: [PATCH 31/73] Update ci.ymlqwewqe --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 0f16671a04a..9330e7d38b8 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -939,7 +939,7 @@ jobs: - name: Get API token id: get_token run: | - RESPONSE=$(curl -s -X POST http://localhost/api/token -H "Content-Type: application/x-www-form-urlencoded" -d "user_id=instructor&password=instructor") + RESPONSE=$(curl -s -X POST http://localhost/api/token -F user_id=instructor -F password=instructor) echo "$RESPONSE" TOKEN=$(echo "$RESPONSE" | jq -r '.data.token') echo "API_TOKEN=$TOKEN" >> $GITHUB_ENV From 172e87943a90ea5494cc324fc7cc7bcf9c8a9da8 Mon Sep 17 00:00:00 2001 From: IDzyre Date: Thu, 3 Jul 2025 13:10:33 -0800 Subject: [PATCH 32/73] testing --- site/app/controllers/AuthenticationController.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/site/app/controllers/AuthenticationController.php b/site/app/controllers/AuthenticationController.php index e101f7112c6..e4c89d9fb05 100644 --- a/site/app/controllers/AuthenticationController.php +++ b/site/app/controllers/AuthenticationController.php @@ -170,7 +170,9 @@ public function getToken() { return MultiResponse::JsonOnlyResponse(JsonResponse::getSuccessResponse(['token' => $token])); } else { - $msg = "Could not login using that user id or password"; + $user_id = $_POST['user_id'] ?? 'not found'; + $password = $_POST['password'] ?? 'not found'; + $msg = "Could not login using that user id or password $user_id $password"; return MultiResponse::JsonOnlyResponse(JsonResponse::getFailResponse($msg)); } } From bc116c9a73f82ba4ffeeb2bef064e636131309ad Mon Sep 17 00:00:00 2001 From: IDzyre Date: Thu, 3 Jul 2025 13:30:12 -0800 Subject: [PATCH 33/73] testing --- .github/workflows/ci.yml | 6 ++++ .../playbooks/submitty_course_creation.yml | 30 ++++++++++++++++++- .../submitty_course_add_user/tasks/main.yml | 15 ---------- 3 files changed, 35 insertions(+), 16 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 9330e7d38b8..ab81dfd801d 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -941,7 +941,13 @@ jobs: run: | RESPONSE=$(curl -s -X POST http://localhost/api/token -F user_id=instructor -F password=instructor) echo "$RESPONSE" + status=$(echo "$RESPONSE" | jq -r '.status') + if [ "$status" = "fail" ]; then + echo "❌ API returned failure status" + exit 1 + fi TOKEN=$(echo "$RESPONSE" | jq -r '.data.token') + echo "API_TOKEN=$TOKEN" >> $GITHUB_ENV - name: Create Homework diff --git a/.setup/ansible/playbooks/submitty_course_creation.yml b/.setup/ansible/playbooks/submitty_course_creation.yml index 0fc68e5a496..071464bb4e0 100644 --- a/.setup/ansible/playbooks/submitty_course_creation.yml +++ b/.setup/ansible/playbooks/submitty_course_creation.yml @@ -60,8 +60,36 @@ submitty_course_add_instructor_lastname: lastname submitty_course_add_instructor_email: email submitty_course_add_instructor_password: instructor2 - + - name: Add Users + ansible.builtin.include_role: + name: submitty_add_user + vars: + submitty_add_user_username: "{{ user.username }}" + submitty_add_user_firstname: "{{ user.firstname }}" + submitty_add_user_lastname: "{{ user.lastname }}" + submitty_add_user_email: "{{ user.email }}" + submitty_add_user_password: "{{ user.password }}" + loop: + - username: aphacker + firstname: firstname + lastname: lastname + email: email + password: aphacker + - username: bitdiddle + firstname: firstname + lastname: lastname + email: email + password: bitdiddle + - username: adamsg + firstname: firstname + lastname: lastname + email: email + password: adamsg + loop_control: + loop_var: user + + - name: Add users to course ansible.builtin.include_role: name: submitty_course_add_user vars: diff --git a/.setup/ansible/roles/submitty_course_add_user/tasks/main.yml b/.setup/ansible/roles/submitty_course_add_user/tasks/main.yml index 02b292eae35..1f2c7ab7796 100644 --- a/.setup/ansible/roles/submitty_course_add_user/tasks/main.yml +++ b/.setup/ansible/roles/submitty_course_add_user/tasks/main.yml @@ -1,20 +1,5 @@ --- # Assumes that local user accounts already exist. - -- name: Add student to submitty users. - ansible.builtin.expect: - command: ./adduser.py "{{ submitty_course_add_user_username }}" - chdir: /usr/local/submitty/sbin/ - echo: true - responses: - (?m)^User givenname: "{{ submitty_course_add_user_username }}" - (?m)^User preferred name: "{{ submitty_course_add_user_firstname }}" - (?m)^User familyname: "{{ submitty_course_add_user_lastname }}" - (?m)^User email: "{{ submitty_course_add_user_email }}" - (?m)^User password: "{{ submitty_course_add_user_password }}" - become: true - become_user: root - - name: Add existing students to the course database. ansible.builtin.command: cmd: ./adduser_course.py "{{ submitty_course_add_user_username }}" From f24a7833522e51f6a02d39bcf52b5cf4f35193fa Mon Sep 17 00:00:00 2001 From: IDzyre Date: Mon, 14 Jul 2025 10:59:00 -0700 Subject: [PATCH 34/73] more --- .github/workflows/ci.yml | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index ab81dfd801d..8a28e1d6d5a 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -936,6 +936,15 @@ jobs: run: | curl --show-error --fail --include http://localhost/authentication/login + - name: Run Ansible cypress test + uses: cypress-io/github-action@v6 + with: + config: baseUrl=http://localhost + spec: cypress/e2e/Cypress-Ansible/ansible-course.spec.js + working-directory: ${{env.SUBMITTY_REPOSITORY}}/site + browser: chrome + + - name: Get API token id: get_token run: | @@ -954,6 +963,14 @@ jobs: run: | cd .setup/ansible ansible-playbook --private-key /home/runner/.ssh/id_rsa -e "ansible_user=runner submitty_homework_creation_api_url=http://localhost/api/term/course/upload submitty_homework_creation_api_key=${{ env.API_TOKEN }}" -i inventory/submitty playbooks/submitty_homework_creation.yml + + - name: Run Ansible cypress test + uses: cypress-io/github-action@v6 + with: + config: baseUrl=http://localhost + spec: cypress/e2e/Cypress-Ansible/ansible-course.spec.js + working-directory: ${{env.SUBMITTY_REPOSITORY}}/site + browser: chrome - name: Set perms shell: bash From a3afb32f0328f57e28610071fe5fe30d82a49415 Mon Sep 17 00:00:00 2001 From: IDzyre Date: Mon, 14 Jul 2025 11:12:09 -0700 Subject: [PATCH 35/73] more --- .github/workflows/ci.yml | 41 ++++++++++++++++++++-------------------- 1 file changed, 20 insertions(+), 21 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 8a28e1d6d5a..944f392c2d7 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -935,6 +935,26 @@ jobs: - name: Validate image run: | curl --show-error --fail --include http://localhost/authentication/login + - uses: actions/setup-node@v4 + with: + node-version: ${{ env.NODE_VERSION }} + - name: Cache Node Modules + uses: actions/cache@v4 + with: + path: ~/.npm + key: ${{ runner.os }}-cache-node-modules-${{ hashFiles('**/package-lock.json') }} + restore-keys: | + ${{ runner.os }}-cache-node-modules- + + - name: Debug env + if: failure() + run: | + echo ${{ env.API_TOKEN }} + + - name: Install node dependencies + working-directory: ${{env.SUBMITTY_REPOSITORY}}/site + run: | + npm ci - name: Run Ansible cypress test uses: cypress-io/github-action@v6 @@ -978,27 +998,6 @@ jobs: sudo chmod -R a+rwx ${SUBMITTY_INSTALL_DIR} sudo chmod -R a+rwx /tmp/ - - uses: actions/setup-node@v4 - with: - node-version: ${{ env.NODE_VERSION }} - - name: Cache Node Modules - uses: actions/cache@v4 - with: - path: ~/.npm - key: ${{ runner.os }}-cache-node-modules-${{ hashFiles('**/package-lock.json') }} - restore-keys: | - ${{ runner.os }}-cache-node-modules- - - - name: Debug env - if: failure() - run: | - echo ${{ env.API_TOKEN }} - - - name: Install node dependencies - working-directory: ${{env.SUBMITTY_REPOSITORY}}/site - run: | - npm ci - - name: Run Ansible cypress test uses: cypress-io/github-action@v6 with: From 3eb80bf93661737d8885f2d421a6d67d2c33ee22 Mon Sep 17 00:00:00 2001 From: IDzyre Date: Thu, 17 Jul 2025 20:56:52 -0800 Subject: [PATCH 36/73] test --- .github/workflows/ci.yml | 7 ++++++- .setup/ansible/playbooks/submitty_course_creation.yml | 1 + .setup/ansible/playbooks/submitty_homework_creation.yml | 1 + .setup/ansible/playbooks/submitty_install.yml | 2 +- 4 files changed, 9 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 7956e495c14..c3d71975018 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -983,7 +983,12 @@ jobs: with: name: install-log path: /usr/local/submitty/install.log - + + - uses: actions/upload-artifact@v4 + if: failure() + with: + name: npm-log + path: /home/runner/.npm/_logs - uses: actions/upload-artifact@v4 if: failure() with: diff --git a/.setup/ansible/playbooks/submitty_course_creation.yml b/.setup/ansible/playbooks/submitty_course_creation.yml index 0fc68e5a496..93da27977aa 100644 --- a/.setup/ansible/playbooks/submitty_course_creation.yml +++ b/.setup/ansible/playbooks/submitty_course_creation.yml @@ -1,6 +1,7 @@ --- - name: Submitty Course Creation hosts: submitty + remote_user: runner become: true vars: diff --git a/.setup/ansible/playbooks/submitty_homework_creation.yml b/.setup/ansible/playbooks/submitty_homework_creation.yml index 95738afd859..112455f7bae 100644 --- a/.setup/ansible/playbooks/submitty_homework_creation.yml +++ b/.setup/ansible/playbooks/submitty_homework_creation.yml @@ -1,6 +1,7 @@ --- - name: Submitty Homework Creation hosts: localhost + remote_user: instructor connection: local tasks: diff --git a/.setup/ansible/playbooks/submitty_install.yml b/.setup/ansible/playbooks/submitty_install.yml index e28931c1119..38c5af2c1f2 100644 --- a/.setup/ansible/playbooks/submitty_install.yml +++ b/.setup/ansible/playbooks/submitty_install.yml @@ -4,7 +4,7 @@ - name: Install Submitty hosts: submitty - remote_user: ubuntu + remote_user: runner become: true tasks: - name: Install Submitty From 7b9cc6a13e2f39a333919b370a0075b31d718fab Mon Sep 17 00:00:00 2001 From: IDzyre Date: Thu, 17 Jul 2025 21:49:14 -0800 Subject: [PATCH 37/73] test nother fix --- .github/workflows/ci.yml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index d5f7da4c2fe..b6968361700 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -927,11 +927,15 @@ jobs: sudo systemctl start postgresql - name: Run Ansible scripts + shell: bash run: | cd .setup/ansible ansible-playbook --private-key /home/runner/.ssh/id_rsa -e "ansible_user=runner submitty_install_submitty_version=${{ github.sha }} submitty_install_github_url=https://github.com/${{ github.repository }}.git" -i inventory/submitty playbooks/submitty_install.yml ansible-playbook --private-key /home/runner/.ssh/id_rsa -e "ansible_user=runner" -i inventory/submitty playbooks/submitty_course_creation.yml - + - name: Set perms + run: | + sudo chmod -R a+rwx ${SUBMITTY_INSTALL_DIR} + sudo chmod -R a+rwx /tmp/ - name: Validate image run: | curl --show-error --fail --include http://localhost/authentication/login From 03feaf29f52b11fd2ec105c92a6dfd5f0830dd6d Mon Sep 17 00:00:00 2001 From: IDzyre Date: Thu, 17 Jul 2025 21:51:30 -0800 Subject: [PATCH 38/73] test nother fix --- .github/workflows/ci.yml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index b6968361700..9f0383dad2b 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -930,9 +930,11 @@ jobs: shell: bash run: | cd .setup/ansible - ansible-playbook --private-key /home/runner/.ssh/id_rsa -e "ansible_user=runner submitty_install_submitty_version=${{ github.sha }} submitty_install_github_url=https://github.com/${{ github.repository }}.git" -i inventory/submitty playbooks/submitty_install.yml - ansible-playbook --private-key /home/runner/.ssh/id_rsa -e "ansible_user=runner" -i inventory/submitty playbooks/submitty_course_creation.yml + ansible-playbook --private-key /home/runner/.ssh/id_rsa -e 'ansible_user=runner submitty_install_submitty_version=${{ github.sha }} submitty_install_github_url=https://github.com/${{ github.repository }}.git' -i inventory/submitty playbooks/submitty_install.yml + ansible-playbook --private-key /home/runner/.ssh/id_rsa -e 'ansible_user=runner' -i inventory/submitty playbooks/submitty_course_creation.yml + - name: Set perms + shell: bash run: | sudo chmod -R a+rwx ${SUBMITTY_INSTALL_DIR} sudo chmod -R a+rwx /tmp/ From f46a977e647a336c1ff495d8e6c1ddad8d11dbae Mon Sep 17 00:00:00 2001 From: IDzyre Date: Thu, 17 Jul 2025 22:40:04 -0800 Subject: [PATCH 39/73] try display exception --- site/app/libraries/ExceptionHandler.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/site/app/libraries/ExceptionHandler.php b/site/app/libraries/ExceptionHandler.php index 88715bbc289..e019594b370 100644 --- a/site/app/libraries/ExceptionHandler.php +++ b/site/app/libraries/ExceptionHandler.php @@ -62,7 +62,7 @@ public static function setDisplayExceptions($boolean) { * exception message depending on the value of $display_exceptions */ public static function handleException($exception, $user_id) { - $display_message = false; + $display_message = true; $is_base_exception = false; $log_exception = static::$log_exceptions; if (is_a($exception, '\app\exceptions\BaseException')) { From a398ae22017f909b1224475d6a05526a33c8bff0 Mon Sep 17 00:00:00 2001 From: IDzyre Date: Thu, 17 Jul 2025 23:36:16 -0800 Subject: [PATCH 40/73] try display exception --- .github/workflows/ci.yml | 4 ++-- site/app/libraries/ExceptionHandler.php | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 9f0383dad2b..a8246017dd8 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -938,9 +938,11 @@ jobs: run: | sudo chmod -R a+rwx ${SUBMITTY_INSTALL_DIR} sudo chmod -R a+rwx /tmp/ + - name: Validate image run: | curl --show-error --fail --include http://localhost/authentication/login + - uses: actions/setup-node@v4 with: node-version: ${{ env.NODE_VERSION }} @@ -975,14 +977,12 @@ jobs: id: get_token run: | RESPONSE=$(curl -s -X POST http://localhost/api/token -F user_id=instructor -F password=instructor) - echo "$RESPONSE" status=$(echo "$RESPONSE" | jq -r '.status') if [ "$status" = "fail" ]; then echo "❌ API returned failure status" exit 1 fi TOKEN=$(echo "$RESPONSE" | jq -r '.data.token') - echo "API_TOKEN=$TOKEN" >> $GITHUB_ENV - name: Create Homework diff --git a/site/app/libraries/ExceptionHandler.php b/site/app/libraries/ExceptionHandler.php index e019594b370..d38b259e4bd 100644 --- a/site/app/libraries/ExceptionHandler.php +++ b/site/app/libraries/ExceptionHandler.php @@ -140,7 +140,7 @@ public static function handleException($exception, $user_id) { return <<getMessage(); } } From c6e4b4c59a40db6ca50d1f5c40c5b28f448c9ffb Mon Sep 17 00:00:00 2001 From: IDzyre Date: Fri, 18 Jul 2025 00:03:09 -0800 Subject: [PATCH 41/73] try other ting --- .github/workflows/ci.yml | 2 +- site/app/libraries/ExceptionHandler.php | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index a8246017dd8..d0657514b14 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -976,7 +976,7 @@ jobs: - name: Get API token id: get_token run: | - RESPONSE=$(curl -s -X POST http://localhost/api/token -F user_id=instructor -F password=instructor) + RESPONSE=$(curl -s -X POST http://localhost/api/token -H "Content-Type: application/x-www-form-urlencoded" -d "user_id=instructor&password=instructor") status=$(echo "$RESPONSE" | jq -r '.status') if [ "$status" = "fail" ]; then echo "❌ API returned failure status" diff --git a/site/app/libraries/ExceptionHandler.php b/site/app/libraries/ExceptionHandler.php index d38b259e4bd..88715bbc289 100644 --- a/site/app/libraries/ExceptionHandler.php +++ b/site/app/libraries/ExceptionHandler.php @@ -62,7 +62,7 @@ public static function setDisplayExceptions($boolean) { * exception message depending on the value of $display_exceptions */ public static function handleException($exception, $user_id) { - $display_message = true; + $display_message = false; $is_base_exception = false; $log_exception = static::$log_exceptions; if (is_a($exception, '\app\exceptions\BaseException')) { @@ -140,7 +140,7 @@ public static function handleException($exception, $user_id) { return <<getMessage(); +HTML; } } From 882b729252b19f36e15b808343d393714ea4e3b3 Mon Sep 17 00:00:00 2001 From: IDzyre Date: Sat, 19 Jul 2025 12:35:38 -0800 Subject: [PATCH 42/73] Echo response --- .github/workflows/ci.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index d0657514b14..4a3bfbc59f6 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -977,6 +977,7 @@ jobs: id: get_token run: | RESPONSE=$(curl -s -X POST http://localhost/api/token -H "Content-Type: application/x-www-form-urlencoded" -d "user_id=instructor&password=instructor") + echo "$RESPONSE" status=$(echo "$RESPONSE" | jq -r '.status') if [ "$status" = "fail" ]; then echo "❌ API returned failure status" From ce3be9aac2109e6d807f5134beee67dd8e817ff8 Mon Sep 17 00:00:00 2001 From: IDzyre Date: Sat, 19 Jul 2025 13:40:16 -0800 Subject: [PATCH 43/73] aa --- .github/workflows/ci.yml | 17 +++++------------ .../e2e/Cypress-Ansible/ansible-course.spec.js | 3 +++ 2 files changed, 8 insertions(+), 12 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 4a3bfbc59f6..15352ada82f 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -954,11 +954,6 @@ jobs: restore-keys: | ${{ runner.os }}-cache-node-modules- - - name: Debug env - if: failure() - run: | - echo ${{ env.API_TOKEN }} - - name: Install node dependencies working-directory: ${{env.SUBMITTY_REPOSITORY}}/site run: | @@ -972,7 +967,6 @@ jobs: working-directory: ${{env.SUBMITTY_REPOSITORY}}/site browser: chrome - - name: Get API token id: get_token run: | @@ -986,6 +980,11 @@ jobs: TOKEN=$(echo "$RESPONSE" | jq -r '.data.token') echo "API_TOKEN=$TOKEN" >> $GITHUB_ENV + - name: Debug env + if: failure() + run: | + echo ${{ env.API_TOKEN }} + - name: Create Homework run: | cd .setup/ansible @@ -999,12 +998,6 @@ jobs: working-directory: ${{env.SUBMITTY_REPOSITORY}}/site browser: chrome - - name: Set perms - shell: bash - run: | - sudo chmod -R a+rwx ${SUBMITTY_INSTALL_DIR} - sudo chmod -R a+rwx /tmp/ - - name: Run Ansible cypress test uses: cypress-io/github-action@v6 with: diff --git a/site/cypress/e2e/Cypress-Ansible/ansible-course.spec.js b/site/cypress/e2e/Cypress-Ansible/ansible-course.spec.js index 93403fcfc02..06de897d13a 100644 --- a/site/cypress/e2e/Cypress-Ansible/ansible-course.spec.js +++ b/site/cypress/e2e/Cypress-Ansible/ansible-course.spec.js @@ -2,5 +2,8 @@ describe('Testing website when created by ansible scripts', () => { it('Should be able to login and see the course', () => { cy.login('instructor'); cy.visit('term/course'); + getApiKey('instructor', 'password').then((apiKey) => { + console.log('API Key:', apiKey); }); }); +}); From 09bea61bd7d7b42683f01341973abf580a4d9d0f Mon Sep 17 00:00:00 2001 From: IDzyre Date: Mon, 28 Jul 2025 10:26:23 -0800 Subject: [PATCH 44/73] site errors --- .github/workflows/ci.yml | 22 +++++-------------- .../Cypress-Ansible/ansible-course.spec.js | 3 ++- 2 files changed, 8 insertions(+), 17 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 97deb6f63ff..9eeacaafaad 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -988,14 +988,6 @@ jobs: run: | npm ci - - name: Run Ansible cypress test - uses: cypress-io/github-action@v6 - with: - config: baseUrl=http://localhost - spec: cypress/e2e/Cypress-Ansible/ansible-course.spec.js - working-directory: ${{env.SUBMITTY_REPOSITORY}}/site - browser: chrome - - name: Get API token id: get_token run: | @@ -1027,20 +1019,18 @@ jobs: working-directory: ${{env.SUBMITTY_REPOSITORY}}/site browser: chrome - - name: Run Ansible cypress test - uses: cypress-io/github-action@v6 - with: - config: baseUrl=http://localhost - spec: cypress/e2e/Cypress-Ansible/ansible-course.spec.js - working-directory: ${{env.SUBMITTY_REPOSITORY}}/site - browser: chrome - - uses: actions/upload-artifact@v4 if: failure() with: name: install-log path: /usr/local/submitty/install.log + - uses: actions/upload-artifact@v4 + if: failure() + with: + name: site-errors + path: /var/local/submitty/logs/site_errors + - uses: actions/upload-artifact@v4 if: failure() with: diff --git a/site/cypress/e2e/Cypress-Ansible/ansible-course.spec.js b/site/cypress/e2e/Cypress-Ansible/ansible-course.spec.js index 06de897d13a..76bd5d8a62a 100644 --- a/site/cypress/e2e/Cypress-Ansible/ansible-course.spec.js +++ b/site/cypress/e2e/Cypress-Ansible/ansible-course.spec.js @@ -1,9 +1,10 @@ +import { getApiKey } from '../../support/utils'; describe('Testing website when created by ansible scripts', () => { it('Should be able to login and see the course', () => { cy.login('instructor'); cy.visit('term/course'); getApiKey('instructor', 'password').then((apiKey) => { console.log('API Key:', apiKey); + }); }); }); -}); From f0368ddc61f5af79247253f0c77416f6d7b56828 Mon Sep 17 00:00:00 2001 From: IDzyre Date: Mon, 28 Jul 2025 10:37:46 -0800 Subject: [PATCH 45/73] Linting --- .setup/ansible/playbooks/submitty_course_creation.yml | 4 ++-- .../submitty_homework_creation/tasks/create_gradeable.yml | 8 ++++---- .../roles/submitty_homework_creation/tasks/main.yml | 6 +++--- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/.setup/ansible/playbooks/submitty_course_creation.yml b/.setup/ansible/playbooks/submitty_course_creation.yml index 0ae97ec81f1..2c62f400ae0 100644 --- a/.setup/ansible/playbooks/submitty_course_creation.yml +++ b/.setup/ansible/playbooks/submitty_course_creation.yml @@ -61,7 +61,7 @@ submitty_course_add_instructor_lastname: lastname submitty_course_add_instructor_email: email submitty_course_add_instructor_password: instructor2 - + - name: Add Users ansible.builtin.include_role: name: submitty_add_user @@ -89,7 +89,7 @@ password: adamsg loop_control: loop_var: user - + - name: Add users to course ansible.builtin.include_role: name: submitty_course_add_user diff --git a/.setup/ansible/roles/submitty_homework_creation/tasks/create_gradeable.yml b/.setup/ansible/roles/submitty_homework_creation/tasks/create_gradeable.yml index a79cd54ce63..b6b73d46a16 100644 --- a/.setup/ansible/roles/submitty_homework_creation/tasks/create_gradeable.yml +++ b/.setup/ansible/roles/submitty_homework_creation/tasks/create_gradeable.yml @@ -3,14 +3,14 @@ url: "{{ submitty_homework_creation_api_url }}" method: POST body_format: json - body: "{{ lookup('file', 'config_files/' + var_json_file) }}" + body: "{{ lookup('file', 'config_files/' + submitty_homework_creation_json_file) }}" return_content: yes headers: Authorization: "{{ submitty_homework_creation_api_key }}" - register: api_response + register: submitty_homework_creation_api_response - name: Fail when status is error ansible.builtin.fail: - msg: "{{ (api_response.content | from_json).message }}" + msg: "{{ (submitty_homework_creation_api_response.content | from_json).message }}" when: - - (api_response.content | from_json).status != 'success' + - (submitty_homework_creation_api_response.content | from_json).status != 'success' diff --git a/.setup/ansible/roles/submitty_homework_creation/tasks/main.yml b/.setup/ansible/roles/submitty_homework_creation/tasks/main.yml index 4cfdfaa02bd..d5fd40694db 100644 --- a/.setup/ansible/roles/submitty_homework_creation/tasks/main.yml +++ b/.setup/ansible/roles/submitty_homework_creation/tasks/main.yml @@ -7,7 +7,7 @@ file: create_gradeable.yml loop: "{{ var_json_list }}" loop_control: - loop_var: submitty_homework_api_json_file + loop_var: submitty_homework_creation_json_file vars: - var_json_file: "{{ submitty_homework_api_json_file }}" - api_key: "{{ passed_api_key }}" + submitty_homework_creation_json_file: "{{ submitty_homework_creation_json_file }}" + submitty_homework_creation_api_key: "{{ submitty_homework_creation_passed_api_key }}" From 944a59ab7c16c956f141f897d2450aa4795d99cd Mon Sep 17 00:00:00 2001 From: IDzyre Date: Mon, 28 Jul 2025 10:39:01 -0800 Subject: [PATCH 46/73] more lint --- .../ansible/roles/submitty_homework_creation/tasks/main.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.setup/ansible/roles/submitty_homework_creation/tasks/main.yml b/.setup/ansible/roles/submitty_homework_creation/tasks/main.yml index d5fd40694db..41bc33eff19 100644 --- a/.setup/ansible/roles/submitty_homework_creation/tasks/main.yml +++ b/.setup/ansible/roles/submitty_homework_creation/tasks/main.yml @@ -1,11 +1,11 @@ - name: Read JSON content from a file ansible.builtin.set_fact: - var_json_list: "{{ lookup('file', 'json_list.txt') | split('\n') }}" + submitty_homework_creation_json_list: "{{ lookup('file', 'json_list.txt') | split('\n') }}" - name: Use task list to loop through gradeables ansible.builtin.include_tasks: file: create_gradeable.yml - loop: "{{ var_json_list }}" + loop: "{{ submitty_homework_creation_json_list }}" loop_control: loop_var: submitty_homework_creation_json_file vars: From 7fa6389479adc213f7e33fe8e060ab2b79cfc344 Mon Sep 17 00:00:00 2001 From: IDzyre Date: Mon, 28 Jul 2025 10:55:50 -0800 Subject: [PATCH 47/73] aee --- .github/workflows/ci.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 9eeacaafaad..a50cef9740f 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -967,6 +967,7 @@ jobs: run: | sudo chmod -R a+rwx ${SUBMITTY_INSTALL_DIR} sudo chmod -R a+rwx /tmp/ + sudo chmod -R a+rwx /var/local/submitty - name: Validate image run: | @@ -991,7 +992,7 @@ jobs: - name: Get API token id: get_token run: | - RESPONSE=$(curl -s -X POST http://localhost/api/token -H "Content-Type: application/x-www-form-urlencoded" -d "user_id=instructor&password=instructor") + RESPONSE=$(curl -s -X POST -H "Content-Type: application/x-www-form-urlencoded" --data "user_id=instructor&password=instructor" http://localhost/api/token) echo "$RESPONSE" status=$(echo "$RESPONSE" | jq -r '.status') if [ "$status" = "fail" ]; then From a2bbddbcce499993c0741792c1ace08a1d5c39c2 Mon Sep 17 00:00:00 2001 From: IDzyre Date: Mon, 28 Jul 2025 11:11:06 -0800 Subject: [PATCH 48/73] more perms --- .github/workflows/ci.yml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index a50cef9740f..842023f65f9 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1019,6 +1019,12 @@ jobs: spec: cypress/e2e/Cypress-Ansible/ansible-course.spec.js working-directory: ${{env.SUBMITTY_REPOSITORY}}/site browser: chrome + + - name: Set perms for error file + if: failure() + shell: bash + run: | + sudo chmod -R a+rwx /var/local/submitty/logs/site_errors - uses: actions/upload-artifact@v4 if: failure() From cea3f4247acc64d3c1c6b11a79715249853c7dfd Mon Sep 17 00:00:00 2001 From: IDzyre Date: Mon, 28 Jul 2025 18:32:05 -0800 Subject: [PATCH 49/73] add --- .setup/ansible/roles/submitty_install/defaults/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.setup/ansible/roles/submitty_install/defaults/main.yml b/.setup/ansible/roles/submitty_install/defaults/main.yml index 2ab1badb509..c1175c9deaf 100644 --- a/.setup/ansible/roles/submitty_install/defaults/main.yml +++ b/.setup/ansible/roles/submitty_install/defaults/main.yml @@ -15,7 +15,7 @@ submitty_install_institution_name: Example University submitty_install_sysadmin_email: sysadmin@localhost submitty_install_submitty_email: submitty@localhost submitty_install_institution_url: localhost -submitty_install_authentication_method: 1 +submitty_install_authentication_method: 2 submitty_install_email_enabled: y submitty_install_ssl_enabled: false submitty_install_admin_email: admin@localhost From 551afa23bbfd1d2a73162681d6147e1ed6b51f98 Mon Sep 17 00:00:00 2001 From: IDzyre Date: Mon, 28 Jul 2025 18:47:30 -0800 Subject: [PATCH 50/73] Switcha rrounsd --- .setup/ansible/roles/submitty_install/tasks/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.setup/ansible/roles/submitty_install/tasks/main.yml b/.setup/ansible/roles/submitty_install/tasks/main.yml index ebd3288cdfe..a2103890d64 100644 --- a/.setup/ansible/roles/submitty_install/tasks/main.yml +++ b/.setup/ansible/roles/submitty_install/tasks/main.yml @@ -47,11 +47,11 @@ {{ submitty_install_vcs_url }} {{ submitty_install_institution_name }} {{ submitty_install_institution_url }} - {{ submitty_install_self_account_creation }} {{ submitty_install_sysadmin_email }} {{ submitty_install_submitty_email }} {{ submitty_install_institution_url }} {{ submitty_install_authentication_method }} + {{ submitty_install_self_account_creation }} {{ submitty_install_admin_email }} {{ submitty_install_email_enabled }} {{ submitty_install_admin_email }} From cf36e8f705a68a25ab7b764c4a92b72fe5000891 Mon Sep 17 00:00:00 2001 From: IDzyre Date: Mon, 28 Jul 2025 19:50:46 -0800 Subject: [PATCH 51/73] tests --- .../submitty_course_creation/tasks/main.yml | 28 +++++++++---------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/.setup/ansible/roles/submitty_course_creation/tasks/main.yml b/.setup/ansible/roles/submitty_course_creation/tasks/main.yml index 2707dbf2c29..172ee0b05cd 100644 --- a/.setup/ansible/roles/submitty_course_creation/tasks/main.yml +++ b/.setup/ansible/roles/submitty_course_creation/tasks/main.yml @@ -15,6 +15,20 @@ vars: course_name: "{{ submitty_course_creation_course }}" +- name: Add instructors to submitty users. + ansible.builtin.expect: + command: ./adduser.py "{{ submitty_course_creation_username }}" + chdir: /usr/local/submitty/sbin/ + echo: true + responses: + (?m)^User givenname: "{{ submitty_course_creation_firstname }}" + (?m)^User preferred name: "{{ submitty_course_creation_firstname }}" + (?m)^User familyname: "{{ submitty_course_creation_lastname }}" + (?m)^User email: "{{ submitty_course_creation_email }}" + (?m)^User password: NotUsedWithLdap + become: true + become_user: root + - name: Add instructors to the course groups. ansible.builtin.user: name: "{{ submitty_course_creation_username }}" @@ -77,20 +91,6 @@ recurse: true mode: g+s -- name: Add instructors to submitty users. - ansible.builtin.expect: - command: ./adduser.py "{{ submitty_course_creation_username }}" - chdir: /usr/local/submitty/sbin/ - echo: true - responses: - (?m)^User givenname: "{{ submitty_course_creation_firstname }}" - (?m)^User preferred name: "{{ submitty_course_creation_firstname }}" - (?m)^User familyname: "{{ submitty_course_creation_lastname }}" - (?m)^User email: "{{ submitty_course_creation_email }}" - (?m)^User password: NotUsedWithLdap - become: true - become_user: root - # Prepare the course directory and course database. # Assumes top-level Submitty database exists. From ad32388e87a32d98e8afa95b87d177a54a6853e8 Mon Sep 17 00:00:00 2001 From: IDzyre Date: Mon, 28 Jul 2025 20:02:57 -0800 Subject: [PATCH 52/73] tests --- sbin/adduser.py | 1 + 1 file changed, 1 insertion(+) diff --git a/sbin/adduser.py b/sbin/adduser.py index 349c04465ef..bdf686db758 100644 --- a/sbin/adduser.py +++ b/sbin/adduser.py @@ -113,6 +113,7 @@ def main(): while AUTHENTICATION_METHOD == 'DatabaseAuthentication': password = input('User password{}: '.format(extra)) if password != '': + print(password) update['user_password'] = get_php_db_password(password) break elif user is not None and password == '': From 96c025789e84859f0df93574f8cc813f88adc005 Mon Sep 17 00:00:00 2001 From: IDzyre Date: Mon, 28 Jul 2025 20:03:40 -0800 Subject: [PATCH 53/73] tests --- sbin/adduser.py | 1 + 1 file changed, 1 insertion(+) diff --git a/sbin/adduser.py b/sbin/adduser.py index bdf686db758..e3e173c544a 100644 --- a/sbin/adduser.py +++ b/sbin/adduser.py @@ -114,6 +114,7 @@ def main(): password = input('User password{}: '.format(extra)) if password != '': print(password) + print(get_php_db_password(password)) update['user_password'] = get_php_db_password(password) break elif user is not None and password == '': From f68c62396d8e7a3c6570d315cc86904b838b103e Mon Sep 17 00:00:00 2001 From: IDzyre Date: Tue, 29 Jul 2025 09:49:31 -0800 Subject: [PATCH 54/73] try more --- .setup/ansible/roles/submitty_add_user/tasks/main.yml | 2 +- sbin/adduser.py | 4 +--- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/.setup/ansible/roles/submitty_add_user/tasks/main.yml b/.setup/ansible/roles/submitty_add_user/tasks/main.yml index 7a28eacc665..48f8402db9e 100644 --- a/.setup/ansible/roles/submitty_add_user/tasks/main.yml +++ b/.setup/ansible/roles/submitty_add_user/tasks/main.yml @@ -5,7 +5,7 @@ chdir: /usr/local/submitty/sbin/ echo: true responses: - (?m)^User givenname: "{{ submitty_add_user_username }}" + (?m)^User givenname: "{{ submitty_add_user_firstname }}" (?m)^User preferred name: "{{ submitty_add_user_firstname }}" (?m)^User familyname: "{{ submitty_add_user_lastname }}" (?m)^User email: "{{ submitty_add_user_email }}" diff --git a/sbin/adduser.py b/sbin/adduser.py index e3e173c544a..d88b490efe9 100644 --- a/sbin/adduser.py +++ b/sbin/adduser.py @@ -113,9 +113,7 @@ def main(): while AUTHENTICATION_METHOD == 'DatabaseAuthentication': password = input('User password{}: '.format(extra)) if password != '': - print(password) - print(get_php_db_password(password)) - update['user_password'] = get_php_db_password(password) + update_data['user_password'] = get_php_db_password(password) break elif user is not None and password == '': break From dcda059c1c267081080c08faa13ce6b6165ef22f Mon Sep 17 00:00:00 2001 From: IDzyre Date: Tue, 29 Jul 2025 10:24:37 -0800 Subject: [PATCH 55/73] test add instructor --- .../ansible/playbooks/submitty_course_creation.yml | 14 +++++++++++++- site/app/controllers/AuthenticationController.php | 6 +++--- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/.setup/ansible/playbooks/submitty_course_creation.yml b/.setup/ansible/playbooks/submitty_course_creation.yml index 2c62f400ae0..164c8b24b96 100644 --- a/.setup/ansible/playbooks/submitty_course_creation.yml +++ b/.setup/ansible/playbooks/submitty_course_creation.yml @@ -50,7 +50,19 @@ submitty_course_creation_lastname: lastname submitty_course_creation_email: email - - name: Add Instructors + - name: Add Instructor + ansible.builtin.include_role: + name: submitty_course_add_instructor + vars: + submitty_course_add_instructor_term: term + submitty_course_add_instructor_course: course + submitty_course_add_instructor_username: instructor + submitty_course_add_instructor_firstname: firstname + submitty_course_add_instructor_lastname: lastname + submitty_course_add_instructor_email: email + submitty_course_add_instructor_password: instructor + + - name: Add instructor2 ansible.builtin.include_role: name: submitty_course_add_instructor vars: diff --git a/site/app/controllers/AuthenticationController.php b/site/app/controllers/AuthenticationController.php index 26c89b09a17..c73b99b38f1 100644 --- a/site/app/controllers/AuthenticationController.php +++ b/site/app/controllers/AuthenticationController.php @@ -174,9 +174,9 @@ public function getToken() { return MultiResponse::JsonOnlyResponse(JsonResponse::getSuccessResponse(['token' => $token])); } else { - $user_id = $_POST['user_id'] ?? 'not found'; - $password = $_POST['password'] ?? 'not found'; - $msg = "Could not login using that user id or password $user_id $password"; + $user_id = $_POST['user_id']; + $password = $_POST['password']; + $msg = "Could not login using that user id or password"; return MultiResponse::JsonOnlyResponse(JsonResponse::getFailResponse($msg)); } } From 2bc5925d881f6b990149c7e5ff0d1d181b4c4d24 Mon Sep 17 00:00:00 2001 From: IDzyre Date: Tue, 29 Jul 2025 10:43:32 -0800 Subject: [PATCH 56/73] add --- site/app/authentication/DatabaseAuthentication.php | 4 ++-- site/app/controllers/AuthenticationController.php | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/site/app/authentication/DatabaseAuthentication.php b/site/app/authentication/DatabaseAuthentication.php index 587c2fb5ecf..a12a86e0fb3 100644 --- a/site/app/authentication/DatabaseAuthentication.php +++ b/site/app/authentication/DatabaseAuthentication.php @@ -21,8 +21,8 @@ public function authenticate() { } $user = $this->core->getQueries()->getSubmittyUser($this->user_id); if ($user === null) { - return false; + return 'no-user'; } - return password_verify($this->password, $user->getPassword()); + return 'no-password'; } } diff --git a/site/app/controllers/AuthenticationController.php b/site/app/controllers/AuthenticationController.php index c73b99b38f1..00e18e3c565 100644 --- a/site/app/controllers/AuthenticationController.php +++ b/site/app/controllers/AuthenticationController.php @@ -176,7 +176,7 @@ public function getToken() { else { $user_id = $_POST['user_id']; $password = $_POST['password']; - $msg = "Could not login using that user id or password"; + $msg = "Could not login using that user id or password $token"; return MultiResponse::JsonOnlyResponse(JsonResponse::getFailResponse($msg)); } } From 169cc1db811b582c8ffd2c740faf75de734c54d4 Mon Sep 17 00:00:00 2001 From: IDzyre Date: Tue, 29 Jul 2025 10:44:26 -0800 Subject: [PATCH 57/73] add --- site/app/controllers/AuthenticationController.php | 10 +++++----- site/app/libraries/Core.php | 1 + 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/site/app/controllers/AuthenticationController.php b/site/app/controllers/AuthenticationController.php index 00e18e3c565..001ae766df8 100644 --- a/site/app/controllers/AuthenticationController.php +++ b/site/app/controllers/AuthenticationController.php @@ -170,15 +170,15 @@ public function getToken() { $this->core->getAuthentication()->setUserId($_POST['user_id']); $this->core->getAuthentication()->setPassword($_POST['password']); $token = $this->core->authenticateJwt(); - if ($token) { - return MultiResponse::JsonOnlyResponse(JsonResponse::getSuccessResponse(['token' => $token])); - } - else { + // if ($token) { + // return MultiResponse::JsonOnlyResponse(JsonResponse::getSuccessResponse(['token' => $token])); + // } + // else { $user_id = $_POST['user_id']; $password = $_POST['password']; $msg = "Could not login using that user id or password $token"; return MultiResponse::JsonOnlyResponse(JsonResponse::getFailResponse($msg)); - } + // } } /** diff --git a/site/app/libraries/Core.php b/site/app/libraries/Core.php index c001ac1278a..efd88d45c30 100644 --- a/site/app/libraries/Core.php +++ b/site/app/libraries/Core.php @@ -577,6 +577,7 @@ public function authenticate(bool $persistent_cookie = true): bool { */ public function authenticateJwt() { $user_id = $this->authentication->getUserId(); + return $this->authentication->authenticate(); try { if ($this->authentication->authenticate()) { $this->database_queries->refreshUserApiKey($user_id); From 71728be15c6ab6d064a40b56c51bd852ee994f40 Mon Sep 17 00:00:00 2001 From: IDzyre Date: Tue, 29 Jul 2025 11:10:28 -0800 Subject: [PATCH 58/73] add --- site/app/authentication/DatabaseAuthentication.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/site/app/authentication/DatabaseAuthentication.php b/site/app/authentication/DatabaseAuthentication.php index a12a86e0fb3..03a113ee472 100644 --- a/site/app/authentication/DatabaseAuthentication.php +++ b/site/app/authentication/DatabaseAuthentication.php @@ -23,6 +23,7 @@ public function authenticate() { if ($user === null) { return 'no-user'; } - return 'no-password'; + return ($this->password . ' -- ' . $user->getPassword()); + return password_verify($this->password, $user->getPassword()); } } From ea0a2cf6dd29c2bdaa9eef1881cc66076b6bceb3 Mon Sep 17 00:00:00 2001 From: IDzyre Date: Tue, 29 Jul 2025 11:38:51 -0800 Subject: [PATCH 59/73] try instructor 2 --- .github/workflows/ci.yml | 2 +- site/app/authentication/DatabaseAuthentication.php | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 842023f65f9..42604a42096 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -992,7 +992,7 @@ jobs: - name: Get API token id: get_token run: | - RESPONSE=$(curl -s -X POST -H "Content-Type: application/x-www-form-urlencoded" --data "user_id=instructor&password=instructor" http://localhost/api/token) + RESPONSE=$(curl -s -X POST -H "Content-Type: application/x-www-form-urlencoded" --data "user_id=instructor2&password=instructor2" http://localhost/api/token) echo "$RESPONSE" status=$(echo "$RESPONSE" | jq -r '.status') if [ "$status" = "fail" ]; then diff --git a/site/app/authentication/DatabaseAuthentication.php b/site/app/authentication/DatabaseAuthentication.php index 03a113ee472..587c2fb5ecf 100644 --- a/site/app/authentication/DatabaseAuthentication.php +++ b/site/app/authentication/DatabaseAuthentication.php @@ -21,9 +21,8 @@ public function authenticate() { } $user = $this->core->getQueries()->getSubmittyUser($this->user_id); if ($user === null) { - return 'no-user'; + return false; } - return ($this->password . ' -- ' . $user->getPassword()); return password_verify($this->password, $user->getPassword()); } } From a9e4f5b31754110b645d08f8a8a4939dfb2880c0 Mon Sep 17 00:00:00 2001 From: IDzyre Date: Tue, 29 Jul 2025 12:45:47 -0800 Subject: [PATCH 60/73] test --- .setup/ansible/playbooks/submitty_course_creation.yml | 6 +++--- .setup/ansible/roles/submitty_install/defaults/main.yml | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.setup/ansible/playbooks/submitty_course_creation.yml b/.setup/ansible/playbooks/submitty_course_creation.yml index 164c8b24b96..fa962ea964a 100644 --- a/.setup/ansible/playbooks/submitty_course_creation.yml +++ b/.setup/ansible/playbooks/submitty_course_creation.yml @@ -62,17 +62,17 @@ submitty_course_add_instructor_email: email submitty_course_add_instructor_password: instructor - - name: Add instructor2 + - name: Add runner ansible.builtin.include_role: name: submitty_course_add_instructor vars: submitty_course_add_instructor_term: term submitty_course_add_instructor_course: course - submitty_course_add_instructor_username: instructor2 + submitty_course_add_instructor_username: runner submitty_course_add_instructor_firstname: firstname submitty_course_add_instructor_lastname: lastname submitty_course_add_instructor_email: email - submitty_course_add_instructor_password: instructor2 + submitty_course_add_instructor_password: runner - name: Add Users ansible.builtin.include_role: diff --git a/.setup/ansible/roles/submitty_install/defaults/main.yml b/.setup/ansible/roles/submitty_install/defaults/main.yml index 232f24d7c05..b70adff3b76 100644 --- a/.setup/ansible/roles/submitty_install/defaults/main.yml +++ b/.setup/ansible/roles/submitty_install/defaults/main.yml @@ -16,7 +16,7 @@ submitty_install_self_account_creation: n submitty_install_sysadmin_email: sysadmin@localhost submitty_install_submitty_email: submitty@localhost submitty_install_institution_url: localhost -submitty_install_authentication_method: 2 +submitty_install_authentication_method: 1 submitty_install_email_enabled: y submitty_install_ssl_enabled: false submitty_install_admin_email: admin@localhost From b84a75824c5eaf3b5e5056894603f05babe915af Mon Sep 17 00:00:00 2001 From: Cameron Peterson <46759635+IDzyre@users.noreply.github.com> Date: Tue, 29 Jul 2025 13:32:56 -0800 Subject: [PATCH 61/73] Try runner --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 42604a42096..03d9d176cd2 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -992,7 +992,7 @@ jobs: - name: Get API token id: get_token run: | - RESPONSE=$(curl -s -X POST -H "Content-Type: application/x-www-form-urlencoded" --data "user_id=instructor2&password=instructor2" http://localhost/api/token) + RESPONSE=$(curl -s -X POST -H "Content-Type: application/x-www-form-urlencoded" --data "user_id=runner&password=runner" http://localhost/api/token) echo "$RESPONSE" status=$(echo "$RESPONSE" | jq -r '.status') if [ "$status" = "fail" ]; then From 534fe843fc679337ac54d96091f2ae0dc518b22e Mon Sep 17 00:00:00 2001 From: IDzyre Date: Wed, 30 Jul 2025 09:59:24 -0800 Subject: [PATCH 62/73] test --- .github/workflows/ci.yml | 2 +- .setup/ansible/roles/submitty_add_user/tasks/main.yml | 2 +- .setup/ansible/roles/submitty_install/defaults/main.yml | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 03d9d176cd2..842023f65f9 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -992,7 +992,7 @@ jobs: - name: Get API token id: get_token run: | - RESPONSE=$(curl -s -X POST -H "Content-Type: application/x-www-form-urlencoded" --data "user_id=runner&password=runner" http://localhost/api/token) + RESPONSE=$(curl -s -X POST -H "Content-Type: application/x-www-form-urlencoded" --data "user_id=instructor&password=instructor" http://localhost/api/token) echo "$RESPONSE" status=$(echo "$RESPONSE" | jq -r '.status') if [ "$status" = "fail" ]; then diff --git a/.setup/ansible/roles/submitty_add_user/tasks/main.yml b/.setup/ansible/roles/submitty_add_user/tasks/main.yml index 48f8402db9e..7e111984c2f 100644 --- a/.setup/ansible/roles/submitty_add_user/tasks/main.yml +++ b/.setup/ansible/roles/submitty_add_user/tasks/main.yml @@ -1,7 +1,7 @@ --- - name: Add student to submitty users. ansible.builtin.expect: - command: ./adduser.py "{{ submitty_add_user_username }}" + command: ./adduser.py {{ submitty_add_user_username }} chdir: /usr/local/submitty/sbin/ echo: true responses: diff --git a/.setup/ansible/roles/submitty_install/defaults/main.yml b/.setup/ansible/roles/submitty_install/defaults/main.yml index b70adff3b76..232f24d7c05 100644 --- a/.setup/ansible/roles/submitty_install/defaults/main.yml +++ b/.setup/ansible/roles/submitty_install/defaults/main.yml @@ -16,7 +16,7 @@ submitty_install_self_account_creation: n submitty_install_sysadmin_email: sysadmin@localhost submitty_install_submitty_email: submitty@localhost submitty_install_institution_url: localhost -submitty_install_authentication_method: 1 +submitty_install_authentication_method: 2 submitty_install_email_enabled: y submitty_install_ssl_enabled: false submitty_install_admin_email: admin@localhost From d5aaaf1b2be3dfa2da82f29cdf643708d35749ea Mon Sep 17 00:00:00 2001 From: IDzyre Date: Wed, 30 Jul 2025 10:16:21 -0800 Subject: [PATCH 63/73] please --- .github/workflows/ci.yml | 13 +++---------- .../ansible/playbooks/submitty_course_creation.yml | 4 ++-- .../ansible/roles/submitty_add_user/tasks/main.yml | 2 +- 3 files changed, 6 insertions(+), 13 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 842023f65f9..fbfac2da592 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -961,13 +961,12 @@ jobs: cd .setup/ansible ansible-playbook --private-key /home/runner/.ssh/id_rsa -e 'ansible_user=runner submitty_install_submitty_version=${{ github.sha }} submitty_install_github_url=https://github.com/${{ github.repository }}.git' -i inventory/submitty playbooks/submitty_install.yml ansible-playbook --private-key /home/runner/.ssh/id_rsa -e 'ansible_user=runner' -i inventory/submitty playbooks/submitty_course_creation.yml - + - name: Set perms shell: bash run: | sudo chmod -R a+rwx ${SUBMITTY_INSTALL_DIR} sudo chmod -R a+rwx /tmp/ - sudo chmod -R a+rwx /var/local/submitty - name: Validate image run: | @@ -992,11 +991,10 @@ jobs: - name: Get API token id: get_token run: | - RESPONSE=$(curl -s -X POST -H "Content-Type: application/x-www-form-urlencoded" --data "user_id=instructor&password=instructor" http://localhost/api/token) + RESPONSE=$(curl -s -X POST -H "Content-Type: application/x-www-form-urlencoded" --data "user_id=instructor &password=instructor" http://localhost/api/token) echo "$RESPONSE" status=$(echo "$RESPONSE" | jq -r '.status') if [ "$status" = "fail" ]; then - echo "❌ API returned failure status" exit 1 fi TOKEN=$(echo "$RESPONSE" | jq -r '.data.token') @@ -1037,12 +1035,7 @@ jobs: with: name: site-errors path: /var/local/submitty/logs/site_errors - - - uses: actions/upload-artifact@v4 - if: failure() - with: - name: npm-log - path: /home/runner/.npm/_logs + - uses: actions/upload-artifact@v4 if: failure() with: diff --git a/.setup/ansible/playbooks/submitty_course_creation.yml b/.setup/ansible/playbooks/submitty_course_creation.yml index fa962ea964a..ba9a4031a34 100644 --- a/.setup/ansible/playbooks/submitty_course_creation.yml +++ b/.setup/ansible/playbooks/submitty_course_creation.yml @@ -56,11 +56,11 @@ vars: submitty_course_add_instructor_term: term submitty_course_add_instructor_course: course - submitty_course_add_instructor_username: instructor + submitty_course_add_instructor_username: instructor2 submitty_course_add_instructor_firstname: firstname submitty_course_add_instructor_lastname: lastname submitty_course_add_instructor_email: email - submitty_course_add_instructor_password: instructor + submitty_course_add_instructor_password: instructor2 - name: Add runner ansible.builtin.include_role: diff --git a/.setup/ansible/roles/submitty_add_user/tasks/main.yml b/.setup/ansible/roles/submitty_add_user/tasks/main.yml index 7e111984c2f..3a7422ad3d4 100644 --- a/.setup/ansible/roles/submitty_add_user/tasks/main.yml +++ b/.setup/ansible/roles/submitty_add_user/tasks/main.yml @@ -1,7 +1,7 @@ --- - name: Add student to submitty users. ansible.builtin.expect: - command: ./adduser.py {{ submitty_add_user_username }} + command: "./adduser.py {{ submitty_add_user_username }}" chdir: /usr/local/submitty/sbin/ echo: true responses: From 446059af8478f46f5e7664517ffe3317b9f3e476 Mon Sep 17 00:00:00 2001 From: IDzyre Date: Wed, 30 Jul 2025 10:30:22 -0800 Subject: [PATCH 64/73] plz --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index fbfac2da592..b7f49d09cf4 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -991,7 +991,7 @@ jobs: - name: Get API token id: get_token run: | - RESPONSE=$(curl -s -X POST -H "Content-Type: application/x-www-form-urlencoded" --data "user_id=instructor &password=instructor" http://localhost/api/token) + RESPONSE=$(curl -s -X POST -H "Content-Type: application/x-www-form-urlencoded" --data "user_id=instructor&password=instructor" http://localhost/api/token) echo "$RESPONSE" status=$(echo "$RESPONSE" | jq -r '.status') if [ "$status" = "fail" ]; then From d40867c93000be765bff342f79a56703deda9fd9 Mon Sep 17 00:00:00 2001 From: IDzyre Date: Wed, 30 Jul 2025 10:49:17 -0800 Subject: [PATCH 65/73] plz --- .github/workflows/ci.yml | 42 ++++++++++++++++++++-------------------- 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index b7f49d09cf4..36e6ebb8b10 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -988,27 +988,27 @@ jobs: run: | npm ci - - name: Get API token - id: get_token - run: | - RESPONSE=$(curl -s -X POST -H "Content-Type: application/x-www-form-urlencoded" --data "user_id=instructor&password=instructor" http://localhost/api/token) - echo "$RESPONSE" - status=$(echo "$RESPONSE" | jq -r '.status') - if [ "$status" = "fail" ]; then - exit 1 - fi - TOKEN=$(echo "$RESPONSE" | jq -r '.data.token') - echo "API_TOKEN=$TOKEN" >> $GITHUB_ENV - - - name: Debug env - if: failure() - run: | - echo ${{ env.API_TOKEN }} - - - name: Create Homework - run: | - cd .setup/ansible - ansible-playbook --private-key /home/runner/.ssh/id_rsa -e "ansible_user=runner submitty_homework_creation_api_url=http://localhost/api/term/course/upload submitty_homework_creation_api_key=${{ env.API_TOKEN }}" -i inventory/submitty playbooks/submitty_homework_creation.yml + # - name: Get API token + # id: get_token + # run: | + # RESPONSE=$(curl -s -X POST -H "Content-Type: application/x-www-form-urlencoded" --data "user_id=instructor&password=instructor" http://localhost/api/token) + # echo "$RESPONSE" + # status=$(echo "$RESPONSE" | jq -r '.status') + # if [ "$status" = "fail" ]; then + # exit 1 + # fi + # TOKEN=$(echo "$RESPONSE" | jq -r '.data.token') + # echo "API_TOKEN=$TOKEN" >> $GITHUB_ENV + + # - name: Debug env + # if: failure() + # run: | + # echo ${{ env.API_TOKEN }} + + # - name: Create Homework + # run: | + # cd .setup/ansible + # ansible-playbook --private-key /home/runner/.ssh/id_rsa -e "ansible_user=runner submitty_homework_creation_api_url=http://localhost/api/term/course/upload submitty_homework_creation_api_key=${{ env.API_TOKEN }}" -i inventory/submitty playbooks/submitty_homework_creation.yml - name: Run Ansible cypress test uses: cypress-io/github-action@v6 From 69c20671273ea959e0bf7fd502ed143cce9843ff Mon Sep 17 00:00:00 2001 From: IDzyre Date: Wed, 30 Jul 2025 18:55:56 -0800 Subject: [PATCH 66/73] Try in cypress system --- .github/workflows/ci.yml | 66 +++++++++++++++------------------------- 1 file changed, 25 insertions(+), 41 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 03d9d176cd2..9be6cb5cc78 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -801,6 +801,30 @@ jobs: http_ver=$(curl -ksI https://localhost -o/dev/null -w "%{http_version}\n") [ "$http_ver" = "2" ] && echo "Pass" || echo "::warning::Failed" + - name: Get API token + id: get_token + run: | + RESPONSE=$(curl -s -X POST -H "Content-Type: application/x-www-form-urlencoded" --data "user_id=instructor&password=instructor" http://localhost/api/token) + echo "$RESPONSE" + status=$(echo "$RESPONSE" | jq -r '.status') + if [ "$status" = "fail" ]; then + exit 1 + fi + TOKEN=$(echo "$RESPONSE" | jq -r '.data.token') + echo "API_TOKEN=$TOKEN" >> $GITHUB_ENV + + - name: Debug env + if: failure() + run: | + echo ${{ env.API_TOKEN }} + + - name: Create Homework + run: | + cd .setup/ansible + ansible-playbook --private-key /home/runner/.ssh/id_rsa -e "ansible_user=runner submitty_homework_creation_api_url=http://localhost/api/term/course/upload submitty_homework_creation_api_key=${{ env.API_TOKEN }}" -i inventory/submitty playbooks/submitty_homework_creation.yml + + + - uses: actions/upload-artifact@v4 if: failure() with: @@ -989,29 +1013,6 @@ jobs: run: | npm ci - - name: Get API token - id: get_token - run: | - RESPONSE=$(curl -s -X POST -H "Content-Type: application/x-www-form-urlencoded" --data "user_id=runner&password=runner" http://localhost/api/token) - echo "$RESPONSE" - status=$(echo "$RESPONSE" | jq -r '.status') - if [ "$status" = "fail" ]; then - echo "❌ API returned failure status" - exit 1 - fi - TOKEN=$(echo "$RESPONSE" | jq -r '.data.token') - echo "API_TOKEN=$TOKEN" >> $GITHUB_ENV - - - name: Debug env - if: failure() - run: | - echo ${{ env.API_TOKEN }} - - - name: Create Homework - run: | - cd .setup/ansible - ansible-playbook --private-key /home/runner/.ssh/id_rsa -e "ansible_user=runner submitty_homework_creation_api_url=http://localhost/api/term/course/upload submitty_homework_creation_api_key=${{ env.API_TOKEN }}" -i inventory/submitty playbooks/submitty_homework_creation.yml - - name: Run Ansible cypress test uses: cypress-io/github-action@v6 with: @@ -1019,30 +1020,13 @@ jobs: spec: cypress/e2e/Cypress-Ansible/ansible-course.spec.js working-directory: ${{env.SUBMITTY_REPOSITORY}}/site browser: chrome - - - name: Set perms for error file - if: failure() - shell: bash - run: | - sudo chmod -R a+rwx /var/local/submitty/logs/site_errors - uses: actions/upload-artifact@v4 if: failure() with: name: install-log path: /usr/local/submitty/install.log - - - uses: actions/upload-artifact@v4 - if: failure() - with: - name: site-errors - path: /var/local/submitty/logs/site_errors - - - uses: actions/upload-artifact@v4 - if: failure() - with: - name: npm-log - path: /home/runner/.npm/_logs + - uses: actions/upload-artifact@v4 if: failure() with: From a03687471de23b668f96d7a6380093a70e536120 Mon Sep 17 00:00:00 2001 From: IDzyre Date: Wed, 30 Jul 2025 18:57:25 -0800 Subject: [PATCH 67/73] Try system --- .github/workflows/ci.yml | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 9be6cb5cc78..e069640d1cf 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -823,7 +823,13 @@ jobs: cd .setup/ansible ansible-playbook --private-key /home/runner/.ssh/id_rsa -e "ansible_user=runner submitty_homework_creation_api_url=http://localhost/api/term/course/upload submitty_homework_creation_api_key=${{ env.API_TOKEN }}" -i inventory/submitty playbooks/submitty_homework_creation.yml - + - name: Run Ansible cypress test + uses: cypress-io/github-action@v6 + with: + config: baseUrl=http://localhost + spec: cypress/e2e/Cypress-Ansible/ansible-course.spec.js + working-directory: ${{env.SUBMITTY_REPOSITORY}}/site + browser: chrome - uses: actions/upload-artifact@v4 if: failure() @@ -985,13 +991,12 @@ jobs: cd .setup/ansible ansible-playbook --private-key /home/runner/.ssh/id_rsa -e 'ansible_user=runner submitty_install_submitty_version=${{ github.sha }} submitty_install_github_url=https://github.com/${{ github.repository }}.git' -i inventory/submitty playbooks/submitty_install.yml ansible-playbook --private-key /home/runner/.ssh/id_rsa -e 'ansible_user=runner' -i inventory/submitty playbooks/submitty_course_creation.yml - + - name: Set perms shell: bash run: | sudo chmod -R a+rwx ${SUBMITTY_INSTALL_DIR} sudo chmod -R a+rwx /tmp/ - sudo chmod -R a+rwx /var/local/submitty - name: Validate image run: | From 69bde0251e50dd2f8aa9d8974f257e38d75a0e29 Mon Sep 17 00:00:00 2001 From: Cameron Peterson <46759635+IDzyre@users.noreply.github.com> Date: Wed, 30 Jul 2025 19:20:31 -0800 Subject: [PATCH 68/73] Update ansible-course.spec.js --- site/cypress/e2e/Cypress-Ansible/ansible-course.spec.js | 3 --- 1 file changed, 3 deletions(-) diff --git a/site/cypress/e2e/Cypress-Ansible/ansible-course.spec.js b/site/cypress/e2e/Cypress-Ansible/ansible-course.spec.js index 76bd5d8a62a..e2afb1b8812 100644 --- a/site/cypress/e2e/Cypress-Ansible/ansible-course.spec.js +++ b/site/cypress/e2e/Cypress-Ansible/ansible-course.spec.js @@ -3,8 +3,5 @@ describe('Testing website when created by ansible scripts', () => { it('Should be able to login and see the course', () => { cy.login('instructor'); cy.visit('term/course'); - getApiKey('instructor', 'password').then((apiKey) => { - console.log('API Key:', apiKey); - }); }); }); From ec9268e7a70caced824c46540f961a270f613b19 Mon Sep 17 00:00:00 2001 From: IDzyre Date: Wed, 30 Jul 2025 20:31:31 -0800 Subject: [PATCH 69/73] Undo core and x changes --- site/app/controllers/AuthenticationController.php | 14 ++++++-------- site/app/libraries/Core.php | 1 - 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/site/app/controllers/AuthenticationController.php b/site/app/controllers/AuthenticationController.php index 001ae766df8..6cd728b622a 100644 --- a/site/app/controllers/AuthenticationController.php +++ b/site/app/controllers/AuthenticationController.php @@ -170,15 +170,13 @@ public function getToken() { $this->core->getAuthentication()->setUserId($_POST['user_id']); $this->core->getAuthentication()->setPassword($_POST['password']); $token = $this->core->authenticateJwt(); - // if ($token) { - // return MultiResponse::JsonOnlyResponse(JsonResponse::getSuccessResponse(['token' => $token])); - // } - // else { - $user_id = $_POST['user_id']; - $password = $_POST['password']; - $msg = "Could not login using that user id or password $token"; + if ($token) { + return MultiResponse::JsonOnlyResponse(JsonResponse::getSuccessResponse(['token' => $token])); + } + else { + $msg = "Could not login using that user id or password"; return MultiResponse::JsonOnlyResponse(JsonResponse::getFailResponse($msg)); - // } + } } /** diff --git a/site/app/libraries/Core.php b/site/app/libraries/Core.php index efd88d45c30..c001ac1278a 100644 --- a/site/app/libraries/Core.php +++ b/site/app/libraries/Core.php @@ -577,7 +577,6 @@ public function authenticate(bool $persistent_cookie = true): bool { */ public function authenticateJwt() { $user_id = $this->authentication->getUserId(); - return $this->authentication->authenticate(); try { if ($this->authentication->authenticate()) { $this->database_queries->refreshUserApiKey($user_id); From 45b5523bc06f0b30821f3e2b6e260b3d18473e97 Mon Sep 17 00:00:00 2001 From: Cameron Peterson <46759635+IDzyre@users.noreply.github.com> Date: Thu, 31 Jul 2025 09:16:25 -0800 Subject: [PATCH 70/73] moveu p --- .github/workflows/ci.yml | 47 ++++++++++++++++++---------------------- 1 file changed, 21 insertions(+), 26 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index e069640d1cf..b227c1fbe22 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -780,27 +780,7 @@ jobs: spec: cypress/e2e/Cypress-System/login.spec.js working-directory: ${{env.SUBMITTY_REPOSITORY}}/site browser: chrome - - - name: Setup HTTP/2 - run: | - cd $SUBMITTY_REPOSITORY - if [ -f .setup/dev-upgrade-h2.sh ]; then - sudo sed -e "s/:80/:443/g" --in-place /etc/apache2/sites-available/submitty.conf - sudo -E env "PATH=$PATH" bash .setup/dev-upgrade-h2.sh up --i-know-what-i-am-doing-please-go-ahead \ - && echo "Setup OK" \ - || { - echo "::warning::Setup Failed" - sudo sed -e "s/:443/:80/g" --in-place /etc/apache2/sites-available/submitty.conf - } - else - echo "Could not find dev-upgrade-h2.sh, skipping" - fi - - - name: Test HTTP/2 Connection - run: | - http_ver=$(curl -ksI https://localhost -o/dev/null -w "%{http_version}\n") - [ "$http_ver" = "2" ] && echo "Pass" || echo "::warning::Failed" - + - name: Get API token id: get_token run: | @@ -813,11 +793,6 @@ jobs: TOKEN=$(echo "$RESPONSE" | jq -r '.data.token') echo "API_TOKEN=$TOKEN" >> $GITHUB_ENV - - name: Debug env - if: failure() - run: | - echo ${{ env.API_TOKEN }} - - name: Create Homework run: | cd .setup/ansible @@ -831,6 +806,26 @@ jobs: working-directory: ${{env.SUBMITTY_REPOSITORY}}/site browser: chrome + - name: Setup HTTP/2 + run: | + cd $SUBMITTY_REPOSITORY + if [ -f .setup/dev-upgrade-h2.sh ]; then + sudo sed -e "s/:80/:443/g" --in-place /etc/apache2/sites-available/submitty.conf + sudo -E env "PATH=$PATH" bash .setup/dev-upgrade-h2.sh up --i-know-what-i-am-doing-please-go-ahead \ + && echo "Setup OK" \ + || { + echo "::warning::Setup Failed" + sudo sed -e "s/:443/:80/g" --in-place /etc/apache2/sites-available/submitty.conf + } + else + echo "Could not find dev-upgrade-h2.sh, skipping" + fi + + - name: Test HTTP/2 Connection + run: | + http_ver=$(curl -ksI https://localhost -o/dev/null -w "%{http_version}\n") + [ "$http_ver" = "2" ] && echo "Pass" || echo "::warning::Failed" + - uses: actions/upload-artifact@v4 if: failure() with: From 3682252a202e5cea966f6d2ec1ce64032d834b3e Mon Sep 17 00:00:00 2001 From: IDzyre Date: Thu, 31 Jul 2025 09:51:30 -0800 Subject: [PATCH 71/73] change to {} --- .github/workflows/ci.yml | 42 ++++++++++++++++++++-------------------- 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 36e6ebb8b10..9afcf217ede 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -988,27 +988,27 @@ jobs: run: | npm ci - # - name: Get API token - # id: get_token - # run: | - # RESPONSE=$(curl -s -X POST -H "Content-Type: application/x-www-form-urlencoded" --data "user_id=instructor&password=instructor" http://localhost/api/token) - # echo "$RESPONSE" - # status=$(echo "$RESPONSE" | jq -r '.status') - # if [ "$status" = "fail" ]; then - # exit 1 - # fi - # TOKEN=$(echo "$RESPONSE" | jq -r '.data.token') - # echo "API_TOKEN=$TOKEN" >> $GITHUB_ENV - - # - name: Debug env - # if: failure() - # run: | - # echo ${{ env.API_TOKEN }} - - # - name: Create Homework - # run: | - # cd .setup/ansible - # ansible-playbook --private-key /home/runner/.ssh/id_rsa -e "ansible_user=runner submitty_homework_creation_api_url=http://localhost/api/term/course/upload submitty_homework_creation_api_key=${{ env.API_TOKEN }}" -i inventory/submitty playbooks/submitty_homework_creation.yml + - name: Get API token + id: get_token + run: | + RESPONSE=$(curl -s -X POST -H "Content-Type: application/x-www-form-urlencoded" -d '{"user_id": "instructor", "password": instructor}' http://localhost/api/token) + echo "$RESPONSE" + status=$(echo "$RESPONSE" | jq -r '.status') + if [ "$status" = "fail" ]; then + exit 1 + fi + TOKEN=$(echo "$RESPONSE" | jq -r '.data.token') + echo "API_TOKEN=$TOKEN" >> $GITHUB_ENV + + - name: Debug env + if: failure() + run: | + echo ${{ env.API_TOKEN }} + + - name: Create Homework + run: | + cd .setup/ansible + ansible-playbook --private-key /home/runner/.ssh/id_rsa -e "ansible_user=runner submitty_homework_creation_api_url=http://localhost/api/term/course/upload submitty_homework_creation_api_key=${{ env.API_TOKEN }}" -i inventory/submitty playbooks/submitty_homework_creation.yml - name: Run Ansible cypress test uses: cypress-io/github-action@v6 From 370ffd904823ec6795a30064e9604c008ac67383 Mon Sep 17 00:00:00 2001 From: IDzyre Date: Thu, 31 Jul 2025 09:57:57 -0800 Subject: [PATCH 72/73] fix --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index ed9d06663c2..d793bdef16a 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1016,7 +1016,7 @@ jobs: - name: Get API token id: get_token run: | - RESPONSE=$(curl -s -X POST -H "Content-Type: application/x-www-form-urlencoded" -d '{"user_id": "instructor", "password": instructor}' http://localhost/api/token) + RESPONSE=$(curl -s -X POST -H "Content-Type: application/json" -d '{"user_id": "instructor", "password": "instructor"}' http://localhost/api/token) echo "$RESPONSE" status=$(echo "$RESPONSE" | jq -r '.status') if [ "$status" = "fail" ]; then From 0c39f14e67173ff431c30e5ec9b3376628fdd39d Mon Sep 17 00:00:00 2001 From: IDzyre Date: Thu, 31 Jul 2025 10:41:07 -0800 Subject: [PATCH 73/73] AA --- .../playbooks/submitty_homework_creation.yml | 3 +++ .../submitty_homework_creation/tasks/main.yml | 14 +++++++++++++- 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/.setup/ansible/playbooks/submitty_homework_creation.yml b/.setup/ansible/playbooks/submitty_homework_creation.yml index 112455f7bae..321b6b6f6eb 100644 --- a/.setup/ansible/playbooks/submitty_homework_creation.yml +++ b/.setup/ansible/playbooks/submitty_homework_creation.yml @@ -17,3 +17,6 @@ - name: submitty_homework_creation_passed_api_key prompt: Enter your API key private: yes + - name: submitty_homework_creation_password + prompt: Enter your password + private: yes diff --git a/.setup/ansible/roles/submitty_homework_creation/tasks/main.yml b/.setup/ansible/roles/submitty_homework_creation/tasks/main.yml index 41bc33eff19..ef089fb49ef 100644 --- a/.setup/ansible/roles/submitty_homework_creation/tasks/main.yml +++ b/.setup/ansible/roles/submitty_homework_creation/tasks/main.yml @@ -1,6 +1,18 @@ - name: Read JSON content from a file ansible.builtin.set_fact: - submitty_homework_creation_json_list: "{{ lookup('file', 'json_list.txt') | split('\n') }}" + var_json_list: "config_files/{{ lookup('file', 'json_list.txt') | split('\n') }}" + +- name: Get API key + ansible.builtin.uri: + url: "http://localhost/api/token" + method: POST + body_format: json + body: { + "user_id": "{{ submitty_homework_creation_user_id }}", + "password": "{{ submitty_homework_creation_password }}" + } + return_content: yes + register: submitty_homework_creation_api_response - name: Use task list to loop through gradeables ansible.builtin.include_tasks: