Commit 8fd8fa49 authored by Laurent's avatar Laurent

Fix symphony adapter

parent bbbe2fc2
declare var unescape: any;
import * as http from 'http';
import {PortalAdapter} from './adapter';
import * as cheerio from 'cheerio';
import {Account, Loan} from '../../models';
......@@ -22,6 +23,14 @@ export class Symphony extends PortalAdapter {
}
public request(account: Account, options: any): Promise<http.HttpResponse> {
if (!options.headers)
options.headers={};
options.headers['User-Agent'] = 'Mozilla/5.0 (X11; Linux x86_64; rv:59.0) Gecko/20100101 Firefox/59.0';
return super.request(account, options);
}
public _signIn(account: Account): Promise<any> {
if (!(account.credentials['login'] && account.credentials['password']))
return Promise.reject(new WrongLoginPassword());
......@@ -31,7 +40,8 @@ export class Symphony extends PortalAdapter {
.then ( ($) => {
if ($('input[name="userid"]').length > 0)
return Promise.reject(new WrongLoginPassword());
account.beConnected();
return Promise.resolve();
})
}
......
......@@ -73,7 +73,8 @@ export class ManagerLoanAnnecy extends HTTPScenario {
this
.expect({ url: base_url + '/api/loan/library.annecy.fr',
headers: { 'Content-Type': 'application/json' },
content: {login: 'marco', password: 'polo', barcode: 'L9876'}
method: 'POST',
content: JSON.stringify({login: 'marco', password: 'polo', barcode: 'L9876'})
},
{
content: JSON.stringify({ title: 'I love sushis',
......
......@@ -5,23 +5,31 @@ export class SymphonySignInWithSuccessfulLogin extends HTTPScenario {
public constructor(base_url: string) {
super();
this
.expect({ url: base_url + '/web2/tramp2.exe/log_in?setting_key=BMT1' },
{ content: this.homePage() })
.expect({ url: base_url + '/web2/tramp2.exe/goto/A05ppu9t.000?screen=MyAccount.html' },
.expect({ url: base_url + '/web2/tramp2.exe/log_in?setting_key=BMT1',
headers: {'User-Agent': 'Mozilla/5.0 (X11; Linux x86_64; rv:59.0) Gecko/20100101 Firefox/59.0'} },
{ content: this.homePage()})
.expect({ url: base_url + '/web2/tramp2.exe/goto/A05ppu9t.000?screen=MyAccount.html',
headers: {'User-Agent': 'Mozilla/5.0 (X11; Linux x86_64; rv:59.0) Gecko/20100101 Firefox/59.0'} },
{ content: this.loginPage() })
.expect({ url: base_url + '/web2/tramp2.exe/login_when_needed/A05qsq7s.000',
headers: {'User-Agent': 'Mozilla/5.0 (X11; Linux x86_64; rv:59.0) Gecko/20100101 Firefox/59.0',
"Content-Type": "application/x-www-form-urlencoded"},
method: 'POST',
content: 'fail_screen=LoginOTFFailed.html&screen=MyAccount.html&server=&item=&item_source=&userid=marco&pin=polo',
headers: {"Content-Type": "application/x-www-form-urlencoded"} },
content: 'fail_screen=LoginOTFFailed.html&screen=MyAccount.html&server=&item=&item_source=&userid=marco&pin=polo' },
{ content: this.accountPage() })
.expect({ url: base_url + '/web2/tramp2.exe/log_in?setting_key=BMT1' },
.expect({ url: base_url + '/web2/tramp2.exe/log_in?setting_key=BMT1',
headers: {'User-Agent': 'Mozilla/5.0 (X11; Linux x86_64; rv:59.0) Gecko/20100101 Firefox/59.0'} },
{ content: this.homePage() })
.expect({ url: base_url + '/web2/tramp2.exe/goto/A05ppu9t.000?screen=MyAccount.html' },
.expect({ url: base_url + '/web2/tramp2.exe/goto/A05ppu9t.000?screen=MyAccount.html',
headers: {'User-Agent': 'Mozilla/5.0 (X11; Linux x86_64; rv:59.0) Gecko/20100101 Firefox/59.0'} },
{ content: this.loginPage() })
.expect({ url: base_url + '/web2/tramp2.exe/login_when_needed/A05qsq7s.000',
headers: {'User-Agent': 'Mozilla/5.0 (X11; Linux x86_64; rv:59.0) Gecko/20100101 Firefox/59.0',
"Content-Type": "application/x-www-form-urlencoded"},
method: 'POST',
content: 'fail_screen=LoginOTFFailed.html&screen=MyAccount.html&server=&item=&item_source=&userid=marco&pin=polo',
headers: {"Content-Type": "application/x-www-form-urlencoded"} },
content: 'fail_screen=LoginOTFFailed.html&screen=MyAccount.html&server=&item=&item_source=&userid=marco&pin=polo' },
{ content: this.accountPage() })
}
......
declare var describe, expect, it, before, beforeEach, chai: any;
import {Loan, Account, Database, Portal} from '../../models/';
import {Symphony} from '../../models/';
import {Symphony} from '../../models/portal/symphony';
import {SymphonySignInWithSuccessfulLogin} from './symphony-fixtures';
describe('Account on Symphony', () => {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment