Skip to content
Snippets Groups Projects
Commit 8e913da1 authored by Bruno Michel's avatar Bruno Michel
Browse files

Fix the sharing tests

Add to the sharings tests a ruby implementation to derive the password
on the client side.
parent 375a9163
No related branches found
No related tags found
No related merge requests found
......@@ -5,6 +5,7 @@ gem "faker"
gem "faye-websocket"
gem "mimemagic"
gem "minitest"
gem "pbkdf2-ruby"
gem "pry"
gem "pry-rescue"
gem "pry-stack_explorer"
......
......@@ -27,6 +27,7 @@ GEM
mimemagic (0.3.2)
minitest (5.11.3)
netrc (0.11.0)
pbkdf2-ruby (0.2.1)
pry (0.11.3)
coderay (~> 1.1.0)
method_source (~> 0.9.0)
......@@ -56,10 +57,11 @@ DEPENDENCIES
faye-websocket
mimemagic
minitest
pbkdf2-ruby
pry
pry-rescue
pry-stack_explorer
rest-client
BUNDLED WITH
1.15.1
1.16.4
......@@ -5,6 +5,7 @@ require 'faker'
require 'fileutils'
require 'mimemagic'
require 'json'
require 'pbkdf2'
require 'pry'
require 'rest-client'
......
......@@ -31,7 +31,7 @@ class Accept
client = RestClient::Resource.new @inst.url
res = client["/auth/login"].get
csrf_token = res.cookies["_csrf"]
body = { csrf_token: csrf_token, passphrase: @inst.passphrase }
body = { csrf_token: csrf_token, passphrase: @inst.derived_passphrase }
params = { cookies: res.cookies, accept: :json }
res2 = client["/auth/login"].post body, params
res2.cookies["cozysessid"]
......
......@@ -72,7 +72,19 @@ class Instance
Accept.new(sharing, sharer).on self
end
def fsck
@stack.fsck self
end
# See https://github.com/jcs/rubywarden/blob/master/API.md#example
def derived_passphrase
PBKDF2.new do |p|
p.password = passphrase
p.salt = "me@" + domain.split(':').first
p.iterations = 10_000 # See pkg/crypto/pbkdf2.go
p.hash_function = OpenSSL::Digest::SHA256
p.key_length = (256 / 8)
end.bin_string
end
end
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment