store displayName on RestSession to use it in tests
This commit is contained in:
parent
249cf4f87e
commit
4057ec8a6a
1 changed files with 12 additions and 6 deletions
|
@ -20,19 +20,25 @@ const {approveConsent} = require('./consent');
|
||||||
|
|
||||||
module.exports = class RestSession {
|
module.exports = class RestSession {
|
||||||
constructor(credentials) {
|
constructor(credentials) {
|
||||||
this.credentials = credentials;
|
this._credentials = credentials;
|
||||||
|
this._displayName = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
userId() {
|
userId() {
|
||||||
return this.credentials.userId;
|
return this._credentials.userId;
|
||||||
}
|
}
|
||||||
|
|
||||||
userName() {
|
userName() {
|
||||||
return this.credentials.userId.split(":")[0].substr(1);
|
return this._credentials.userId.split(":")[0].substr(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
displayName() {
|
||||||
|
return this._displayName;
|
||||||
}
|
}
|
||||||
|
|
||||||
async setDisplayName(displayName) {
|
async setDisplayName(displayName) {
|
||||||
await this._put(`/profile/${this.credentials.userId}/displayname`, {
|
this._displayName = displayName;
|
||||||
|
await this._put(`/profile/${this._credentials.userId}/displayname`, {
|
||||||
displayname: displayName
|
displayname: displayName
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -76,10 +82,10 @@ module.exports = class RestSession {
|
||||||
async _request(method, csApiPath, body) {
|
async _request(method, csApiPath, body) {
|
||||||
try {
|
try {
|
||||||
const responseBody = await request({
|
const responseBody = await request({
|
||||||
url: `${this.credentials.hsUrl}/_matrix/client/r0${csApiPath}`,
|
url: `${this._credentials.hsUrl}/_matrix/client/r0${csApiPath}`,
|
||||||
method,
|
method,
|
||||||
headers: {
|
headers: {
|
||||||
"Authorization": `Bearer ${this.credentials.accessToken}`
|
"Authorization": `Bearer ${this._credentials.accessToken}`
|
||||||
},
|
},
|
||||||
json: true,
|
json: true,
|
||||||
body
|
body
|
||||||
|
|
Loading…
Reference in a new issue