feat: Support Azure single-tenant application using the Graph API (#6728) (#6878)

This commit is contained in:
Tejaswini Chile
2023-06-28 08:13:08 +05:30
committed by GitHub
parent 4a770fdea7
commit d05c953eef
14 changed files with 451 additions and 13 deletions

View File

@@ -43,6 +43,29 @@ RSpec.describe 'Microsoft Authorization API', type: :request do
expect(response.parsed_body['url']).to eq response_url
expect(Redis::Alfred.get(administrator.email)).to eq(account.id.to_s)
end
it 'creates a new authorization and returns the redirect url for single tenant' do
with_modified_env AZURE_TENANT_ID: 'azure_tenant_id' do
post "/api/v1/accounts/#{account.id}/microsoft/authorization",
headers: administrator.create_new_auth_token,
params: { email: administrator.email },
as: :json
microsoft_service = Class.new { extend MicrosoftConcern }
response_url = microsoft_service.microsoft_client.auth_code.authorize_url(
{
redirect_uri: "#{ENV.fetch('FRONTEND_URL', 'http://localhost:3000')}/microsoft/callback",
scope: 'offline_access https://graph.microsoft.com/Mail.Read https://graph.microsoft.com/Mail.Send openid profile',
prompt: 'consent'
}
)
expect(response.parsed_body['url']).to eq response_url
end
expect(response).to have_http_status(:success)
expect(Redis::Alfred.get(administrator.email)).to eq(account.id.to_s)
end
end
end
end