Skip to content
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

add test book #199

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
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
3 changes: 3 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,6 @@ indent_size = 2

[*.nsi]
indent_size = 2

[*.{css,js,html}]
indent_size = 2
118 changes: 58 additions & 60 deletions client/api.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,65 +15,65 @@ HTTP <CODE>
```

Voici la liste des erreurs par ordre alphabétique:
- `archived_workspace` (HTTP 403)
- `archiving_not_allowed` (HTTP 403)
- `archiving_period_is_too_short` (HTTP 400)
- `authentication_requested` (HTTP 401)
- `bad_claimer_sas` (HTTP 400)
- `bad_data` (HTTP 400)
- `bad_greeter_sas` (HTTP 400)
- `bad_key` (HTTP 400)
- `bad_timestamp_configuration` (HTTP 400)
- `cannot_delete_root_folder` (HTTP 400)
- `cannot_move_root_folder` (HTTP 400)
- `cannot_use_both_authentication_modes` (HTTP 400)
- `claimer_already_member` (HTTP 400)
- `claimer_not_a_member` (HTTP 400)
- `connection_refused_by_server` (HTTP 502)
- `deleted_workspace` (HTTP 410)
- `destination_parent_not_a_folder` (HTTP 400)
- `device_not_found` (HTTP 404)
- `archived_workspace` (HTTP 403) opération non autorisée, cause : espace archivé
- `archiving_not_allowed` (HTTP 403) archivage impossible
- `archiving_period_is_too_short` (HTTP 400) la période d'archivage est trop courte
- `authentication_requested` (HTTP 401) authentification requise
- `bad_claimer_sas` (HTTP 400) mauvais code sas
- `bad_data` (HTTP 400) mauvais champ (le champ doit être présent dans le champ fields)
- `bad_greeter_sas` (HTTP 400) mauvais code sas
- `bad_key` (HTTP 400) mot de passe incorrect
- `bad_timestamp_configuration` (HTTP 400) Date incorrecte
- `cannot_delete_root_folder` (HTTP 400) impossible de supprimer le dossier racine
- `cannot_move_root_folder` (HTTP 400) impossible de déplacer le dossier racine
- `claimer_already_member` (HTTP 400) utilisateur déjà enrôlé
- `claimer_not_a_member` (HTTP 400) Shamir : le compte à récupérer n'existe pas
- `connection_refused_by_server` (HTTP 502) Connexion refusée par le serveur
- `deleted_workspace` (HTTP 410) Opération impossible, espace supprimé
- `destination_parent_not_a_folder` (HTTP 400) déplacement impossible, la destination n'est pas un dossier
- `device_not_found` (HTTP 404) fichier de clé non trouvé sur le poste
- `email_not_in_recipients` (HTTP 400)
- `failed_to_disable_offline_availability` (HTTP 400)
- `failed_to_enable_offline_availability` (HTTP 400)
- `file_exists` (HTTP 400)
- `forbidden_workspace` (HTTP 403)
- `invalid_configuration` (HTTP 400)
- `invalid_passphrase` (HTTP 400)
- `invalid_state` (HTTP 409)
- `invitation_already_used` (HTTP 400)
- `invitation_not_found` (HTTP 400)
- `json_body_expected` (HTTP 400)
- `mountpoint_already_mounted` (HTTP 400)
- `mountpoint_not_mounted` (HTTP 404)
- `no_shamir_recovery_setup` (HTTP 400)
- `not_enough_shares` (HTTP 400)
- `not_a_file` (HTTP 404)
- `not_a_folder` (HTTP 404)
- `not_connected_to_rie` (HTTP 401)
- `not_found` (HTTP 404)
- `not_setup` (HTTP 404)
- `offline` (HTTP 503)
- `offline_availability_already_disabled` (HTTP 400)
- `offline_availability_already_enabled` (HTTP 400)
- `organization_already_bootstrapped` (HTTP 400)
- `precondition_failed` (HTTP 409)
- `read_only_workspace` (HTTP 403)
- `recipient_already_recovered` (HTTP 400)
- `sharing_not_allowed` (HTTP 403)
- `source_not_a_folder` (HTTP 404)
- `unexpected_error` (HTTP 400)
- `unknown_destination_parent` (HTTP 404)
- `unknown_email` (HTTP 404)
- `unknown_entry` (HTTP 404)
- `unknown_file` (HTTP 404)
- `unknown_folder` (HTTP 404)
- `unknown_organization` (HTTP 404)
- `unknown_parent` (HTTP 404)
- `unknown_source` (HTTP 404)
- `unknown_token` (HTTP 404)
- `unknown_workspace` (HTTP 404)
- `users_not_found` (HTTP 400)
- `failed_to_disable_offline_availability` (HTTP 400) impossible de désactiver la rémanence des données
- `failed_to_enable_offline_availability` (HTTP 400) impossible d'activer la rémanence des données
- `file_exists` (HTTP 400) le fichier existe déjà
- `forbidden_workspace` (HTTP 403) accès à l'espace interdit
- `host_machine_not_compliant` (HTTP 401) le poste de répond pas aux conditions de conformité
- `invalid_configuration` (HTTP 400) Shamir : mauvaise configuration
- `invalid_passphrase` (HTTP 400) import de clé : mauvaise passphrase
- `invalid_state` (HTTP 409) état invalide (désynchonisation des utilisateurs), il faut repartir à l'étape 1
- `invitation_already_used` (HTTP 400) invitation déjà utilisée
- `invitation_not_found` (HTTP 400) invitation introuvable
- `json_body_expected` (HTTP 400) json attendu en payload
- `mountpoint_already_mounted` (HTTP 400) point de montage déjà monté
- `mountpoint_not_mounted` (HTTP 404) point de montage non monté
- `no_shamir_recovery_setup` (HTTP 400) Shamir : pas de configuration présente
- `not_enough_shares` (HTTP 400) Shamir : pas assez de partage
- `not_a_file` (HTTP 404) pas un fichier
- `not_a_folder` (HTTP 404) pas un dossier
- `not_connected_to_rie` (HTTP 401) connexion impossible, utilisateur non connecté sur le RIE
- `not_found` (HTTP 404) introuvable
- `not_setup` (HTTP 404) Shamir : non paramétré
- `offline` (HTTP 503) serveur injoignable
- `offline_availability_already_disabled` (HTTP 400) rémanence des donnée déjà désactivé
- `offline_availability_already_enabled` (HTTP 400) rémanence des donnée déjà activé
- `organization_already_bootstrapped` (HTTP 400) organisation déjà validée
- `precondition_failed` (HTTP 409) mauvais nom actuel de l'espace
- `read_only_workspace` (HTTP 403) espace en lecture seule
- `recipient_already_recovered` (HTTP 400) Shamir
- `sharing_not_allowed` (HTTP 403) partage non autorisé
- `source_not_a_folder` (HTTP 404) la source n'est pas un dossier
- `unexpected_error` (HTTP 400) Shamir
- `unknown_destination_parent` (HTTP 404) destination inconnue
- `unknown_email` (HTTP 404) email inconnu
- `unknown_entry` (HTTP 404) entrée inconnue
- `unknown_file` (HTTP 404) fichier inconnue
- `unknown_folder` (HTTP 404) dossier inconnu
- `unknown_organization` (HTTP 404) organisation inconnue
- `unknown_parent` (HTTP 404) parent inconnu
- `unknown_source` (HTTP 404) source inconnue
- `unknown_token` (HTTP 404) token inconnu
- `unknown_workspace` (HTTP 404) espace inconnu
- `users_not_found` (HTTP 400) utilisateurs non trouvés


Une erreur dans le formatage de la requête est retournée sous la forme suivante:
Expand Down Expand Up @@ -173,8 +173,6 @@ Deux différentes options sont disponibles pour l'authentification :

`email` correspondant à l'email utilisé lors de l'enrôlement RESANA Secure.

`user_password` doit être une chaîne de caractère échappé pour répondre aux normes json

**Response:**


Expand Down
97 changes: 97 additions & 0 deletions misc/test_book/auth.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
// LOGIN

function login() {
const email = document.getElementById("auth-email").value;
const key = document.getElementById("auth-key").value;
const organization = document.getElementById("auth-organization-id").value;
const encryptedKey = document.getElementById("auth-encrypted-key").value;
const http = new XMLHttpRequest();
http.open("POST", "http://localhost:5775/auth");
http.setRequestHeader("Content-type", "application/json");
http.send(JSON.stringify({
email,
key,
organization,
encrypted_key: encryptedKey,
}));
http.onreadystatechange = (e) => {
document.getElementById("auth-result").innerHTML = getHttpResult(http);
if (http.status === 200) {
document.getElementById("auth-info").innerHTML = `${email} | ${organization}`;
tokenSession = JSON.parse(http.responseText).token;
listWorkspaces();
}
}
}

const storageKey = "resana-secure-release-tests-key-auth";

function saveAuth() {
const auth = {};
let storage = null;
auth['email'] = document.getElementById("auth-email").value;
auth['key'] = document.getElementById("auth-key").value;
auth['organization'] = document.getElementById("auth-organization-id").value;
auth['encryptedKey'] = document.getElementById("auth-encrypted-key").value;
auth['password'] = document.getElementById("auth-password").value;
storage = localStorage.getItem(storageKey) || "[]";
storage = JSON.parse(storage);
storage.push(auth);
localStorage.setItem(storageKey, JSON.stringify(storage));
}

function listAuth() {
let saves = [];
const storage = localStorage.getItem(storageKey);
saves = JSON.parse(storage) || [];
const modal = document.getElementById("save-modal");
modal.style.display = "block";
const listElem = document.getElementById("saves-list");
listElem.innerHTML = "";
saves.forEach((save, index) => {
listElem.innerHTML += `<li onclick="loadAuth(${index})">${save.email} | ${save.key} | ${save.organization}</li>`;
});
}

function loadAuth(index) {
const storage = localStorage.getItem(storageKey);
const saves = JSON.parse(storage) || [];
document.getElementById("auth-email").value = saves[index].email;
document.getElementById("auth-key").value = saves[index].key;
document.getElementById("auth-organization-id").value = saves[index].organization;
document.getElementById("auth-encrypted-key").value = saves[index].encryptedKey;
document.getElementById("auth-password").value = saves[index].password;
const modal = document.getElementById("save-modal");
modal.style.display = "none";
}

function closeAuthModal() {
const elem = document.getElementById("save-modal");
elem.style.display = "none";
}


// LOGOUT
function deconnect(force = false) {
const http = new XMLHttpRequest();
http.open("DELETE", "http://localhost:5775/auth");
http.setRequestHeader("Authorization", `bearer ${tokenSession}`);
http.send();
http.onreadystatechange = (e) => {
document.getElementById("auth-info").innerHTML = "";
document.getElementById("logout-result").innerHTML = getHttpResult(http);
}
openAccount(force);
}

function deconnectAll(force = false) {
const http = new XMLHttpRequest();
http.open("DELETE", "http://localhost:5775/auth/all");
http.setRequestHeader("Authorization", `bearer ${tokenSession}`);
http.send();
http.onreadystatechange = (e) => {
document.getElementById("auth-info").innerHTML = "";
document.getElementById("logout-result").innerHTML = getHttpResult(http);
}
openAccount(force);
}
18 changes: 18 additions & 0 deletions misc/test_book/bootstrap.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
function boostrap() {
const organizationUrl = document.getElementById("bootstrap-url").value;
const sequesterVerifyKey = document.getElementById("sequester-verify-key").value;
const email = document.getElementById("bootstrap-email").value;
const key = document.getElementById("bootstrap-key").value;
const http = new XMLHttpRequest();
http.open("POST", "http://localhost:5775/organization/bootstrap");
http.setRequestHeader("Content-type", "application/json");
http.send(JSON.stringify({
organization_url: organizationUrl,
email,
key,
sequester_verify_key: sequesterVerifyKey
}));
http.onreadystatechange = (e) => {
document.getElementById("bootstrap-result").innerHTML = getHttpResult(http);
}
}
7 changes: 7 additions & 0 deletions misc/test_book/common.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
function getHttpResult(http) {
try {
return `${http.status}<br>` + JSON.stringify(JSON.parse(http.responseText), null, 4);
} catch (error) {
return `${http.status} ${http.responseURL}<br>` + http.responseText.replace(/</gi, "&lt;").replace(/>/gi, "&gt;");
}
}
Empty file added misc/test_book/file.js
Empty file.
Empty file added misc/test_book/folder.js
Empty file.
Loading
Loading