diff --git a/app/controllers/api/v2/base_controller.rb b/app/controllers/api/v0/base_controller.rb similarity index 60% rename from app/controllers/api/v2/base_controller.rb rename to app/controllers/api/v0/base_controller.rb index a9d85bcc4208f0a10a6b45aba8c796ce04c4a448..0899a13a80154a87a0fd13a61ae491334c6fd112 100644 --- a/app/controllers/api/v2/base_controller.rb +++ b/app/controllers/api/v0/base_controller.rb @@ -1,4 +1,4 @@ -class Api::V2::BaseController < ApplicationController +class Api::V0::BaseController < ApplicationController include OpenidConnect::Authentication before_filter :require_access_token diff --git a/app/controllers/api/v2/users_controller.rb b/app/controllers/api/v0/users_controller.rb similarity index 66% rename from app/controllers/api/v2/users_controller.rb rename to app/controllers/api/v0/users_controller.rb index 7f8ea55b7f137f4ff7d670feb74818c1789dfcc8..e57c7cd23c14824b20f73e15e7d170d657ca1952 100644 --- a/app/controllers/api/v2/users_controller.rb +++ b/app/controllers/api/v0/users_controller.rb @@ -1,4 +1,4 @@ -class Api::V2::UsersController < Api::V2::BaseController +class Api::V0::UsersController < Api::V0::BaseController def show render json: user diff --git a/app/presenters/api/v0/base_presenter.rb b/app/presenters/api/v0/base_presenter.rb new file mode 100644 index 0000000000000000000000000000000000000000..b425b1440e2a210992c0f5aac44cf4c3813c54aa --- /dev/null +++ b/app/presenters/api/v0/base_presenter.rb @@ -0,0 +1,2 @@ +class Api::V0::BasePresenter +end diff --git a/app/presenters/api/v2/base_presenter.rb b/app/presenters/api/v2/base_presenter.rb deleted file mode 100644 index 2afabc56a5bd59856dac63b39ec25944d479ddb9..0000000000000000000000000000000000000000 --- a/app/presenters/api/v2/base_presenter.rb +++ /dev/null @@ -1,2 +0,0 @@ -class Api::V2::BasePresenter -end diff --git a/config/routes.rb b/config/routes.rb index 02d62211fc2f1579d69010483d38385c2c6ec97a..58c7d7445578dbe8635b6b247b31dc71bfa5def0 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -198,15 +198,7 @@ Diaspora::Application.routes.draw do end end - scope 'api/v0', :controller => :apis do - get :me - end - namespace :api do - namespace :v0 do - get "/users/:username" => 'users#show', :as => 'user' - get "/tags/:name" => 'tags#show', :as => 'tag' - end namespace :v1 do resources :tokens, :only => [:create, :destroy] end @@ -249,7 +241,7 @@ Diaspora::Application.routes.draw do post 'access_tokens', to: proc { |env| OpenidConnect::TokenEndpoint.new.call(env) } end - api_version(:module => "Api::V2", path: {value: "api/v2"}, default: true) do + api_version(module: "Api::V0", path: {value: "api/v0"}, default: true) do match 'user', to: 'users#show', via: :get end end diff --git a/features/step_definitions/openid_steps.rb b/features/step_definitions/openid_steps.rb index ef1974da899fc5d06d00cbca586e72d35501dc79..47fada788796f7b549657b4e2536ec59490707c0 100644 --- a/features/step_definitions/openid_steps.rb +++ b/features/step_definitions/openid_steps.rb @@ -10,13 +10,13 @@ end When /^I use received valid bearer tokens to access user info via URI query parameter$/ do accessTokenJson = JSON.parse(last_response.body) - userInfoEndPointURL = "/api/v2/user/" + userInfoEndPointURL = "/api/v0/user/" userInfoEndPointURLQuery = "?access_token=" + accessTokenJson["access_token"] visit userInfoEndPointURL + userInfoEndPointURLQuery end When /^I use invalid bearer tokens to access user info via URI query parameter$/ do - userInfoEndPointURL = "/api/v2/user/" + userInfoEndPointURL = "/api/v0/user/" userInfoEndPointURLQuery = "?access_token=" + SecureRandom.hex(32) visit userInfoEndPointURL + userInfoEndPointURLQuery end diff --git a/public/docs/v2/index.html b/public/docs/v0/index.html similarity index 79% rename from public/docs/v2/index.html rename to public/docs/v0/index.html index 518259ab3167c0c7a1e40d8927fea319f384b947..08b6b913fe21af665be76a2acb1f4046dda3f1fa 100644 --- a/public/docs/v2/index.html +++ b/public/docs/v0/index.html @@ -1,7 +1,7 @@ <!DOCTYPE html> <html lang="en-US"> <head> - <title>Documentation for v2</title> + <title>Documentation for v0</title> <link href="v2/style.css" media="screen" rel="stylesheet" type="text/css"> </head> <body> @@ -10,7 +10,7 @@ <h3>API Operations</h3> </div> <div id="content"> - <h1>Documentation for v2</h1> + <h1>Documentation for v0</h1> </div> </div> </body> diff --git a/public/docs/v2/style.css b/public/docs/v0/style.css similarity index 100% rename from public/docs/v2/style.css rename to public/docs/v0/style.css diff --git a/spec/controllers/api/v0/base_controller_spec.rb b/spec/controllers/api/v0/base_controller_spec.rb new file mode 100644 index 0000000000000000000000000000000000000000..f637d15b8d691419baebf5525e4b4411cd330217 --- /dev/null +++ b/spec/controllers/api/v0/base_controller_spec.rb @@ -0,0 +1,5 @@ +require 'spec_helper' + +describe Api::V0::BaseController do + +end diff --git a/spec/controllers/api/v2/users_controller_spec.rb b/spec/controllers/api/v0/users_controller_spec.rb similarity index 86% rename from spec/controllers/api/v2/users_controller_spec.rb rename to spec/controllers/api/v0/users_controller_spec.rb index fd2230962870141c8dab936bb0f31b999d1ac4d0..83d7128d2e3a615b87a8dbcff0cc9504d6274d68 100644 --- a/spec/controllers/api/v2/users_controller_spec.rb +++ b/spec/controllers/api/v0/users_controller_spec.rb @@ -2,14 +2,14 @@ require 'spec_helper' # TODO: Confirm that the cache-control header in the response is private as according to RFC 6750 # TODO: Check for WWW-Authenticate response header field as according to RFC 6750 -describe Api::V2::UsersController, type: :request do +describe Api::V0::UsersController, type: :request do describe "#show" do let!(:application) { bob.o_auth_applications.create!(client_id: 1, client_secret: "secret") } let!(:token) { application.tokens.create!.bearer_token.to_s } context "when valid" do it "shows the user's info" do - get "/api/v2/user/?access_token=" + token + get "/api/v0/user/?access_token=" + token jsonBody = JSON.parse(response.body) expect(jsonBody["username"]).to eq(bob.username) expect(jsonBody["email"]).to eq(bob.email) diff --git a/spec/controllers/api/v2/base_controller_spec.rb b/spec/controllers/api/v2/base_controller_spec.rb deleted file mode 100644 index 221629acb8f7983116c65ad2272ea35171a001fa..0000000000000000000000000000000000000000 --- a/spec/controllers/api/v2/base_controller_spec.rb +++ /dev/null @@ -1,5 +0,0 @@ -require 'spec_helper' - -describe Api::V2::BaseController do - -end diff --git a/spec/presenters/api/v0/base_presenter_spec.rb b/spec/presenters/api/v0/base_presenter_spec.rb new file mode 100644 index 0000000000000000000000000000000000000000..36d38fbe75150e9475d5a551bec521e164d05321 --- /dev/null +++ b/spec/presenters/api/v0/base_presenter_spec.rb @@ -0,0 +1,5 @@ +require 'spec_helper' + +describe Api::V0::BasePresenter do + +end diff --git a/spec/presenters/api/v2/base_presenter_spec.rb b/spec/presenters/api/v2/base_presenter_spec.rb deleted file mode 100644 index f9ab6b5dfcf3d8cc781a5fdffbb0c12bcd1716c6..0000000000000000000000000000000000000000 --- a/spec/presenters/api/v2/base_presenter_spec.rb +++ /dev/null @@ -1,5 +0,0 @@ -require 'spec_helper' - -describe Api::V2::BasePresenter do - -end diff --git a/spec/requests/api/v2/base_controller_spec.rb b/spec/requests/api/v2/base_controller_spec.rb index 221629acb8f7983116c65ad2272ea35171a001fa..f637d15b8d691419baebf5525e4b4411cd330217 100644 --- a/spec/requests/api/v2/base_controller_spec.rb +++ b/spec/requests/api/v2/base_controller_spec.rb @@ -1,5 +1,5 @@ require 'spec_helper' -describe Api::V2::BaseController do +describe Api::V0::BaseController do end