Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore!: remove deprecated endpoint pw.getPolicyReset #33474

Open
wants to merge 1 commit into
base: release-7.0.0
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
---

Removed 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
Loading