Skip to content

Commit

Permalink
Merge pull request #11 from UserOfficeProject/878-fix-seps-test-stfc
Browse files Browse the repository at this point in the history
878 Update Mock server for FAPs
  • Loading branch information
TCMeldrum authored Dec 15, 2023
2 parents 203bc79 + d598956 commit af56a30
Show file tree
Hide file tree
Showing 21 changed files with 37 additions and 7 deletions.
16 changes: 14 additions & 2 deletions src/mockserver.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,10 @@ async function mockserver() {
const roleMappings = {
user: 1, // Internal user
officer: 2,
externalUser: 4,
reviewer: 3,
internalUser: 4, //Internal user 2
externalUser: 5,
secretary: 6
};

let responsePath;
Expand Down Expand Up @@ -96,13 +99,21 @@ async function mockserver() {
* This will match user id of test users in the database form e2e cypress
* initialDBData users.
*/
if (match[1] === 1 || match[1] === 4) {
if (match[1] === '1' || match[1] === '2' || match[1] === '3' || match[1] === '4' || match[1] === '5' || match['1'] === '6') {
responsePath = 'src/responses/user/' + method + '/' + match[1] + '.xml';
} else {
responsePath = 'src/responses/user/notEmptyResponse' + '.xml';
}
}

if (
method === 'getBasicPeopleDetailsFromSurname' &&
requestXml.includes('<Surname>')
) {
const match = requestXml.match('<Surname>(.*?)<');
responsePath = 'src/responses/user/' + method + '/' + match[1] + '.xml';
}

if (responsePath === null || responsePath === undefined) {
responsePath = 'src/responses/user/' + method + '.xml';
}
Expand All @@ -113,6 +124,7 @@ async function mockserver() {
return null;
} else {
logger.logInfo('Returning response file', { responsePath });
logger.logInfo('Returningfrom request', { method });

const file = fs.readFileSync(responsePath, 'utf8');

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"><soap:Body><ns2:getBasicPeopleDetailsFromSurnameResponse xmlns:ns2="http://webservice.UserOffice.stfc.com/"><return><country>UNITED KINGDOM</country><deptAcronym>SCD</deptAcronym><deptName>Scientific Computing</deptName><displayName>Benjamin Beckley</displayName><email>[email protected]</email><establishmentId>5</establishmentId><familyName>Beckley</familyName><fedId>puf57046</fedId><firstNameKnownAs>Ben</firstNameKnownAs><fullName>Mr Benjamin Bryson Beckley</fullName><givenName>Benjamin</givenName><initials>B</initials><mobilePhone>085793668438</mobilePhone><orgName>None STFC</orgName><status>Undergraduate Student</status><title>Mr</title><userNumber>4</userNumber></return></ns2:getBasicPeopleDetailsFromSurnameResponse></soap:Body></soap:Envelope>
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"><soap:Body><ns2:getBasicPeopleDetailsFromSurnameResponse xmlns:ns2="http://webservice.UserOffice.stfc.com/"><return><country>UNITED KINGDOM</country><deptAcronym>SCD</deptAcronym><deptName>Scientific Computing</deptName><displayName>Carl Carlsson</displayName><email>[email protected]</email><establishmentId>5</establishmentId><familyName>Carlsson</familyName><firstNameKnownAs>Carl</firstNameKnownAs><fullName>Mr Carl Carlsson</fullName><givenName>Carl</givenName><initials>C</initials><orgName>STFC</orgName><title>Mr</title><userNumber>1</userNumber></return></ns2:getBasicPeopleDetailsFromSurnameResponse></soap:Body></soap:Envelope>
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"><soap:Body><ns2:getBasicPeopleDetailsFromSurnameResponse xmlns:ns2="http://webservice.UserOffice.stfc.com/"><return><country>UNITED KINGDOM</country><deptAcronym>SCD</deptAcronym><deptName>Scientific Computing</deptName><displayName>Nils</displayName><email>[email protected]</email><establishmentId>5</establishmentId><familyName>Nilsson</familyName><firstNameKnownAs>Nils</firstNameKnownAs><fullName>Mr Nils Nilsson</fullName><givenName>Nils</givenName><initials>N</initials><orgName>STFC</orgName><title>Mr</title><userNumber>3</userNumber></return></ns2:getBasicPeopleDetailsFromSurnameResponse></soap:Body></soap:Envelope>
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"><soap:Body><ns2:getBasicPeopleDetailsFromUserNumbersResponse xmlns:ns2="http://webservice.UserOffice.stfc.com/"><return><country>UNITED KINGDOM</country><deptAcronym>SCD</deptAcronym><deptName>Scientific Computing</deptName><displayName>Nils</displayName><email>[email protected]</email><establishmentId>5</establishmentId><familyName>Nilsson</familyName><firstNameKnownAs>Nils</firstNameKnownAs><fullName>Mr Nils Nilsson</fullName><givenName>Nils</givenName><initials>N</initials><orgName>STFC</orgName><title>Mr</title><userNumber>3</userNumber></return></ns2:getBasicPeopleDetailsFromUserNumbersResponse></soap:Body></soap:Envelope>
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"><soap:Body><ns2:getBasicPersonDetailsFromUserNumbersResponse xmlns:ns2="http://webservice.UserOffice.stfc.com/"><return><country>UNITED KINGDOM</country><deptAcronym>SCD</deptAcronym><deptName>Scientific Computing</deptName><displayName>Benjamin Beckley</displayName><email>[email protected]</email><establishmentId>7</establishmentId><familyName>Beckley</familyName><firstNameKnownAs>Ben</firstNameKnownAs><fullName>Mr Benjamin Beckley</fullName><givenName>Benjamin</givenName><initials>B</initials><orgName>STFC</orgName><title>Mr</title><userNumber>4</userNumber></return></ns2:getBasicPeopleDetailsFromUserNumbersResponse></soap:Body></soap:Envelope>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"><soap:Body><ns2:getBasicPeopleDetailsFromUserNumbersResponse xmlns:ns2="http://webservice.UserOffice.stfc.com/"><return><country>UNITED KINGDOM</country><deptAcronym>SCD</deptAcronym><deptName>Scientific Computing</deptName><displayName>Benjamin Beckley</displayName><email>[email protected]</email><establishmentId>7</establishmentId><familyName>Beckley</familyName><firstNameKnownAs>Ben</firstNameKnownAs><fullName>Mr Benjamin Beckley</fullName><givenName>Benjamin</givenName><initials>B</initials><orgName>STFC</orgName><title>Mr</title><userNumber>4</userNumber></return></ns2:getBasicPeopleDetailsFromUserNumbersResponse></soap:Body></soap:Envelope>
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"><soap:Body><ns2:getBasicPeopleDetailsFromUserNumbersResponse xmlns:ns2="http://webservice.UserOffice.stfc.com/"><return><country>UNITED KINGDOM</country><deptAcronym>SCD</deptAcronym><deptName>Scientific Computing</deptName><displayName>Benjamin Beckley</displayName><email>[email protected]</email><establishmentId>5</establishmentId><familyName>Benjamin</familyName><fedId>puf57046</fedId><firstNameKnownAs>Ben</firstNameKnownAs><fullName>Mr Benjamin Bryson Beckley</fullName><givenName>Benjamin</givenName><initials>B</initials><mobilePhone>085793668438</mobilePhone><orgName>None STFC</orgName><status>Undergraduate Student</status><title>Mr</title><userNumber>5</userNumber></return></ns2:getBasicPeopleDetailsFromUserNumbersResponse></soap:Body></soap:Envelope>
2 changes: 2 additions & 0 deletions src/responses/user/getBasicPeopleDetailsFromUserNumbers/6.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"><soap:Body><ns2:getBasicPeopleDetailsFromUserNumbersResponse xmlns:ns2="http://webservice.UserOffice.stfc.com/"><return><country>UNITED KINGDOM</country><deptAcronym>SCD</deptAcronym><deptName>Scientific Computing</deptName><displayName>David Dawson</displayName><email>[email protected]</email><establishmentId>5</establishmentId><familyName>Dawson</familyName><fedId>abc12345</fedId><firstNameKnownAs>David</firstNameKnownAs><fullName>Mr David
Dawson</fullName><givenName>David</givenName><initials>DD</initials><mobilePhone>08579366828</mobilePhone><orgName>STFC</orgName><status>Undergraduate Student</status><title>Mr</title><userNumber>6</userNumber></return></ns2:getBasicPeopleDetailsFromUserNumbersResponse></soap:Body></soap:Envelope>
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"><soap:Body><ns2:getBasicPersonDetailsFromUserNumberResponse xmlns:ns2="http://webservice.UserOffice.stfc.com/"><return><country>UNITED KINGDOM</country><deptAcronym>SCD</deptAcronym><deptName>Scientific Computing</deptName><displayName>Nils</displayName><email>[email protected]</email><establishmentId>5</establishmentId><familyName>Nilsson</familyName><firstNameKnownAs>Nils</firstNameKnownAs><fullName>Mr Nils Nilsson</fullName><givenName>Nils</givenName><initials>N</initials><orgName>STFC</orgName><title>Mr</title><userNumber>3</userNumber></return></ns2:getBasicPersonDetailsFromUserNumberResponse></soap:Body></soap:Envelope>
1 change: 1 addition & 0 deletions src/responses/user/getPersonDetailsFromSessionId/3.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"><soap:Body><ns2:getPersonDetailsFromSessionIdResponse xmlns:ns2="http://webservice.UserOffice.stfc.com/"><return><country>UNITED KINGDOM</country><deptAcronym>SCD</deptAcronym><deptName>Scientific Computing</deptName><displayName>Nils</displayName><email>[email protected]</email><establishmentId>5</establishmentId><familyName>Nilsson</familyName><firstNameKnownAs>Nils</firstNameKnownAs><fullName>Mr Nils Nilsson</fullName><givenName>Nils</givenName><initials>N</initials><orgName>STFC</orgName><title>Mr</title><userNumber>3</userNumber></return></ns2:getPersonDetailsFromSessionIdResponse></soap:Body></soap:Envelope>
1 change: 1 addition & 0 deletions src/responses/user/getPersonDetailsFromSessionId/5.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"><soap:Body><ns2:getPersonDetailsFromSessionIdResponse xmlns:ns2="http://webservice.UserOffice.stfc.com/"><return><country>UNITED KINGDOM</country><deptAcronym>SCD</deptAcronym><deptName>Scientific Computing</deptName><displayName>Benjamin Beckley</displayName><email>[email protected]</email><establishmentId>5</establishmentId><familyName>Benjamin</familyName><fedId>puf57046</fedId><firstNameKnownAs>Ben</firstNameKnownAs><fullName>Mr Benjamin Bryson Beckley</fullName><givenName>Benjamin</givenName><initials>B</initials><mobilePhone>085793668438</mobilePhone><orgName>None STFC</orgName><status>Undergraduate Student</status><title>Mr</title><userNumber>5</userNumber></return></ns2:getPersonDetailsFromSessionIdResponse></soap:Body></soap:Envelope>
3 changes: 3 additions & 0 deletions src/responses/user/getPersonDetailsFromSessionId/6.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"><soap:Body><ns2:getPersonDetailsFromSessionIdResponse xmlns:ns2="http://webservice.UserOffice.stfc.com/"><return><country>UNITED KINGDOM</country><deptAcronym>SCD</deptAcronym><deptName>Scientific Computing</deptName><displayName>David Dawson</displayName><email>[email protected]</email><establishmentId>5</establishmentId><familyName>Dawson</familyName><fedId>abc12345</fedId><firstNameKnownAs>David</firstNameKnownAs><fullName>Mr David
Dawson</fullName><givenName>David</givenName><initials>DD</initials><mobilePhone>08579366828</mobilePhone><orgName>STFC</orgName><status>Undergraduate Student</status><title>Mr</title><userNumber>6</userNumber></return></ns2:getPersonDetailsFromSessionIdResponse></soap:Body></soap:Envelope>

2 changes: 1 addition & 1 deletion src/responses/user/getRolesForUser/1.xml
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"><soap:Body><ns2:getRolesForUserResponse xmlns:ns2="http://webservice.UserOffice.stfc.com/"><return><name>Internal proposal submitter</name></return></ns2:getRolesForUserResponse></soap:Body></soap:Envelope>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"><soap:Body><ns2:getRolesForUserResponse xmlns:ns2="http://webservice.UserOffice.stfc.com/"><return><name>Internal proposal submitter</name></return><return><name>FAP Member</name></return><return><name>FAP Secretary</name></return><return><name>ISIS Instrument Scientist</name></return><return><name>Internal Reviewer</name></return></ns2:getRolesForUserResponse></soap:Body></soap:Envelope>
1 change: 1 addition & 0 deletions src/responses/user/getRolesForUser/3.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"><soap:Body><ns2:getRolesForUserResponse xmlns:ns2="http://webservice.UserOffice.stfc.com/"><return><name>FAP Member</name></return></ns2:getRolesForUserResponse></soap:Body></soap:Envelope>
2 changes: 1 addition & 1 deletion src/responses/user/getRolesForUser/4.xml
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"><soap:Body><ns2:getRolesForUserResponse xmlns:ns2="http://webservice.UserOffice.stfc.com/"><return><name>User</name></return></ns2:getRolesForUserResponse></soap:Body></soap:Envelope>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"><soap:Body><ns2:getRolesForUserResponse xmlns:ns2="http://webservice.UserOffice.stfc.com/"><return><name>User</name></return><return><name>FAP Secretary</name></return><return><name>FAP Member</name></return><return><name>FAP Chair</name></return><return><name>ISIS Instrument Scientist</name></return><return><name>Internal Reviewer</name></return></ns2:getRolesForUserResponse></soap:Body></soap:Envelope>
1 change: 1 addition & 0 deletions src/responses/user/getRolesForUser/5.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"><soap:Body><ns2:getRolesForUserResponse xmlns:ns2="http://webservice.UserOffice.stfc.com/"><return><name>User</name></return></ns2:getRolesForUserResponse></soap:Body></soap:Envelope>
1 change: 1 addition & 0 deletions src/responses/user/getRolesForUser/6.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"><soap:Body><ns2:getRolesForUserResponse xmlns:ns2="http://webservice.UserOffice.stfc.com/"><return><name>FAP Member</name></return><return><name>FAP Secretary</name></return></ns2:getRolesForUserResponse></soap:Body></soap:Envelope>
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"><soap:Body><ns2:getSearchableBasicPeopleDetailsFromUserNumbersResponse xmlns:ns2="http://webservice.UserOffice.stfc.com/"><return><country>UNITED KINGDOM</country><deptAcronym>SCD</deptAcronym><deptName>Scientific Computing</deptName><displayName>Anders Andersson</displayName><email>[email protected]</email><establishmentId>7</establishmentId><familyName>Beckley</familyName><firstNameKnownAs>Benjamin</firstNameKnownAs><fullName>Mr Benjamin Beckley</fullName><givenName>Benjamin</givenName><initials>B</initials><orgName>STFC</orgName><title>Mr</title><userNumber>2</userNumber></return></ns2:getSearchableBasicPeopleDetailsFromUserNumbersResponse></soap:Body></soap:Envelope>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"><soap:Body><ns2:getSearchableBasicPeopleDetailsFromUserNumbersResponse xmlns:ns2="http://webservice.UserOffice.stfc.com/"><return><country>UNITED KINGDOM</country><deptAcronym>SCD</deptAcronym><deptName>Scientific Computing</deptName><displayName>Anders Andersson</displayName><email>[email protected]</email><establishmentId>7</establishmentId><familyName>Andersson</familyName><firstNameKnownAs>Anders</firstNameKnownAs><fullName>Mr Anders Andersson</fullName><givenName>Anders</givenName><initials>A</initials><orgName>STFC</orgName><title>Mr</title><userNumber>2</userNumber></return></ns2:getSearchableBasicPeopleDetailsFromUserNumbersResponse></soap:Body></soap:Envelope>
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"><soap:Body><ns2:getSearchableBasicPeopleDetailsFromUserNumbersResponse xmlns:ns2="http://webservice.UserOffice.stfc.com/"><return><country>UNITED KINGDOM</country><deptAcronym>SCD</deptAcronym><deptName>Scientific Computing</deptName><displayName>Nils</displayName><email>[email protected]</email><establishmentId>5</establishmentId><familyName>Nilsson</familyName><firstNameKnownAs>Nils</firstNameKnownAs><fullName>Mr Nils Nilsson</fullName><givenName>Nils</givenName><initials>N</initials><orgName>STFC</orgName><title>Mr</title><userNumber>3</userNumber></return></ns2:getSearchableBasicPeopleDetailsFromUserNumbersResponse></soap:Body></soap:Envelope>
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"><soap:Body><ns2:getPersonDetailsFromSessionIdResponse xmlns:ns2="http://webservice.UserOffice.stfc.com/"><return><country>UNITED KINGDOM</country><deptAcronym>SCD</deptAcronym><deptName>Scientific Computing</deptName><displayName>Benjamin Beckley</displayName><email>[email protected]</email><establishmentId>5</establishmentId><familyName>Benjamin</familyName><fedId>puf57046</fedId><firstNameKnownAs>Ben</firstNameKnownAs><fullName>Mr Benjamin Bryson Beckley</fullName><givenName>Benjamin</givenName><initials>B</initials><mobilePhone>085793668438</mobilePhone><orgName>None STFC</orgName><status>Undergraduate Student</status><title>Mr</title><userNumber>5</userNumber></return></ns2:getPersonDetailsFromSessionIdResponse></soap:Body></soap:Envelope>
Loading

0 comments on commit af56a30

Please sign in to comment.