Skip to content

Commit 1b8f5bd

Browse files
authored
fix: removed auth on organization api (#395)
1 parent 333f5e3 commit 1b8f5bd

5 files changed

Lines changed: 7 additions & 35 deletions

File tree

src/actions/organization/create.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,6 @@ async function createOrganizationAction({ params, locals }) {
107107
};
108108
}
109109

110-
createOrganizationAction.auth = 'bearer';
111110
createOrganizationAction.transports = [ActionTransport.amqp, ActionTransport.internal];
112111
createOrganizationAction.allowed = async function checkOrganizationExistsConflict(request) {
113112
const { name } = request.params;

src/actions/organization/delete.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,6 @@ async function deleteOrganization({ params }) {
4949
return pipeline.exec().then(handlePipeline);
5050
}
5151

52-
deleteOrganization.auth = 'bearer';
5352
deleteOrganization.allowed = checkOrganizationExists;
5453
deleteOrganization.transports = [ActionTransport.amqp, ActionTransport.internal];
5554
module.exports = deleteOrganization;

test/helpers/organization.js

Lines changed: 1 addition & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
1-
const Promise = require('bluebird');
21
const faker = require('faker');
32
const times = require('lodash/times');
43
const { inspectPromise } = require('@makeomatic/deploy');
5-
const jwt = require('../../src/utils/jwt');
64

75
async function createMembers(totalUsers = 1) {
86
this.userNames = [];
@@ -23,29 +21,6 @@ exports.createOrganization = async function (customOpts = {}, totalUsers = 1) {
2321
await createMembers.call(this, totalUsers);
2422
}
2523

26-
await this.users.dispatch('register', {
27-
params: {
28-
username: 'v@makeomatic.ru',
29-
password: '123456',
30-
audience: 'test',
31-
metadata: {
32-
fine: true,
33-
},
34-
},
35-
}).catch(() => null);
36-
37-
const [bearer] = await Promise.all([
38-
this.users.dispatch('token.create', {
39-
params: {
40-
username: 'v@makeomatic.ru',
41-
name: 'sample',
42-
},
43-
}),
44-
jwt.login.call(this.users, 'v@makeomatic.ru', 'test'),
45-
]);
46-
47-
this.bearerAuthHeaders = { authorization: `Bearer ${bearer}` };
48-
4924
const params = {
5025
name: faker.company.companyName(),
5126
metadata: {
@@ -55,8 +30,7 @@ exports.createOrganization = async function (customOpts = {}, totalUsers = 1) {
5530
members: this.userNames.slice(0, totalUsers),
5631
...customOpts,
5732
};
58-
const organization = await this.users
59-
.dispatch('organization.create', { params, headers: this.bearerAuthHeaders })
33+
const organization = await this.dispatch('users.organization.create', params)
6034
.reflect()
6135
.then(inspectPromise(true));
6236

test/suites/organization/create.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ describe('#create organization', function registerSuite() {
1212
afterEach(global.clearRedis);
1313

1414
it('must reject invalid organization params and return detailed error', function test() {
15-
return this.users.dispatch('organization.create', { headers: this.bearerAuthHeaders })
15+
return this.dispatch('users.organization.create', {})
1616
.reflect()
1717
.then(inspectPromise(false))
1818
.then((response) => {
@@ -30,7 +30,7 @@ describe('#create organization', function registerSuite() {
3030
members: this.userNames.slice(0, 2),
3131
};
3232

33-
return this.users.dispatch('organization.create', { params, headers: this.bearerAuthHeaders })
33+
return this.dispatch('users.organization.create', params)
3434
.reflect()
3535
.then(inspectPromise(true))
3636
.then((response) => {
@@ -48,7 +48,7 @@ describe('#create organization', function registerSuite() {
4848
name: this.organization.name,
4949
};
5050

51-
return this.users.dispatch('organization.create', { params, headers: this.bearerAuthHeaders })
51+
return this.dispatch('users.organization.create', params)
5252
.reflect()
5353
.then(inspectPromise(false))
5454
.then((response) => {

test/suites/organization/delete.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ describe('#delete organization', function registerSuite() {
1212
afterEach(global.clearRedis);
1313

1414
it('must reject invalid organization params and return detailed error', function test() {
15-
return this.users.dispatch('organization.delete', { headers: this.bearerAuthHeaders })
15+
return this.dispatch('users.organization.delete', {})
1616
.reflect()
1717
.then(inspectPromise(false))
1818
.then((response) => {
@@ -25,7 +25,7 @@ describe('#delete organization', function registerSuite() {
2525
const params = {
2626
organizationId: this.organization.id,
2727
};
28-
return this.users.dispatch('organization.delete', { params, headers: this.bearerAuthHeaders })
28+
return this.dispatch('users.organization.delete', params)
2929
.reflect()
3030
.then(inspectPromise());
3131
});
@@ -35,7 +35,7 @@ describe('#delete organization', function registerSuite() {
3535
organizationId: faker.company.companyName(),
3636
};
3737

38-
return this.users.dispatch('organization.delete', { params, headers: this.bearerAuthHeaders })
38+
return this.dispatch('users.organization.delete', params)
3939
.reflect()
4040
.then(inspectPromise(false))
4141
.then((response) => {

0 commit comments

Comments
 (0)