Skip to content

feat(/description): Encode the token for learn-ocaml 0.13.0+ & Update (testsuite, CI) #28

New issue

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

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

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Oct 3, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 1 addition & 8 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,11 @@ jobs:
strategy:
matrix:
include:
- learnocaml_image: "ocamlsf/learn-ocaml"
learnocaml_version: "0.12"
use_passwd: "false"
client_version: "0.12"
allow_failures: false
# may be removed at some point, when the following test will pass:
- learnocaml_image: "ocamlsf/learn-ocaml"
learnocaml_version: "0.12"
use_passwd: "false"
client_version: "oauth-moodle-dev"
# NOTE: currently fails because of an API version mismatch
allow_failures: true
allow_failures: false
- learnocaml_image: "pfitaxel/learn-ocaml"
learnocaml_version: "oauth-moodle-dev"
use_passwd: "false"
Expand Down
12 changes: 10 additions & 2 deletions learn-ocaml.el
Original file line number Diff line number Diff line change
Expand Up @@ -758,10 +758,18 @@ Argument CALLBACK will receive the token."
;; Wrappers
;;

(defconst learn-ocaml-compute-questions-url-token1-compat
(learn-ocaml-since-upto "0.13.0" nil))

(defun learn-ocaml-compute-questions-url (server id token)
"Get subject url for SERVER, exercise ID and user TOKEN."
;; TODO: Use token1=
(concat server "/description/" id "#token=" token))
(let ((token-param
(if (learn-ocaml-compat
learn-ocaml-compute-questions-url-token1-compat
(version-to-list (learn-ocaml-client-server-min-version server)))
(concat "#token1=" (base64-encode-string (format "%192s" token) t))
(concat "#token=" token))))
(concat server "/description/" id token-param)))

(defun learn-ocaml-show-questions (id)
"Open the questions for exercise ID in the default browser."
Expand Down
6 changes: 1 addition & 5 deletions tests/expected_description.html
Original file line number Diff line number Diff line change
@@ -1,5 +1 @@
<body>
<div id="learnocaml-exo-toolbar">
.*
</div>
</body>
<body>.*<div id="learnocaml-exo-toolbar">.*</div>.*</body>
2 changes: 1 addition & 1 deletion tests/learn-ocaml-tests.el
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ See also `learn-ocaml-client-sign-up-cmd'.")
(shell-command (concat "rm -f " file))))

(defun learn-ocaml-test-collapse-whitespace (str)
(replace-regexp-in-string "[[:space:]\n]+" " " str))
(string-trim (replace-regexp-in-string "[[:space:]\n]+" " " str)))

(defun learn-ocaml-test-client-expected-path ()
"Return ../../../learn-ocaml/_opam/bin
Expand Down