-
Notifications
You must be signed in to change notification settings - Fork 133
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
Testing uppgrading branch #2861
base: upgrading
Are you sure you want to change the base?
Changes from all commits
7cb6737
b5b7379
c6bbf98
443df6d
2db1f9d
340976a
cf0fb9e
8cf1e67
237a5e8
360f8aa
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
FactoryGirl.define do | ||
factory :namespaces, class: Setup::Namespace do | ||
sequence(:name) { |n| "Namespace#{n}" } | ||
sequence(:slug) { |n| "slug#{n}" } | ||
end | ||
end |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
require 'rails_helper' | ||
RSpec.describe Api::V3::ApiController, type: :request do | ||
|
||
end |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
require 'rails_helper' | ||
RSpec.describe Api::V3::ApiController, type: :request do | ||
|
||
describe "POST /api/v3/setup/connection" do | ||
# Create an Connection | ||
it "With authorized token request" do | ||
request_data = {name: 'connection_test', url: "http://localhost:3002/cenit/test"} | ||
|
||
# The connection does not exists | ||
connection = Setup::Connection.where(name: request_data[:name]).first | ||
expect(connection).not_to be | ||
|
||
# Connection creation request success | ||
post '/api/v3/setup/connection', params: request_data, headers: headers_token_authorization[:header_token_create], as: :json | ||
expect(response).to have_http_status(:ok) | ||
end | ||
end | ||
|
||
describe "GET /api/v3/setup/connection/{id}" do | ||
# Retrieve an existing Connection | ||
it "Fail retrieve connection with bad id" do | ||
get "/api/v3/setup/connection/not_id", headers: header_token_authorization | ||
expect(response).to have_http_status(:not_found) | ||
expect(json_response[:status]).to eq("item not found") | ||
end | ||
|
||
it "Successful retrieve connection" do | ||
connection = FactoryGirl.create(:stores_connection) | ||
connection_id = connection.id | ||
|
||
get "/api/v3/setup/connection/#{connection_id}", headers: header_token_authorization | ||
expect(response).to have_http_status(:ok) | ||
expect(json_response).to include(:id, :name, :url) | ||
expect(json_response[:name]).to eq(connection.name) | ||
expect(json_response[:url]).to eq(connection.url) | ||
end | ||
end | ||
end | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. remove the last lines |
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
require 'rails_helper' | ||
RSpec.describe Api::V3::ApiController, type: :request do | ||
|
||
end |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
require 'rails_helper' | ||
RSpec.describe Api::V3::ApiController, type: :request do | ||
|
||
end |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
require 'rails_helper' | ||
RSpec.describe Api::V3::ApiController, type: :request do | ||
|
||
describe "POST /api/v3/setup/namespace" do | ||
# Create an Namespace | ||
it "With authorized token request" do | ||
request_data = {name: 'namespace_test', slug: "slug_test"} | ||
|
||
# The namespace does not exists | ||
namespace = Setup::Namespace.where(name: request_data[:name]).first | ||
expect(namespace).not_to be | ||
|
||
# Namespace creation request success | ||
post '/api/v3/setup/namespace', params: request_data, headers: headers_token_authorization[:header_token_create], as: :json | ||
expect(response).to have_http_status(:ok) | ||
end | ||
end | ||
|
||
describe "GET /api/v3/setup/namespace/{id}" do | ||
# Retrieve an existing Namespace | ||
it "Fail retrieve namespace with bad id" do | ||
get "/api/v3/setup/namespace/not_id", headers: header_token_authorization | ||
expect(response).to have_http_status(:not_found) | ||
expect(json_response[:status]).to eq("item not found") | ||
end | ||
|
||
it "Successful retrieve namespace" do | ||
namespace = FactoryGirl.create(:namespaces) | ||
namespace_id = namespace.id | ||
|
||
get "/api/v3/setup/namespace/#{namespace_id}", headers: header_token_authorization | ||
expect(response).to have_http_status(:ok) | ||
expect(json_response).to include(:id, :name, :slug) | ||
expect(json_response[:name]).to eq(namespace.name) | ||
expect(json_response[:slug]).to eq(namespace.slug) | ||
end | ||
end | ||
|
||
end | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
require 'rails_helper' | ||
RSpec.describe Api::V3::ApiController, type: :request do | ||
|
||
end | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. remove extra space |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
require 'rails_helper' | ||
RSpec.describe Api::V3::ApiController, type: :request do | ||
|
||
end |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
require 'rails_helper' | ||
RSpec.describe Api::V3::ApiController, type: :request do | ||
|
||
end |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
require 'rails_helper' | ||
RSpec.describe Api::V3::ApiController, type: :request do | ||
Setup::Models.all.each do |model| | ||
model_name_array = model.name.to_s.split('::') | ||
namespace = model_name_array.first.downcase | ||
underscore_model_name = model_name_array.last.underscore | ||
|
||
return if underscore_model_name === 'attachment' || | ||
underscore_model_name === 'message' || | ||
underscore_model_name === 'config' || | ||
underscore_model_name === 'code' || | ||
underscore_model_name === 'public_storage' || | ||
underscore_model_name === 'cross_shared_collection' | ||
|
||
if namespace == "setup" || namespace == "cenit" | ||
describe "GET /api/v3/#{namespace}/#{underscore_model_name}" do | ||
context "fail retrieve all existing #{underscore_model_name}" do | ||
it "with missing header request" do | ||
get "/api/v3/#{namespace}/#{underscore_model_name}" | ||
expect(response).to have_http_status(:forbidden) | ||
expect(json_response[:error]).to eq("insufficient_scope") | ||
expect(json_response[:error_description]).to eq("The requested action is out of the access token scope") | ||
end | ||
|
||
it "with unauthorized token request" do | ||
get "/api/v3/#{namespace}/#{underscore_model_name}", headers: { | ||
Authorization: "Bearer unauthorized_token }" | ||
} | ||
expect(response).to have_http_status(:unauthorized) | ||
expect(json_response[:error]).to eq("invalid_token") | ||
expect(json_response[:error_description]).to eq("Malformed authorization header") | ||
end | ||
end | ||
|
||
context "successful retrieve all existing #{underscore_model_name}" do | ||
it "with authorized token request" do | ||
get "/api/v3/#{namespace}/#{underscore_model_name}", headers: header_token_authorization | ||
expect(response).to have_http_status(:ok) | ||
expect(json_response[:count]).to be | ||
expect(json_response[:current_page]).to be | ||
expect(json_response[:data_type]).to be | ||
expect(json_response[:items]).to be | ||
expect(json_response[:total_pages]).to be | ||
end | ||
end | ||
end | ||
end | ||
end | ||
end | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. review in your editor and check if have an option to add empty line to a file |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
require 'rails_helper' | ||
RSpec.describe Api::V3::ApiController, type: :request do | ||
|
||
describe "GET /api/v3/setup/execution.json" do | ||
|
||
context "Fail retrieve all existing Executions" do | ||
it "with missing header request" do | ||
get '/api/v3/setup/execution.json' | ||
expect(response).to have_http_status(:forbidden) | ||
expect(json_response[:error]).to eq("insufficient_scope") | ||
expect(json_response[:error_description]).to eq("The requested action is out of the access token scope") | ||
end | ||
|
||
it "with unauthorized token request" do | ||
get '/api/v3/setup/execution.json', headers: { | ||
Authorization: "Bearer unauthorized_token }" | ||
} | ||
expect(response).to have_http_status(:unauthorized) | ||
expect(json_response[:error]).to eq("invalid_token") | ||
expect(json_response[:error_description]).to eq("Malformed authorization header") | ||
end | ||
end | ||
|
||
context "successful retrieve all existing Executions" do | ||
|
||
it "with authorized token request" do | ||
get '/api/v3/setup/execution.json', headers: header_token_authorization | ||
|
||
expect(response).to have_http_status(:ok) | ||
expect(json_response[:data_type]).to be | ||
expect(json_response[:items]).to be | ||
expect(json_response[:total_pages]).to be | ||
end | ||
|
||
end | ||
|
||
end | ||
end |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
require 'rails_helper' | ||
RSpec.describe Api::V3::ApiController, type: :request do | ||
|
||
describe "GET /api/v3/setup/storage.json" do | ||
|
||
context "Fail retrieve all existing Storages" do | ||
it "with missing header request" do | ||
get '/api/v3/setup/storage.json' | ||
expect(response).to have_http_status(:forbidden) | ||
expect(json_response[:error]).to eq("insufficient_scope") | ||
expect(json_response[:error_description]).to eq("The requested action is out of the access token scope") | ||
end | ||
|
||
it "with unauthorized token request" do | ||
get '/api/v3/setup/storage.json', headers: { | ||
Authorization: "Bearer unauthorized_token }" | ||
} | ||
expect(response).to have_http_status(:unauthorized) | ||
expect(json_response[:error]).to eq("invalid_token") | ||
expect(json_response[:error_description]).to eq("Malformed authorization header") | ||
end | ||
end | ||
|
||
context "successful retrieve all existing Storages" do | ||
|
||
it "with authorized token request" do | ||
get '/api/v3/setup/storage.json', headers: header_token_authorization | ||
|
||
expect(response).to have_http_status(:ok) | ||
expect(json_response[:count]).to be | ||
expect(json_response[:current_page]).to eq 1 | ||
expect(json_response[:current_page]).to be | ||
expect(json_response[:data_type]).to be | ||
expect(json_response[:items]).to be | ||
expect(json_response[:total_pages]).to be | ||
end | ||
|
||
end | ||
|
||
end | ||
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@dexterhenry why an extra space here