Skip to content
This repository has been archived by the owner on Aug 19, 2022. It is now read-only.

Policy endpoints #518

Merged
merged 5 commits into from
Apr 11, 2018
Merged

Policy endpoints #518

merged 5 commits into from
Apr 11, 2018

Conversation

cianfoley-nearform
Copy link
Contributor

Hi @mihaidma

I've added the GET policy endpoints to users, teams and orgs, tests in place updated swagger etc.

#461

@ShogunPanda, one thing is confusing me in the hapi17 tests, I might be doing something silly but in org and user I have to check against result.data.data instead of result.data like in teams...

@dberesford

@coveralls
Copy link

coveralls commented Apr 10, 2018

Coverage Status

Coverage decreased (-0.08%) to 93.029% when pulling 184f11b on policy-endpoints into c1384c9 on master.

@ShogunPanda
Copy link
Contributor

@cianfoley-nearform

It's because in udaru-core the related methods are structured like this.

if (typeof cb !== 'function') [promise, cb] = asyncify('data', 'total')

// ...

callback(null, result) // Result is a object which contains the data property.

Now, asyncify will map callback arguments to the argument it received and therefore result.data.data.

Since your callback has a single argument you can follow one of these two solutions:

  1. (preferred): Drop arguments to asyncify.
  2. Change the callback invocation from
const result = {
  page: page,
  limit: pageSize,
  total: job.totalPoliciesCount,
  data: job.organization.policies
}

return cb(null, result)

to this:

if (typeof cb !== 'function') [promise, cb] = asyncify('data', 'total', 'page', 'limit')

// ...

return cb(null, job.organization.policies, job.totalPoliciesCount, page, pageSize)

Good luck! ^^

Copy link
Contributor

@ShogunPanda ShogunPanda left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In general it looks good to me.
Once you fix the misunderstading you requested information for, you're good to go!

@cianfoley-nearform
Copy link
Contributor Author

cianfoley-nearform commented Apr 10, 2018

@ShogunPanda, I completely blindspotted that... thanks!

Should we explicity handle errors e.g. 404 not found in hapi endpoints?

I'm just using await on the test if user/team exists, which will throw the error just wondering is that preferred approach or should it be in try catch?

@cianfoley-nearform
Copy link
Contributor Author

@ShogunPanda, core and tests updated there now... thanks again

Copy link
Contributor

@dberesford dberesford left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks @cianfoley-nearform

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants