Skip to content

OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub

[#49120] added files info query for one drive

Eric Schubert437117dfb0c7
diff --git a/modules/storages/app/common/storages/peripherals/storage_interaction/one_drive/files_info_query.rb b/modules/storages/app/common/storages/peripherals/storage_interaction/one_drive/files_info_query.rb
new file mode 100644
index 00000000000..b0a6832bd5c
--- /dev/null
+++ b/modules/storages/app/common/storages/peripherals/storage_interaction/one_drive/files_info_query.rb
@@ -0,0 +1,149 @@
+# frozen_string_literal: true
+
+#-- copyright
+# OpenProject is an open source project management software.
+# Copyright (C) 2012-2023 the OpenProject GmbH
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License version 3.
+#
+# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:
+# Copyright (C) 2006-2013 Jean-Philippe Lang
+# Copyright (C) 2010-2013 the ChiliProject Team
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+#
+# See COPYRIGHT and LICENSE files for more details.
+#++
+
+module Storages
+ module Peripherals
+ module StorageInteraction
+ module OneDrive
+ class FilesInfoQuery
+ using ServiceResultRefinements
+
+ def self.call(storage:, user:, file_ids: [])
+ new(storage).call(user:, file_ids:)
+ end
+
+ def initialize(storage)
+ @storage = storage
+ end
+
+ def call(user:, file_ids:)
+ using_user_token(user) do |token|
+ make_file_requests(file_ids, token).map(&storage_file_infos)
+ end
+ end
+
+ private
+
+ def make_file_requests(file_ids, token)
+ if file_ids.nil?
+ return ServiceResult.failure(result: :error, errors: ::Storages::StorageError.new(code: :error))
+ end
+
+ response_data = Net::HTTP.start(GRAPH_API_URI.host, GRAPH_API_URI.port, use_ssl: true) do |http|
+ file_ids.map do |file_id|
+ {
+ file_id:,
+ response: http.get(uri_path_for(file_id), { 'Authorization' => "Bearer #{token.access_token}" })
+ }
+ end
+ end
+
+ handle_responses(response_data)
+ end
+
+ def handle_responses(response_data)
+ if response_data.all? { |data| data[:response].is_a?(Net::HTTPSuccess) || data[:response].is_a?(Net::HTTPNotFound) }
+ ServiceResult.success(result: response_data)
+ elsif response_data.any? { |data| data[:response].is_a?(Net::HTTPUnauthorized) }
+ ServiceResult.failure(result: :not_authorized, errors: ::Storages::StorageError.new(code: :not_authorized))
+ else
+ ServiceResult.failure(result: :error, errors: ::Storages::StorageError.new(code: :error))
+ end
+ end
+
+ def uri_path_for(file_id)
+ "/v1.0/drives/#{@storage.drive_id}/items/#{file_id}"
+ end
+
+ # rubocop:disable Metrics/AbcSize
+ def storage_file_infos
+ ->(response_data) do
+ response_data.map do |data|
+ response = data[:response]
+ json = MultiJson.load(response.body, symbolize_keys: true)
+
+ if response.is_a?(Net::HTTPSuccess)
+ StorageFileInfo.new(
+ status: 'ok',
+ status_code: response.code,
+ id: json[:id],
+ name: json[:name],
+ last_modified_at: DateTime.parse(json.dig(:fileSystemInfo, :lastModifiedDateTime)),
+ created_at: DateTime.parse(json.dig(:fileSystemInfo, :createdDateTime)),
+ mime_type: mime_type(json),
+ size: json[:size],
+ owner_name: json.dig(:createdBy, :user, :displayName),
+ owner_id: json.dig(:createdBy, :user, :id),
+ trashed: false,
+ last_modified_by_name: json.dig(:lastModifiedBy, :user, :displayName),
+ last_modified_by_id: json.dig(:lastModifiedBy, :user, :id),
+ permissions: nil,
+ location: json.dig(:parentReference, :path)
+ )
+ else
+ StorageFileInfo.new(
+ status: json.dig(:error, :code),
+ status_code: response.code,
+ id: data[:file_id]
+ )
+ end
+ end
+ end
+ end
+
+ # rubocop:enable Metrics/AbcSize
+
+ def mime_type(json)
+ json.dig(:file, :mimeType) || (json.key?(:folder) ? 'application/x-op-directory' : nil)
+ end
+
+ def using_user_token(user, &block)
+ connection_manager = ::OAuthClients::OneDriveConnectionManager
+ .new(user:, oauth_client: @storage.oauth_client, tenant_id: @storage.tenant_id)
+
+ connection_manager
+ .get_access_token
+ .match(
+ on_success: ->(token) do
+ connection_manager.request_with_token_refresh(token) { block.call(token) }
+ end,
+ on_failure: ->(_) do
+ ServiceResult.failure(
+ result: :not_authorized,
+ message: 'Query could not be created! No access token found!'
+ )
+ end
+ )
+ end
+ end
+ end
+ end
+ end
+end
diff --git a/modules/storages/spec/common/peripherals/storage_interaction/one_drive/files_info_query_spec.rb b/modules/storages/spec/common/peripherals/storage_interaction/one_drive/files_info_query_spec.rb
new file mode 100644
index 00000000000..50c50526739
--- /dev/null
+++ b/modules/storages/spec/common/peripherals/storage_interaction/one_drive/files_info_query_spec.rb
@@ -0,0 +1,200 @@
+# frozen_string_literal: true
+
+#-- copyright
+# OpenProject is an open source project management software.
+# Copyright (C) 2012-2023 the OpenProject GmbH
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License version 3.
+#
+# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:
+# Copyright (C) 2006-2013 Jean-Philippe Lang
+# Copyright (C) 2010-2013 the ChiliProject Team
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+#
+# See COPYRIGHT and LICENSE files for more details.
+#++
+
+require 'spec_helper'
+require_module_spec_helper
+
+RSpec.describe Storages::Peripherals::StorageInteraction::OneDrive::FilesInfoQuery, webmock: true do
+ let(:storage) do
+ create(:one_drive_storage,
+ :with_oauth_client,
+ drive_id: 'b!-RIj2DuyvEyV1T4NlOaMHk8XkS_I8MdFlUCq1BlcjgmhRfAj3-Z8RY2VpuvV_tpd')
+ end
+ let(:user) { create(:user) }
+ let(:token) { create(:oauth_client_token, user:, oauth_client: storage.oauth_client) }
+ let(:file_ids) do
+ %w(
+ 01BYE5RZ5MYLM2SMX75ZBIPQZIHT6OAYPB
+ 01BYE5RZZ6FUE5272C5JCY3L7CLZ7XOUYM
+ 01BYE5RZ47DTJGHO73WBH2ONNXQZVNNILJ
+ not_existent
+ )
+ end
+ let(:not_found_json) do
+ {
+ error: {
+ code: 'itemNotFound',
+ message: 'The resource could not be found.',
+ innerError: {
+ date: '2023-09-08T08:20:55',
+ 'request-id': '286b0215-7f33-46dc-b1fe-67720fe1616a',
+ 'client-request-id': '286b0215-7f33-46dc-b1fe-67720fe1616a'
+ }
+ }
+ }.to_json
+ end
+
+ before do
+ stub_request(:get, "https://graph.microsoft.com/v1.0/drives/#{storage.drive_id}/items/#{file_ids[0]}")
+ .with(headers: { 'Authorization' => "Bearer #{token.access_token}" })
+ .to_return(status: 200, body: read_json('folder_drive_item'), headers: {})
+ stub_request(:get, "https://graph.microsoft.com/v1.0/drives/#{storage.drive_id}/items/#{file_ids[1]}")
+ .with(headers: { 'Authorization' => "Bearer #{token.access_token}" })
+ .to_return(status: 200, body: read_json('file_drive_item_1'), headers: {})
+ stub_request(:get, "https://graph.microsoft.com/v1.0/drives/#{storage.drive_id}/items/#{file_ids[2]}")
+ .with(headers: { 'Authorization' => "Bearer #{token.access_token}" })
+ .to_return(status: 200, body: read_json('file_drive_item_2'), headers: {})
+ stub_request(:get, "https://graph.microsoft.com/v1.0/drives/#{storage.drive_id}/items/#{file_ids[3]}")
+ .with(headers: { 'Authorization' => "Bearer #{token.access_token}" })
+ .to_return(status: 404, body: not_found_json, headers: {})
+ end
+
+ it 'responds to .call' do
+ expect(described_class).to respond_to(:call)
+
+ method = described_class.method(:call)
+ expect(method.parameters).to contain_exactly(%i[keyreq storage], %i[keyreq user], %i[key file_ids])
+ end
+
+ it 'returns an array of StorageFileInfo' do
+ storage_file_infos = described_class.call(storage:, user:, file_ids:).result
+
+ expect(storage_file_infos).to all(be_a(Storages::StorageFileInfo))
+ end
+
+ it 'returns a folder storage file info object' do
+ storage_file_info = described_class.call(storage:, user:, file_ids: file_ids.slice(0, 1)).result[0]
+
+ # rubocop:disable Layout/LineLength
+ expect(storage_file_info.to_h).to eq({
+ status: 'ok',
+ status_code: '200',
+ id: '01BYE5RZ5MYLM2SMX75ZBIPQZIHT6OAYPB',
+ name: "Business Data",
+ size: 39566226,
+ mime_type: "application/x-op-directory",
+ created_at: Time.parse("2017-08-07T16:16:30Z"),
+ last_modified_at: Time.parse("2017-08-07T16:16:30Z"),
+ owner_name: "Megan Bowen",
+ owner_id: "48d31887-5fad-4d73-a9f5-3c356e68a038",
+ last_modified_by_id: "48d31887-5fad-4d73-a9f5-3c356e68a038",
+ last_modified_by_name: "Megan Bowen",
+ permissions: nil,
+ trashed: false,
+ location: "/drives/b!-RIj2DuyvEyV1T4NlOaMHk8XkS_I8MdFlUCq1BlcjgmhRfAj3-Z8RY2VpuvV_tpd/root:"
+ })
+ # rubocop:enable Layout/LineLength
+ end
+
+ it 'returns a file storage file info object' do
+ storage_file_info = described_class.call(storage:, user:, file_ids: file_ids.slice(1, 1)).result[0]
+
+ # rubocop:disable Layout/LineLength
+ expect(storage_file_info.to_h).to eq({
+ status: 'ok',
+ status_code: '200',
+ id: '01BYE5RZZ6FUE5272C5JCY3L7CLZ7XOUYM',
+ name: "All Japan Revenues By City.xlsx",
+ size: 20051,
+ mime_type: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
+ created_at: Time.parse("2017-08-07T16:07:10Z"),
+ last_modified_at: Time.parse("2017-08-07T16:07:10Z"),
+ owner_name: "Megan Bowen",
+ owner_id: "48d31887-5fad-4d73-a9f5-3c356e68a038",
+ last_modified_by_id: "48d31887-5fad-4d73-a9f5-3c356e68a038",
+ last_modified_by_name: "Megan Bowen",
+ permissions: nil,
+ trashed: false,
+ location: "/drives/b!-RIj2DuyvEyV1T4NlOaMHk8XkS_I8MdFlUCq1BlcjgmhRfAj3-Z8RY2VpuvV_tpd/root:"
+ })
+ # rubocop:enable Layout/LineLength
+ end
+
+ it 'returns an error storage file info object' do
+ storage_file_info = described_class.call(storage:, user:, file_ids: file_ids.slice(3, 1)).result[0]
+
+ expect(storage_file_info.to_h).to eq({
+ status: 'itemNotFound',
+ status_code: '404',
+ id: 'not_existent',
+ name: nil,
+ size: nil,
+ mime_type: nil,
+ created_at: nil,
+ last_modified_at: nil,
+ owner_name: nil,
+ owner_id: nil,
+ last_modified_by_id: nil,
+ last_modified_by_name: nil,
+ permissions: nil,
+ trashed: nil,
+ location: nil
+ })
+ end
+
+ describe 'error handling' do
+ it 'returns a success with empty result, if the query is called with empty file ids array' do
+ storage_files = described_class.call(storage:, user:, file_ids: [])
+
+ expect(storage_files).to be_success
+ expect(storage_files.result).to eq([])
+ end
+
+ it 'returns an error, if the query is called with nil file ids array' do
+ storage_files = described_class.call(storage:, user:, file_ids: nil)
+
+ expect(storage_files).to be_failure
+ expect(storage_files.result).to eq(:error)
+ expect(storage_files.errors.to_s).to eq(Storages::StorageError.new(code: :error).to_s)
+ end
+
+ it 'returns a :not_authorized error if any API call returns a 401' do
+ stub_request(:get, "https://graph.microsoft.com/v1.0/drives/#{storage.drive_id}/items/#{file_ids[0]}")
+ .with(headers: { 'Authorization' => "Bearer #{token.access_token}" })
+ .to_return(status: 401, body: '', headers: {})
+
+ storage_files = described_class.call(storage:, user:, file_ids: file_ids.slice(0, 1))
+
+ expect(storage_files).to be_failure
+ expect(storage_files.result).to eq(:not_authorized)
+ expect(storage_files.errors.to_s).to eq(Storages::StorageError.new(code: :not_authorized).to_s)
+ end
+ end
+
+ private
+
+ def read_json(name)
+ File.readlines(payload_path.join("#{name}.json")).join
+ end
+
+ def payload_path
+ Pathname.new(Rails.root).join('modules/storages/spec/support/payloads/')
+ end
+end
diff --git a/modules/storages/spec/support/payloads/file_drive_item_1.json b/modules/storages/spec/support/payloads/file_drive_item_1.json
new file mode 100644
index 00000000000..4e4f1644401
--- /dev/null
+++ b/modules/storages/spec/support/payloads/file_drive_item_1.json
@@ -0,0 +1,46 @@
+{
+ "@odata.context": "https://graph.microsoft.com/v1.0/$metadata#users('48d31887-5fad-4d73-a9f5-3c356e68a038')/drives('b%21-RIj2DuyvEyV1T4NlOaMHk8XkS_I8MdFlUCq1BlcjgmhRfAj3-Z8RY2VpuvV_tpd')/items/$entity",
+ "@microsoft.graph.downloadUrl": "https://m365x214355-my.sharepoint.com/personal/meganb_m365x214355_onmicrosoft_com/_layouts/15/download.aspx?UniqueId=dd092d3e-427f-45ea-8daf-e25e7f77530c&Translate=false&tempauth=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJhdWQiOiIwMDAwMDAwMy0wMDAwLTBmZjEtY2UwMC0wMDAwMDAwMDAwMDAvbTM2NXgyMTQzNTUtbXkuc2hhcmVwb2ludC5jb21AZGNkMjE5ZGQtYmM2OC00YjliLWJmMGItNGEzM2E3OTZiZTM1IiwiaXNzIjoiMDAwMDAwMDMtMDAwMC0wZmYxLWNlMDAtMDAwMDAwMDAwMDAwIiwibmJmIjoiMTY5NDA5MjIxNyIsImV4cCI6IjE2OTQwOTU4MTciLCJlbmRwb2ludHVybCI6IjlacHYvK25wK3ExWnFXdnlMM2RZNGVVaHdtMlllaHJvRTlBSmFjOC84R2c9IiwiZW5kcG9pbnR1cmxMZW5ndGgiOiIxNjkiLCJpc2xvb3BiYWNrIjoiVHJ1ZSIsImNpZCI6IjRmalZ5bnFqTUU2QXNZaUhrUjhJc1E9PSIsInZlciI6Imhhc2hlZHByb29mdG9rZW4iLCJzaXRlaWQiOiJaRGd5TXpFeVpqa3RZakl6WWkwMFkySmpMVGsxWkRVdE0yVXdaRGswWlRZNFl6RmwiLCJhcHBfZGlzcGxheW5hbWUiOiJhcGlzYW5kYm94cHJveHkiLCJnaXZlbl9uYW1lIjoiTWVnYW4iLCJmYW1pbHlfbmFtZSI6IkJvd2VuIiwiYXBwaWQiOiIwNWIxMGEyZC02MmRiLTQyMGMtODYyNi01NWYzYTVlNzg2NWIiLCJ0aWQiOiJkY2QyMTlkZC1iYzY4LTRiOWItYmYwYi00YTMzYTc5NmJlMzUiLCJ1cG4iOiJtZWdhbmJAbTM2NXgyMTQzNTUub25taWNyb3NvZnQuY29tIiwicHVpZCI6IjEwMDNCRkZEQTM4MTMxQUYiLCJjYWNoZWtleSI6IjBoLmZ8bWVtYmVyc2hpcHwxMDAzYmZmZGEzODEzMWFmQGxpdmUuY29tIiwic2NwIjoibXlmaWxlcy5yZWFkIGdyb3VwLnJlYWQgYWxsc2l0ZXMucmVhZCBhbGxwcm9maWxlcy5yZWFkIGFsbHByb2ZpbGVzLnJlYWQgdGVybXN0b3JlLnJlYWQiLCJ0dCI6IjIiLCJpcGFkZHIiOiIyMC4xOTAuMTY5LjE2MCJ9.P2hyTGx96JOTh3_8HyKyNkUOvUh88nZmRGmDbxDMQaE&ApiVersion=2.0",
+ "createdDateTime": "2017-08-07T16:07:10Z",
+ "eTag": "\"{DD092D3E-427F-45EA-8DAF-E25E7F77530C},3\"",
+ "id": "01BYE5RZZ6FUE5272C5JCY3L7CLZ7XOUYM",
+ "lastModifiedDateTime": "2017-08-07T16:07:10Z",
+ "name": "All Japan Revenues By City.xlsx",
+ "webUrl": "https://m365x214355-my.sharepoint.com/personal/meganb_m365x214355_onmicrosoft_com/_layouts/15/Doc.aspx?sourcedoc=%7BDD092D3E-427F-45EA-8DAF-E25E7F77530C%7D&file=All%20Japan%20Revenues%20By%20City.xlsx&action=default&mobileredirect=true",
+ "cTag": "\"c:{DD092D3E-427F-45EA-8DAF-E25E7F77530C},1\"",
+ "size": 20051,
+ "createdBy": {
+ "user": {
+ "email": "[email protected]",
+ "id": "48d31887-5fad-4d73-a9f5-3c356e68a038",
+ "displayName": "Megan Bowen"
+ }
+ },
+ "lastModifiedBy": {
+ "user": {
+ "email": "[email protected]",
+ "id": "48d31887-5fad-4d73-a9f5-3c356e68a038",
+ "displayName": "Megan Bowen"
+ }
+ },
+ "parentReference": {
+ "driveType": "business",
+ "driveId": "b!-RIj2DuyvEyV1T4NlOaMHk8XkS_I8MdFlUCq1BlcjgmhRfAj3-Z8RY2VpuvV_tpd",
+ "id": "01BYE5RZ56Y2GOVW7725BZO354PWSELRRZ",
+ "path": "/drives/b!-RIj2DuyvEyV1T4NlOaMHk8XkS_I8MdFlUCq1BlcjgmhRfAj3-Z8RY2VpuvV_tpd/root:",
+ "siteId": "d82312f9-b23b-4cbc-95d5-3e0d94e68c1e"
+ },
+ "file": {
+ "mimeType": "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
+ "hashes": {
+ "quickXorHash": "I1snetixdavVoAQ0QMvy/W1dyhs="
+ }
+ },
+ "fileSystemInfo": {
+ "createdDateTime": "2017-08-07T16:07:10Z",
+ "lastModifiedDateTime": "2017-08-07T16:07:10Z"
+ },
+ "shared": {
+ "scope": "users"
+ }
+}
\ No newline at end of file
diff --git a/modules/storages/spec/support/payloads/file_drive_item_2.json b/modules/storages/spec/support/payloads/file_drive_item_2.json
new file mode 100644
index 00000000000..ba524a7afcb
--- /dev/null
+++ b/modules/storages/spec/support/payloads/file_drive_item_2.json
@@ -0,0 +1,51 @@
+{
+ "@odata.context": "https://graph.microsoft.com/v1.0/$metadata#users('48d31887-5fad-4d73-a9f5-3c356e68a038')/drives('b%21-RIj2DuyvEyV1T4NlOaMHk8XkS_I8MdFlUCq1BlcjgmhRfAj3-Z8RY2VpuvV_tpd')/items/$entity",
+ "@microsoft.graph.downloadUrl": "https://m365x214355-my.sharepoint.com/personal/meganb_m365x214355_onmicrosoft_com/_layouts/15/download.aspx?UniqueId=63d21c9f-fbbb-4fb0-a735-b7866ad6a169&Translate=false&tempauth=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJhdWQiOiIwMDAwMDAwMy0wMDAwLTBmZjEtY2UwMC0wMDAwMDAwMDAwMDAvbTM2NXgyMTQzNTUtbXkuc2hhcmVwb2ludC5jb21AZGNkMjE5ZGQtYmM2OC00YjliLWJmMGItNGEzM2E3OTZiZTM1IiwiaXNzIjoiMDAwMDAwMDMtMDAwMC0wZmYxLWNlMDAtMDAwMDAwMDAwMDAwIiwibmJmIjoiMTY5NDA5MjIzNCIsImV4cCI6IjE2OTQwOTU4MzQiLCJlbmRwb2ludHVybCI6Ik1BT3pvbGh5VURRMzhnSEEyajhQS1NoU2dzY015WlZBWlN3d1VsRDBOYkk9IiwiZW5kcG9pbnR1cmxMZW5ndGgiOiIxNjkiLCJpc2xvb3BiYWNrIjoiVHJ1ZSIsImNpZCI6IjJCR1dDemVJZkVta05RRVVKaFVubmc9PSIsInZlciI6Imhhc2hlZHByb29mdG9rZW4iLCJzaXRlaWQiOiJaRGd5TXpFeVpqa3RZakl6WWkwMFkySmpMVGsxWkRVdE0yVXdaRGswWlRZNFl6RmwiLCJhcHBfZGlzcGxheW5hbWUiOiJhcGlzYW5kYm94cHJveHkiLCJnaXZlbl9uYW1lIjoiTWVnYW4iLCJmYW1pbHlfbmFtZSI6IkJvd2VuIiwiYXBwaWQiOiIwNWIxMGEyZC02MmRiLTQyMGMtODYyNi01NWYzYTVlNzg2NWIiLCJ0aWQiOiJkY2QyMTlkZC1iYzY4LTRiOWItYmYwYi00YTMzYTc5NmJlMzUiLCJ1cG4iOiJtZWdhbmJAbTM2NXgyMTQzNTUub25taWNyb3NvZnQuY29tIiwicHVpZCI6IjEwMDNCRkZEQTM4MTMxQUYiLCJjYWNoZWtleSI6IjBoLmZ8bWVtYmVyc2hpcHwxMDAzYmZmZGEzODEzMWFmQGxpdmUuY29tIiwic2NwIjoibXlmaWxlcy5yZWFkIGdyb3VwLnJlYWQgYWxsc2l0ZXMucmVhZCBhbGxwcm9maWxlcy5yZWFkIGFsbHByb2ZpbGVzLnJlYWQgdGVybXN0b3JlLnJlYWQiLCJ0dCI6IjIiLCJpcGFkZHIiOiIyMC4xOTAuMTY5LjE2MCJ9.E8yDmydDqhGRNq-c0sLJ7UYrKMx7g3TwF15wV4djDiI&ApiVersion=2.0",
+ "createdDateTime": "2017-08-07T16:08:22Z",
+ "eTag": "\"{63D21C9F-FBBB-4FB0-A735-B7866AD6A169},4\"",
+ "id": "01BYE5RZ47DTJGHO73WBH2ONNXQZVNNILJ",
+ "lastModifiedDateTime": "2017-08-07T16:08:22Z",
+ "name": "BrokenPipe.jpg",
+ "webUrl": "https://m365x214355-my.sharepoint.com/personal/meganb_m365x214355_onmicrosoft_com/Documents/BrokenPipe.jpg",
+ "cTag": "\"c:{63D21C9F-FBBB-4FB0-A735-B7866AD6A169},1\"",
+ "size": 5336,
+ "createdBy": {
+ "user": {
+ "email": "[email protected]",
+ "id": "48d31887-5fad-4d73-a9f5-3c356e68a038",
+ "displayName": "Megan Bowen"
+ }
+ },
+ "lastModifiedBy": {
+ "user": {
+ "email": "[email protected]",
+ "id": "48d31887-5fad-4d73-a9f5-3c356e68a038",
+ "displayName": "Megan Bowen"
+ }
+ },
+ "parentReference": {
+ "driveType": "business",
+ "driveId": "b!-RIj2DuyvEyV1T4NlOaMHk8XkS_I8MdFlUCq1BlcjgmhRfAj3-Z8RY2VpuvV_tpd",
+ "id": "01BYE5RZ56Y2GOVW7725BZO354PWSELRRZ",
+ "path": "/drives/b!-RIj2DuyvEyV1T4NlOaMHk8XkS_I8MdFlUCq1BlcjgmhRfAj3-Z8RY2VpuvV_tpd/root:",
+ "siteId": "d82312f9-b23b-4cbc-95d5-3e0d94e68c1e"
+ },
+ "file": {
+ "mimeType": "image/jpeg",
+ "hashes": {
+ "quickXorHash": "OGd+sgG4B/f1x6pn54GCsFTczzI="
+ }
+ },
+ "fileSystemInfo": {
+ "createdDateTime": "2017-08-07T16:08:22Z",
+ "lastModifiedDateTime": "2017-08-07T16:08:22Z"
+ },
+ "image": {
+ "height": 183,
+ "width": 260
+ },
+ "photo": {},
+ "shared": {
+ "scope": "users"
+ }
+}
\ No newline at end of file
diff --git a/modules/storages/spec/support/payloads/folder_drive_item.json b/modules/storages/spec/support/payloads/folder_drive_item.json
new file mode 100644
index 00000000000..b81c0b5012e
--- /dev/null
+++ b/modules/storages/spec/support/payloads/folder_drive_item.json
@@ -0,0 +1,39 @@
+{
+ "@odata.context": "https://graph.microsoft.com/v1.0/$metadata#users('48d31887-5fad-4d73-a9f5-3c356e68a038')/drives('b%21-RIj2DuyvEyV1T4NlOaMHk8XkS_I8MdFlUCq1BlcjgmhRfAj3-Z8RY2VpuvV_tpd')/items/$entity",
+ "createdDateTime": "2017-08-07T16:16:30Z",
+ "eTag": "\"{A9D9C2AC-FF32-42EE-87C3-283CFCE061E1},1\"",
+ "id": "01BYE5RZ5MYLM2SMX75ZBIPQZIHT6OAYPB",
+ "lastModifiedDateTime": "2017-08-07T16:16:30Z",
+ "name": "Business Data",
+ "webUrl": "https://m365x214355-my.sharepoint.com/personal/meganb_m365x214355_onmicrosoft_com/Documents/Business%20Data",
+ "cTag": "\"c:{A9D9C2AC-FF32-42EE-87C3-283CFCE061E1},0\"",
+ "size": 39566226,
+ "createdBy": {
+ "user": {
+ "email": "[email protected]",
+ "id": "48d31887-5fad-4d73-a9f5-3c356e68a038",
+ "displayName": "Megan Bowen"
+ }
+ },
+ "lastModifiedBy": {
+ "user": {
+ "email": "[email protected]",
+ "id": "48d31887-5fad-4d73-a9f5-3c356e68a038",
+ "displayName": "Megan Bowen"
+ }
+ },
+ "parentReference": {
+ "driveType": "business",
+ "driveId": "b!-RIj2DuyvEyV1T4NlOaMHk8XkS_I8MdFlUCq1BlcjgmhRfAj3-Z8RY2VpuvV_tpd",
+ "id": "01BYE5RZ56Y2GOVW7725BZO354PWSELRRZ",
+ "path": "/drives/b!-RIj2DuyvEyV1T4NlOaMHk8XkS_I8MdFlUCq1BlcjgmhRfAj3-Z8RY2VpuvV_tpd/root:",
+ "siteId": "d82312f9-b23b-4cbc-95d5-3e0d94e68c1e"
+ },
+ "fileSystemInfo": {
+ "createdDateTime": "2017-08-07T16:16:30Z",
+ "lastModifiedDateTime": "2017-08-07T16:16:30Z"
+ },
+ "folder": {
+ "childCount": 6
+ }
+}