Skip to content

Commit

Permalink
chore!: remove deprecated endpoint pw.getPolicyReset (#33474)
Browse files Browse the repository at this point in the history
  • Loading branch information
abhinavkrin authored and ggazzo committed Oct 11, 2024
1 parent 3e022d8 commit 4320db6
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 96 deletions.
6 changes: 6 additions & 0 deletions .changeset/fair-bees-wash.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
'@rocket.chat/rest-typings': major
'@rocket.chat/meteor': major
---

Removes deprecated endpoint `pw.getPolicyReset`. Moving forward, use the `pw.getPolicy` endpoint.
31 changes: 0 additions & 31 deletions apps/meteor/app/api/server/v1/misc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import {
isMethodCallAnonProps,
isFingerprintProps,
isMeteorCall,
validateParamsPwGetPolicyRest,
} from '@rocket.chat/rest-typings';
import { escapeHTML } from '@rocket.chat/string-helpers';
import EJSON from 'ejson';
Expand Down Expand Up @@ -408,36 +407,6 @@ API.v1.addRoute(
},
);

API.v1.addRoute(
'pw.getPolicyReset',
{
authRequired: false,
validateParams: validateParamsPwGetPolicyRest,
deprecation: {
version: '7.0.0',
alternatives: ['pw.getPolicy'],
},
},
{
async get() {
check(
this.queryParams,
Match.ObjectIncluding({
token: String,
}),
);
const { token } = this.queryParams;

const user = await Users.findOneByResetToken(token, { projection: { _id: 1 } });
if (!user) {
return API.v1.unauthorized();
}

return API.v1.success(passwordPolicy.getPasswordPolicy());
},
},
);

/**
* @openapi
* /api/v1/stdout.queue:
Expand Down
43 changes: 0 additions & 43 deletions apps/meteor/tests/end-to-end/api/miscellaneous.ts
Original file line number Diff line number Diff line change
Expand Up @@ -662,49 +662,6 @@ describe('miscellaneous', () => {
});
});

describe('/pw.getPolicyReset', () => {
it('should fail if no token provided', (done) => {
void request
.get(api('pw.getPolicyReset'))
.expect('Content-Type', 'application/json')
.expect(400)
.expect((res) => {
expect(res.body).to.have.property('success', false);
expect(res.body).to.have.property('errorType', 'invalid-params');
})
.end(done);
});

it('should fail if no token is invalid format', (done) => {
void request
.get(api('pw.getPolicyReset'))
.query({ token: '123' })
.expect('Content-Type', 'application/json')
.expect(403)
.expect((res) => {
expect(res.body).to.have.property('success', false);
expect(res.body).to.have.property('error', 'unauthorized');
})
.end(done);
});

// not sure we have a way to get the reset token, looks like it is only sent via email by Meteor
it.skip('should return policies if correct token is provided', (done) => {
void request
.get(api('pw.getPolicyReset'))
.query({ token: '' })
.set(credentials)
.expect('Content-Type', 'application/json')
.expect(403)
.expect((res) => {
expect(res.body).to.have.property('success', true);
expect(res.body).to.have.property('enabled');
expect(res.body).to.have.property('policy').and.to.be.an('array');
})
.end(done);
});
});

describe('[/stdout.queue]', () => {
let testUser: TestUser<IUser>;
let testUsername: string;
Expand Down
22 changes: 0 additions & 22 deletions packages/rest-typings/src/v1/misc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -180,21 +180,6 @@ const FingerprintSchema = {

export const isFingerprintProps = ajv.compile<Fingerprint>(FingerprintSchema);

type PwGetPolicyReset = { token: string };

const PwGetPolicyResetSchema = {
type: 'object',
properties: {
token: {
type: 'string',
},
},
required: ['token'],
additionalProperties: false,
};

export const validateParamsPwGetPolicyRest = ajv.compile<PwGetPolicyReset>(PwGetPolicyResetSchema);

export type MiscEndpoints = {
'/v1/stdout.queue': {
GET: () => {
Expand Down Expand Up @@ -226,13 +211,6 @@ export type MiscEndpoints = {
};
};

'/v1/pw.getPolicyReset': {
GET: (params: PwGetPolicyReset) => {
enabled: boolean;
policy: [name: string, options?: Record<string, unknown>][];
};
};

'/v1/method.call/:method': {
POST: (params: { message: string }) => {
message: string;
Expand Down

0 comments on commit 4320db6

Please sign in to comment.