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

Make all calls to the db from the api direct and synchronous #704

Merged
merged 1 commit into from Oct 4, 2018

Conversation

Projects
None yet
3 participants
@elliott-davis
Member

elliott-davis commented Oct 4, 2018

Signed-off-by: Elliott Davis elliott@excellent.io

Elliott Davis
Make all calls to the db from the api direct and synchronous
Signed-off-by: Elliott Davis <elliott@excellent.io>
@thesentinels

This comment has been minimized.

Show comment
Hide comment
@thesentinels

thesentinels Oct 4, 2018

Contributor

Thanks for the pull request! Here is what will happen next:

  1. Your PR will be reviewed by the maintainers
  2. If everything looks good, one of them will approve it, and your PR will be merged.

Thank you for contributing!

Contributor

thesentinels commented Oct 4, 2018

Thanks for the pull request! Here is what will happen next:

  1. Your PR will be reviewed by the maintainers
  2. If everything looks good, one of them will approve it, and your PR will be merged.

Thank you for contributing!

@eeyun

eeyun approved these changes Oct 4, 2018

@elliott-davis

This comment has been minimized.

Show comment
Hide comment
@elliott-davis

elliott-davis Oct 4, 2018

Member

> hab-api-tests@0.0.1 mocha /src/test/builder-api
> mocha --require src/helpers --reporter spec src/api.js



  Origin API
    Create neurosis origin
      ✓ requires authentication
      ✓ returns the created origin (94ms)
    Get origin neurosis
      ✓ returns the origin
    Create xmen origin
      ✓ returns the created origin (43ms)
    Updating origins
      ✓ requires authentication
      ✓ requires that you are a member of the origin being updated
      ✓ succeeds
      ✓ reflects the changes when viewing it again
    Origin secret creation
      ✓ requires authentication
    Origin secret list
      ✓ requires authentication
      ✓ succeeds
    Origin secret deletion
      ✓ requires authentication

  Authenticate API
    Create sessions
      ✓ returns bobo
      ✓ returns mystique

  Origin Invitations API
    Invite bobo to xmen
      ✓ requires authentication
      ✓ refuses invitations from non-members
      ✓ returns the invitation
      ✓ shows bobo in the origins list of invitations
      ✓ shows xmen in bobos list of invitations
    Bobo accepts the invitation to the xmen
      ✓ requires authentication to accept the invitation
      ✓ accepts the invitation
      ✓ does not show bobo in the origins list of invitations
      ✓ does not show xmen in bobos list of invitations
      ✓ shows xmen in bobos origins

  Related Origin API functions
    Retrieving origin users
      ✓ requires authentication
      ✓ requires that you are a member of the origin
      ✓ returns the list of users
    Removing a member from an origin
      ✓ requires authentication
      ✓ requires that you are the owner of the origin
      ✓ succeeds
      ✓ no longer shows the removed user as part of the origin

  Working with packages
    Uploading packages
      ✓ does not allow unauthenticated users to upload packages
      ✓ requires that you are a member of the origin to upload a package
      ✓ allows authenticated users to upload packages (87ms)
      ✓ uploads a second package (69ms)
      ✓ uploads a third package (63ms)
      ✓ uploads a fourth package (64ms)
    Finding packages
      ✓ allows me to search for packages
      ✓ lists all packages
      ✓ lists all unique package names
      ✓ lists all packages with the specified name
      ✓ lists all versions of the package with the specified name
      ✓ returns the latest release of a package with the specified name
      ✓ lists all packages with the specified name and version
      ✓ returns the latest release of a package with the spcified name and version
      ✓ returns the specified release
    Other functions
      ✓ lists all the channels a package is in
      ✓ downloads a package
      ✓ toggles the privacy setting for a package
      ✓ requires authentication to view private packages
      ✓ does not let members of other origins view private packages
      ✓ allows members of the origin to view private packages when they are authenticated
      ✓ returns package stats

  Channels API
    Create foo channel
      ✓ requires authentication to create a channel
      ✓ returns the created channel
    Duplicate channel
      ✓ returns conflict on channel create
    Create bar channel
      ✓ succeeds
    Channel promotion
      ✓ requires authentication to promote a package
      ✓ requires origin membership to promote a package
      ✓ puts the specified package into the specified channel
      ✓ can promote private packages
    Listing packages in a channel
      ✓ returns all packages in a channel
      ✓ returns all packages with the given name in a channel
      ✓ returns all packages with the given name and version in a channel
      ✓ returns the package with the given name, version and release in a channel (307ms)
      ✓ returns the latest package with the given name in a channel (246ms)
      ✓ returns the latest package with the given name and version in a channel (255ms)
      ✓ requires authentication to view private packages in a channel (159ms)
      ✓ does not let members of other origins view private packages in a channel (118ms)
      ✓ allows members of the origin to view private packages when they are authenticated (255ms)
    Listing channels in an origin
      ✓ returns a list of channels
    Channel demotion
      ✓ requires authentication to demote a package
      ✓ requires origin membership to demote a package
      ✓ removes the specified package from the specified channel (38ms)
      ✓ rejects attempts to demote a package from the unstable channel
      ✓ will not find a package in a channel after it has been demoted
    Delete foo channel
      ✓ rejects attempts to delete the stable channel
      ✓ rejects attempts to delete the unstable channel
      ✓ requires authentication to delete a channel
      ✓ requires origin membership to delete a channel
      ✓ succeeds

  Keys API
    Uploading public keys
      ✓ requires authentication
      ✓ requires membership in the origin you are uploading to
      ✓ uploads the key
    Downloading public keys
      ✓ can download a specific revision
      ✓ can download the latest key
    Uploading secret keys
      ✓ requires authentication
      ✓ requires membership in the origin you are uploading to
      ✓ uploads the key
    Downloading secret keys
      ✓ requires authentication
      ✓ requires membership in the origin you are uploading to
      ✓ can download the latest key
    Generating keys
      ✓ requires authentication
      ✓ requires membership in the origin you are uploading to
      ✓ generates the key
    Listing keys
      ✓ can list all public keys

  Integrations API
    Creating an origin integration
      ✓ requires authentication
      ✓ requires membership in the given origin
      ✓ succeeds
    Retrieving all integrations for an origin
      ✓ requires authentication
      ✓ requires membership in the given origin
      ✓ succeeds
    Retrieving all names for a specific integration
      ✓ requires authentication
      ✓ requires membership in the given origin
      ✓ succeeds
    Removing an integration
      ✓ requires authentication
      ✓ requires membership in the given origin
      ✓ succeeds
      ✓ creates another integration so that future tests will pass

  Profile API
    Updating the profile
      ✓ requires authentication
      ✓ allows someone to update their profile
    Retrieving a profile
      ✓ requires authentication
      ✓ allows someone to retrieve their profile

  Projects API
    Creating a project
      ✓ requires authentication
      ✓ requires membership in the origin that the project refers to
      ✓ requires a properly formatted payload
      ✓ succeeds
    Retrieving a project
      ✓ requires authentication
      ✓ requires membership in the origin that the project refers to
      ✓ succeeds
    Listing all projects in an origin
      ✓ requires authentication
      ✓ requires membership in the origin that the project refers to
      ✓ succeeds
    Editing a project
      ✓ requires authentication
      ✓ requires membership in the origin that the project refers to
      ✓ requires a properly formatted payload
      ✓ succeeds
      ✓ reflects the new changes when viewing it again
    Toggling the privacy of a project
      ✓ requires authentication
      ✓ requires membership in the origin that the project refers to
      ✓ requires that you set it to a known visibility setting
      ✓ does not allow you to set hidden manually
      ✓ succeeds
    Deleting a project
      ✓ requires authentication
      ✓ requires membership in the origin that the project refers to
      ✓ succeeds
      ✓ creates another project so that other tests dont fail

  Project integrations API
    Creating a project integration
      ✓ requires authentication
      ✓ requires membership in the origin that the project refers to
      ✓ requires a JSON body
      ✓ succeeds
    Retrieving a project integration
      ✓ requires authentication
      ✓ requires membership in the origin that the project refers to
      ✓ succeeds
    Deleting a project integration
      ✓ requires authentication
      ✓ requires membership in the origin that the project refers to
      ✓ succeeds

  Jobs API
    Scheduling jobs
      ✓ requires authentication
      ✓ requires that you belong to the origin
      ✓ does not schedule a build for Windows
      ✓ does not schedule a build for Linux kernel2
      ✓ returns the group (636ms)
    Retrieving information about a job group
      ✓ requires a group id that is a u64
      ✓ return the group
    Retrieving information about every job group in an origin
      ✓ returns all of the groups
    Listing all jobs for a project
      ✓ requires authentication
      ✓ requires membership in the origin that the project refers to
      ✓ succeeds
    Getting details of a job
      ✓ requires authentication
      ✓ requires you are a member of the origin that the job belongs to
      ✓ requires a job id that is a u64
      ✓ succeeds
    Getting logs of a job
      - requires authentication
      - requires you are logged in
      - requires a job id that is a u64
      - succeeds
      private projects
        - sets the project to private first
        - requires you are a member of the origin that the job belongs to when viewing logs for a private project
        - shows the logs for a private project
        - set the project back to public
    Promoting a job group
      ✓ requires authentication
      - requires you are a member of the origin that the job group belongs to
    Demoting a job group
      ✓ requires authentication
    Canceling a job group
      ✓ requires authentication
      ✓ requires you are a member of the origin that the job group belongs to
      ✓ cancels the group (44ms)

  External API
    Getting the external repo content
      ✓ requires authentication
      - succeeds
    Validate credentials in an external registry
      ✓ requires authentication
      - succeeds

  Miscellanenous API
    Retrieving the API status
      ✓ succeeds
    Receiving a GitHub webhook
      - succeeds
    Retrieving reverse dependencies
      ✓ returns all reverse dependencies for an origin and package name


  171 passing (4s)
  12 pending
Member

elliott-davis commented Oct 4, 2018


> hab-api-tests@0.0.1 mocha /src/test/builder-api
> mocha --require src/helpers --reporter spec src/api.js



  Origin API
    Create neurosis origin
      ✓ requires authentication
      ✓ returns the created origin (94ms)
    Get origin neurosis
      ✓ returns the origin
    Create xmen origin
      ✓ returns the created origin (43ms)
    Updating origins
      ✓ requires authentication
      ✓ requires that you are a member of the origin being updated
      ✓ succeeds
      ✓ reflects the changes when viewing it again
    Origin secret creation
      ✓ requires authentication
    Origin secret list
      ✓ requires authentication
      ✓ succeeds
    Origin secret deletion
      ✓ requires authentication

  Authenticate API
    Create sessions
      ✓ returns bobo
      ✓ returns mystique

  Origin Invitations API
    Invite bobo to xmen
      ✓ requires authentication
      ✓ refuses invitations from non-members
      ✓ returns the invitation
      ✓ shows bobo in the origins list of invitations
      ✓ shows xmen in bobos list of invitations
    Bobo accepts the invitation to the xmen
      ✓ requires authentication to accept the invitation
      ✓ accepts the invitation
      ✓ does not show bobo in the origins list of invitations
      ✓ does not show xmen in bobos list of invitations
      ✓ shows xmen in bobos origins

  Related Origin API functions
    Retrieving origin users
      ✓ requires authentication
      ✓ requires that you are a member of the origin
      ✓ returns the list of users
    Removing a member from an origin
      ✓ requires authentication
      ✓ requires that you are the owner of the origin
      ✓ succeeds
      ✓ no longer shows the removed user as part of the origin

  Working with packages
    Uploading packages
      ✓ does not allow unauthenticated users to upload packages
      ✓ requires that you are a member of the origin to upload a package
      ✓ allows authenticated users to upload packages (87ms)
      ✓ uploads a second package (69ms)
      ✓ uploads a third package (63ms)
      ✓ uploads a fourth package (64ms)
    Finding packages
      ✓ allows me to search for packages
      ✓ lists all packages
      ✓ lists all unique package names
      ✓ lists all packages with the specified name
      ✓ lists all versions of the package with the specified name
      ✓ returns the latest release of a package with the specified name
      ✓ lists all packages with the specified name and version
      ✓ returns the latest release of a package with the spcified name and version
      ✓ returns the specified release
    Other functions
      ✓ lists all the channels a package is in
      ✓ downloads a package
      ✓ toggles the privacy setting for a package
      ✓ requires authentication to view private packages
      ✓ does not let members of other origins view private packages
      ✓ allows members of the origin to view private packages when they are authenticated
      ✓ returns package stats

  Channels API
    Create foo channel
      ✓ requires authentication to create a channel
      ✓ returns the created channel
    Duplicate channel
      ✓ returns conflict on channel create
    Create bar channel
      ✓ succeeds
    Channel promotion
      ✓ requires authentication to promote a package
      ✓ requires origin membership to promote a package
      ✓ puts the specified package into the specified channel
      ✓ can promote private packages
    Listing packages in a channel
      ✓ returns all packages in a channel
      ✓ returns all packages with the given name in a channel
      ✓ returns all packages with the given name and version in a channel
      ✓ returns the package with the given name, version and release in a channel (307ms)
      ✓ returns the latest package with the given name in a channel (246ms)
      ✓ returns the latest package with the given name and version in a channel (255ms)
      ✓ requires authentication to view private packages in a channel (159ms)
      ✓ does not let members of other origins view private packages in a channel (118ms)
      ✓ allows members of the origin to view private packages when they are authenticated (255ms)
    Listing channels in an origin
      ✓ returns a list of channels
    Channel demotion
      ✓ requires authentication to demote a package
      ✓ requires origin membership to demote a package
      ✓ removes the specified package from the specified channel (38ms)
      ✓ rejects attempts to demote a package from the unstable channel
      ✓ will not find a package in a channel after it has been demoted
    Delete foo channel
      ✓ rejects attempts to delete the stable channel
      ✓ rejects attempts to delete the unstable channel
      ✓ requires authentication to delete a channel
      ✓ requires origin membership to delete a channel
      ✓ succeeds

  Keys API
    Uploading public keys
      ✓ requires authentication
      ✓ requires membership in the origin you are uploading to
      ✓ uploads the key
    Downloading public keys
      ✓ can download a specific revision
      ✓ can download the latest key
    Uploading secret keys
      ✓ requires authentication
      ✓ requires membership in the origin you are uploading to
      ✓ uploads the key
    Downloading secret keys
      ✓ requires authentication
      ✓ requires membership in the origin you are uploading to
      ✓ can download the latest key
    Generating keys
      ✓ requires authentication
      ✓ requires membership in the origin you are uploading to
      ✓ generates the key
    Listing keys
      ✓ can list all public keys

  Integrations API
    Creating an origin integration
      ✓ requires authentication
      ✓ requires membership in the given origin
      ✓ succeeds
    Retrieving all integrations for an origin
      ✓ requires authentication
      ✓ requires membership in the given origin
      ✓ succeeds
    Retrieving all names for a specific integration
      ✓ requires authentication
      ✓ requires membership in the given origin
      ✓ succeeds
    Removing an integration
      ✓ requires authentication
      ✓ requires membership in the given origin
      ✓ succeeds
      ✓ creates another integration so that future tests will pass

  Profile API
    Updating the profile
      ✓ requires authentication
      ✓ allows someone to update their profile
    Retrieving a profile
      ✓ requires authentication
      ✓ allows someone to retrieve their profile

  Projects API
    Creating a project
      ✓ requires authentication
      ✓ requires membership in the origin that the project refers to
      ✓ requires a properly formatted payload
      ✓ succeeds
    Retrieving a project
      ✓ requires authentication
      ✓ requires membership in the origin that the project refers to
      ✓ succeeds
    Listing all projects in an origin
      ✓ requires authentication
      ✓ requires membership in the origin that the project refers to
      ✓ succeeds
    Editing a project
      ✓ requires authentication
      ✓ requires membership in the origin that the project refers to
      ✓ requires a properly formatted payload
      ✓ succeeds
      ✓ reflects the new changes when viewing it again
    Toggling the privacy of a project
      ✓ requires authentication
      ✓ requires membership in the origin that the project refers to
      ✓ requires that you set it to a known visibility setting
      ✓ does not allow you to set hidden manually
      ✓ succeeds
    Deleting a project
      ✓ requires authentication
      ✓ requires membership in the origin that the project refers to
      ✓ succeeds
      ✓ creates another project so that other tests dont fail

  Project integrations API
    Creating a project integration
      ✓ requires authentication
      ✓ requires membership in the origin that the project refers to
      ✓ requires a JSON body
      ✓ succeeds
    Retrieving a project integration
      ✓ requires authentication
      ✓ requires membership in the origin that the project refers to
      ✓ succeeds
    Deleting a project integration
      ✓ requires authentication
      ✓ requires membership in the origin that the project refers to
      ✓ succeeds

  Jobs API
    Scheduling jobs
      ✓ requires authentication
      ✓ requires that you belong to the origin
      ✓ does not schedule a build for Windows
      ✓ does not schedule a build for Linux kernel2
      ✓ returns the group (636ms)
    Retrieving information about a job group
      ✓ requires a group id that is a u64
      ✓ return the group
    Retrieving information about every job group in an origin
      ✓ returns all of the groups
    Listing all jobs for a project
      ✓ requires authentication
      ✓ requires membership in the origin that the project refers to
      ✓ succeeds
    Getting details of a job
      ✓ requires authentication
      ✓ requires you are a member of the origin that the job belongs to
      ✓ requires a job id that is a u64
      ✓ succeeds
    Getting logs of a job
      - requires authentication
      - requires you are logged in
      - requires a job id that is a u64
      - succeeds
      private projects
        - sets the project to private first
        - requires you are a member of the origin that the job belongs to when viewing logs for a private project
        - shows the logs for a private project
        - set the project back to public
    Promoting a job group
      ✓ requires authentication
      - requires you are a member of the origin that the job group belongs to
    Demoting a job group
      ✓ requires authentication
    Canceling a job group
      ✓ requires authentication
      ✓ requires you are a member of the origin that the job group belongs to
      ✓ cancels the group (44ms)

  External API
    Getting the external repo content
      ✓ requires authentication
      - succeeds
    Validate credentials in an external registry
      ✓ requires authentication
      - succeeds

  Miscellanenous API
    Retrieving the API status
      ✓ succeeds
    Receiving a GitHub webhook
      - succeeds
    Retrieving reverse dependencies
      ✓ returns all reverse dependencies for an origin and package name


  171 passing (4s)
  12 pending

@elliott-davis elliott-davis merged commit 23aa094 into master Oct 4, 2018

1 of 2 checks passed

continuous-integration/travis-ci/pr The Travis CI build failed
Details
DCO This commit has a DCO Signed-off-by line

@elliott-davis elliott-davis deleted the elliott/sync_db branch Oct 4, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment