Coder Social home page Coder Social logo

0xnf / mockify Goto Github PK

View Code? Open in Web Editor NEW
1.0 3.0 0.0 7.18 MB

A replica Spotify server complete with OAuth that allows offline testing of applications using the Spotify Web API

License: MIT License

C# 46.58% CSS 53.42% JavaScript 0.01%
spotify-api oauth2-server oauth-server mock-data efcore aspnet-core dotnetcore

mockify's Introduction

Mockify - A Replica Spotify Server

Feature Completeness: 50%. Do not attempt to use yet.

Mockify attempts to be a drop-in replacement for any applications that want to test their compliance, performance, and resilience against the Spotify Web API. Features include:

  1. Self hosted and totally offline1
  2. Full Spotify API parity (as of March 14 2018)2
  3. Full Spotify Object Model parity
  4. No worrying about Spotify rate limits while testing
  5. Ability to control server side errors
  6. Ability to test against token revoke and rate limiting

Mockify allows you to create users and OAuth Applications, and also models Spotify's OAuth2 log in process, allowing all 3 supported authentication flows.

Each Spotify endpoint is present and returns the same type of data the live web API would return. Paging objects, album objects, playlist objects, everything behaves as expected.

Most importantly, Mockify allows you to issue server-side errors, such as 502, 503, timeouts, and rate limiting, allowing you to test your application's resilience without trying to compel that behavior from Spotify itself.

Mockify is a .NET Core 2.0 application, and launches a webserver at https://localhost:44345. Mockify requires you to accept a temporary https certificate. If you do not wish to accept this certificate, then you cannot currently use Mockify. A non-https version is not currently planned.

Presently, subdomains are not supported.
For https://accounts.spotify.com/authorize/ requests, the Mockify counterpart is https://localhost:44345/authorize/
For https://api.spotify.com/v1/ requests, the Mockify counterpart is https://localhost:44345/api/v1/

Otherwise the url scheme is the same. For instance, To request an album, instead of hitting https://api.spotify.com/v1/albums/{id}, you hit https://localhost:44345/api/v1/albums/{id}

Implementation Todo List

Although this is currently in working order as a starting point for anyone attempting to set up an OpenIdConnectServer OAuth2 Server, its ability to serve as a Spotify integration test suite is not yet implemented. What follows is what is left to do before it can be used fully:

  • Collect dummy Spotify data for each endpoint
  • Create unit tests
  • api.localhost and accounts.localhost subdomains
  • More thorough administrative control panels
  • Rate limiting is not active
  • Server Response Modes are not active
  • CLI methods for adjusting rate limits and response modes

Building

Mockify depends on .NET Core 2.0.
Please see Microsoft's download and installation instructions here before proceeding.

$ git pull https://github.com/0xnf/mockify.git
$ cd mockify
$ dotnet build
$ dotnet ef database update

Development Notes

If you make changes to the Database Context (MockifyDbContext.cs), please be sure to delete the following files:

  • Mockify\Mockify\Data\2018030218752_n3.cs (Delete whatever matches the pattern. the actual file name is a generated timestamp and will differ for you upon each build)
  • Mockify\Mockify\Data\MockifyDbContextModelSnapshot.cs
  • Mockify\Mockify\Mockify.db

SQLite does not presently support a number of EF Core migration options, meaning that any migrations must be generated from scratch, thus necessitating the deletion of all the above files, including the Database itself.

Footnotes

offline caveat

If you decide to use the Facebook authentication flow for a user, you will need to allow Mockify access to the external internet.

parity caveat

Endpoints regarding web-playback, connected devices, and random seeding for playlists are not in the scope of this project

mockify's People

Stargazers

 avatar

Watchers

 avatar  avatar  avatar

mockify's Issues

Add Facebook authentication

Because Spotify has it.

n.b., this will require Mockify to be temporarily Online while it requests access tokens.

Better administrative panels

  • Rate Limits should be able to be reset from the control panels
  • Registered Application details page should look more like Spotify's Dev Dashboard

Server Responde Modes are NYI

None of the endpoints presently checks the response mode setting. Need to create a catchall method that initiates before any call goes to any specific controller and return the appropriate error.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.