github.com/cozy/cozy-stack@v0.0.0-20240603063001-31110fa4cae1/tests/system/lib/export.rb (about) 1 class Export 2 def doctype 3 "io.cozy.exports" 4 end 5 6 def initialize(inst) 7 @inst = inst 8 end 9 10 def run 11 body = JSON.generate data: { attributes: {} } 12 opts = { 13 accept: "application/vnd.api+json", 14 authorization: "Bearer #{@inst.token_for doctype}" 15 } 16 @inst.client["/move/exports"].post body, opts 17 end 18 19 def get_link(timeout = 20) 20 timeout.times do 21 sleep 1 22 received = Email.received kind: "to", query: @inst.email 23 return extract_link received.first if received.any? 24 end 25 raise "Export mail was not received after #{timeout} seconds" 26 end 27 28 def extract_link(mail) 29 parts = mail.body.split "\r\n" 30 parts.shift while parts.first !~ /^http:/ 31 parts.map { |p| p.chomp "=" }.join('') 32 end 33 end