Re-add more specs
All checks were successful
continuous-integration/drone/push Build is passing
continuous-integration/drone/pr Build is passing

This commit is contained in:
Râu Cao 2023-11-20 12:21:57 +01:00
parent aa399b862a
commit bdf5a18ad4
Signed by: raucao
GPG Key ID: 15E65F399D084BA9
2 changed files with 98 additions and 97 deletions

View File

@ -87,7 +87,7 @@ class Rs::OauthController < ApplicationController
permissions: permissions, permissions: permissions,
client_id: client_id, client_id: client_id,
redirect_uri: redirect_uri, redirect_uri: redirect_uri,
app_name: client_id, #TODO use user-defined name app_name: client_id,
expire_at: expire_at expire_at: expire_at
) )

View File

@ -76,102 +76,103 @@ RSpec.describe RemoteStorageAuthorization, type: :model do
end end
end end
# describe "#find_or_create_web_app" do describe "#find_or_create_web_app" do
# context "with origin that looks hosted" do context "with origin that looks hosted" do
# before do after(:all) { redis_rs_delete_keys("authorizations:*") }
# auth = user.remote_storage_authorizations.create!(
# permissions: %w(documents photos contacts:rw videos:r tasks/work:r), let(:auth) do
# client_id: "example.com", user.remote_storage_authorizations.create!(
# redirect_uri: "https://example.com", permissions: %w(documents:rw),
# expire_at: 1.month.from_now client_id: "example.com",
# ) redirect_uri: "https://example.com",
# end expire_at: 1.month.from_now
# )
# it "generates a web_app" do end
# expect(auth.web_app).to be_a(AppCatalog::WebApp)
# end it "generates a web_app" do
# expect(auth.web_app).to be_a(AppCatalog::WebApp)
# it "uses the Web App's name as app name" do end
# expect(auth.app_name).to eq("Example Domain") end
# end
# end context "when creating two authorizations for the same app" do
# let(:user_2) { create :user, id: 23, cn: "michiel", email: "michiel@example.com" }
# context "when creating two authorizations for the same app" do
# before do let(:auth_1) do
# user_2 = create :user user.remote_storage_authorizations.create!(
# ResqueSpec.reset! permissions: %w(documents photos contacts:rw videos:r tasks/work:r),
# auth_1 = user.remote_storage_authorizations.create!( client_id: "example.com",
# permissions: %w(documents photos contacts:rw videos:r tasks/work:r), redirect_uri: "https://example.com",
# client_id: "example.com", expire_at: 1.month.from_now
# redirect_uri: "https://example.com", )
# expire_at: 1.month.from_now end
# )
# auth_2 = user_2.remote_storage_authorizations.create!( let(:auth_2) do
# permissions: %w(documents photos contacts:rw videos:r tasks/work:r), user_2.remote_storage_authorizations.create!(
# client_id: "example.com", permissions: %w(documents photos contacts:rw videos:r tasks/work:r),
# redirect_uri: "https://example.com", client_id: "example.com",
# expire_at: 1.month.from_now redirect_uri: "https://example.com",
# ) expire_at: 1.month.from_now
# end )
# end
# after do
# auth_1.destroy after do
# auth_2.destroy auth_1.destroy
# user_2.destroy auth_2.destroy
# end user_2.destroy
# end
# it "uses the same web app instance for both authorizations" do
# expect(auth_1.web_app).to be_a(AppCatalog::WebApp) it "uses the same web app for both authorizations" do
# expect(auth_1.web_app).to eq(auth_2.web_app) expect(auth_1.web_app).to eq(auth_2.web_app)
# end end
# end end
#
# describe "non-production app origins" do describe "non-production app origins" do
# context "when host is not an FQDN" do context "when host is not an FQDN" do
# before do let(:auth) do
# auth = user.remote_storage_authorizations.create!( user.remote_storage_authorizations.create!(
# permissions: %w(recipes), permissions: %w(recipes),
# client_id: "localhost:4200", client_id: "localhost:4200",
# redirect_uri: "http://localhost:4200" redirect_uri: "http://localhost:4200"
# ) )
# end end
#
# it "does not create a web app" do it "does not create a web app" do
# expect(auth.web_app).to be_nil expect(auth.web_app).to be_nil
# expect(auth.app_name).to eq("localhost:4200") expect(auth.app_name).to eq("localhost:4200")
# end end
# end end
#
# context "when host is an IP address" do context "when host is an IP address" do
# before do let(:auth) do
# auth = user.remote_storage_authorizations.create!( user.remote_storage_authorizations.create!(
# permissions: %w(recipes), permissions: %w(recipes),
# client_id: "192.168.0.23:3000", client_id: "192.168.0.23:3000",
# redirect_uri: "http://192.168.0.23:3000" redirect_uri: "http://192.168.0.23:3000"
# ) )
# end end
#
# it "does not create a web app" do it "does not create a web app" do
# expect(auth.web_app).to be_nil expect(auth.web_app).to be_nil
# expect(auth.app_name).to eq("192.168.0.23:3000") expect(auth.app_name).to eq("192.168.0.23:3000")
# end end
# end end
#
# context "when host is an extension URL" do # before do context "when host is an extension URL" do
# auth = user.remote_storage_authorizations.create!( let(:auth) do
# permissions: %w(bookmarks), user.remote_storage_authorizations.create!(
# client_id: "123.addons.allizom.org", permissions: %w(bookmarks),
# redirect_uri: "123.addons.allizom.org/foo" client_id: "123.addons.allizom.org",
# ) redirect_uri: "123.addons.allizom.org/foo"
# end )
# end
# it "does not create a web app" do
# expect(auth.web_app).to be_nil it "does not create a web app" do
# expect(auth.app_name).to eq("123.addons.allizom.org") expect(auth.web_app).to be_nil
# end expect(auth.app_name).to eq("123.addons.allizom.org")
# end end
# end end
# end end
end
# describe "auth notifications" do # describe "auth notifications" do
# context "with auth notifications enabled" do # context "with auth notifications enabled" do