Skip to content

Commit e61f209

Browse files
committed
test: add test to ensure v1 endpoints use oauth apps to authenticate users
1 parent 2a7626d commit e61f209

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed

apps/meteor/tests/end-to-end/api/oauth-server.ts

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,4 +142,37 @@ describe('[OAuth Server]', () => {
142142
});
143143
});
144144
});
145+
146+
describe('[oauth credentials]', () => {
147+
let accessToken: string;
148+
149+
before(() => {
150+
accessToken = refreshedAccessToken;
151+
});
152+
153+
it('should be able to use oauth credentials to access v1 endpoints (/v1/me)', async () => {
154+
await request
155+
.get(api('me'))
156+
.auth(accessToken, { type: 'bearer' })
157+
.expect('Content-Type', 'application/json')
158+
.expect(200)
159+
.expect((res: Response) => {
160+
expect(res.body).to.have.property('success', true);
161+
expect(res.body).to.have.property('_id', 'rocketchat.internal.admin.test');
162+
});
163+
});
164+
165+
it('should be able to use oauth credentials to access v1 endpoints (/v1/users.info)', async () => {
166+
await request
167+
.get(api('users.info'))
168+
.query({ username: 'rocketchat.internal.admin.test' })
169+
.auth(accessToken, { type: 'bearer' })
170+
.expect('Content-Type', 'application/json')
171+
.expect(200)
172+
.expect((res: Response) => {
173+
expect(res.body).to.have.property('success', true);
174+
expect(res.body).to.have.nested.property('user._id', 'rocketchat.internal.admin.test');
175+
});
176+
});
177+
});
145178
});

0 commit comments

Comments
 (0)