This commit is contained in:
Colby Williams 2018-04-12 13:03:37 -04:00
Родитель 981adfe202
Коммит 7ee45876ef
36 изменённых файлов: 2302 добавлений и 4 удалений

96
.gitignore поставляемый
Просмотреть файл

@ -287,6 +287,98 @@ __pycache__/
*.odx.cs
*.xsd.cs
*.DS_Store
*.sln.cache
*.DS_Store
*.sln.cache
# Xcode
#
# gitignore contributors: remember to update Global/Xcode.gitignore, Objective-C.gitignore & Swift.gitignore
## Build generated
build/
DerivedData/
## Various settings
*.pbxuser
!default.pbxuser
*.mode1v3
!default.mode1v3
*.mode2v3
!default.mode2v3
*.perspectivev3
!default.perspectivev3
xcuserdata/
## Other
*.moved-aside
*.xccheckout
*.xcscmblueprint
## Obj-C/Swift specific
*.hmap
*.ipa
*.dSYM.zip
*.dSYM
## Playgrounds
timeline.xctimeline
playground.xcworkspace
# Swift Package Manager
#
# Add this line if you want to avoid checking in source code from Swift Package Manager dependencies.
# Packages/
# Package.pins
.build/
# CocoaPods
#
# We recommend against adding the Pods directory to your .gitignore. However
# you should judge for yourself, the pros and cons are mentioned at:
# https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control
#
# Pods/
# Carthage
#
# Add this line if you want to avoid checking in source code from Carthage dependencies.
*/Carthage/Checkouts
*/Carthage/Build
iOS/AzureMobile/Carthage/Checkouts
iOS/AzureMobile/Carthage/Build
# fastlane
#
# It is recommended to not store the screenshots in the git repo. Instead, use fastlane to re-generate the
# screenshots whenever they are needed.
# For more information about the recommended setup visit:
# https://docs.fastlane.tools/best-practices/source-control/#source-control
fastlane/report.xml
fastlane/Preview.html
fastlane/screenshots
fastlane/test_output
*.csproj.bak
project.lock.json
.vs/
[Ll]ocal/
[Pp]rivateKeys.cs
[Pp]rivateKeys.swift
*.paw
*.xcbkptlist
*.xcuserstate
# *.xcworkspacedata
AzureData Sample/scripts/test-all.sh
Azure.framework.zip
iOS/AzureMobile/AzureMobile.framework.zip

Просмотреть файл

Просмотреть файл

@ -54,9 +54,10 @@ namespace csharp
SecretBundle secretBundle = null;
PermissionRequest permissionRequest = null;
//https://docs.microsoft.com/en-us/azure/app-service/app-service-authentication-overview#user-claims
var userId = req.UniqueUserIdentifier() ?? AnonymousId;
log.Info($" ... userId: {userId}");

Просмотреть файл

Просмотреть файл

Просмотреть файл

Просмотреть файл

Просмотреть файл

@ -107,7 +107,7 @@
"WEBSITE_CONTENTSHARE": "[variables('functionAppNameLower')]",
"WEBSITE_HTTPLOGGING_RETENTION_DAYS": "2",
"WEBSITE_NODE_DEFAULT_VERSION": "6.5.0",
"PROJECT": "[if(equals(parameters('functionAppLanguage'),'C#'), 'csharp/csharp', if(equals(parameters('functionAppLanguage'),'JavaScript'), 'javascript', 'csharpscript'))]",
"PROJECT": "[if(equals(parameters('functionAppLanguage'),'C#'), 'Server/csharp/csharp', if(equals(parameters('functionAppLanguage'),'JavaScript'), 'Server/javascript', 'Server/csharpscript'))]",
"AzureWebJobsStorage": "[concat('DefaultEndpointsProtocol=https;AccountName=',variables('storageAccountName'),';AccountKey=',listKeys(resourceId('Microsoft.Storage/storageAccounts', variables('storageAccountName')), '2017-06-01').keys[0].value)]",
"AzureWebJobsDashboard": "[concat('DefaultEndpointsProtocol=https;AccountName=',variables('storageAccountName'),';AccountKey=',listKeys(resourceId('Microsoft.Storage/storageAccounts', variables('storageAccountName')), '2017-06-01').keys[0].value)]",
"AzureWebJobsDocumentDBConnectionString": "[concat('AccountEndpoint=', reference(concat('Microsoft.DocumentDb/databaseAccounts/', variables('documentDbName'))).documentEndpoint, ';AccountKey=', listKeys(resourceId('Microsoft.DocumentDb/databaseAccounts', variables('documentDbName')), '2015-04-08').primaryMasterKey)]",

1
iOS/.swift-version Normal file
Просмотреть файл

@ -0,0 +1 @@
4.1

7
iOS/Azure.xcworkspace/contents.xcworkspacedata сгенерированный Normal file
Просмотреть файл

@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<Workspace
version = "1.0">
<FileRef
location = "group:/Users/colbylwilliams/GitHub/Azure.Mobile/iOS/AzureMobile/AzureMobile.xcodeproj">
</FileRef>
</Workspace>

Просмотреть файл

@ -0,0 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>FILEHEADER</key>
<string>
// ___FILENAME___
// ___PROJECTNAME___
//
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
//</string>
</dict>
</plist>

Просмотреть файл

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>IDEDidComputeMac32BitWarning</key>
<true/>
</dict>
</plist>

Разница между файлами не показана из-за своего большого размера Загрузить разницу

Просмотреть файл

@ -0,0 +1,99 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0930"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
buildImplicitDependencies = "YES">
<BuildActionEntries>
<BuildActionEntry
buildForTesting = "YES"
buildForRunning = "YES"
buildForProfiling = "YES"
buildForArchiving = "YES"
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "93011B12207F9BA80011BE1B"
BuildableName = "AzureMobile.framework"
BlueprintName = "AzureMobile iOS"
ReferencedContainer = "container:AzureMobile.xcodeproj">
</BuildableReference>
</BuildActionEntry>
</BuildActionEntries>
</BuildAction>
<TestAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES">
<Testables>
<TestableReference
skipped = "NO">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "93011B1B207F9BA80011BE1B"
BuildableName = "AzureMobile iOS Tests.xctest"
BlueprintName = "AzureMobile iOS Tests"
ReferencedContainer = "container:AzureMobile.xcodeproj">
</BuildableReference>
</TestableReference>
</Testables>
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "93011B12207F9BA80011BE1B"
BuildableName = "AzureMobile.framework"
BlueprintName = "AzureMobile iOS"
ReferencedContainer = "container:AzureMobile.xcodeproj">
</BuildableReference>
</MacroExpansion>
<AdditionalOptions>
</AdditionalOptions>
</TestAction>
<LaunchAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
launchStyle = "0"
useCustomWorkingDirectory = "NO"
ignoresPersistentStateOnLaunch = "NO"
debugDocumentVersioning = "YES"
debugServiceExtension = "internal"
allowLocationSimulation = "YES">
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "93011B12207F9BA80011BE1B"
BuildableName = "AzureMobile.framework"
BlueprintName = "AzureMobile iOS"
ReferencedContainer = "container:AzureMobile.xcodeproj">
</BuildableReference>
</MacroExpansion>
<AdditionalOptions>
</AdditionalOptions>
</LaunchAction>
<ProfileAction
buildConfiguration = "Release"
shouldUseLaunchSchemeArgsEnv = "YES"
savedToolIdentifier = ""
useCustomWorkingDirectory = "NO"
debugDocumentVersioning = "YES">
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "93011B12207F9BA80011BE1B"
BuildableName = "AzureMobile.framework"
BlueprintName = "AzureMobile iOS"
ReferencedContainer = "container:AzureMobile.xcodeproj">
</BuildableReference>
</MacroExpansion>
</ProfileAction>
<AnalyzeAction
buildConfiguration = "Debug">
</AnalyzeAction>
<ArchiveAction
buildConfiguration = "Release"
revealArchiveInOrganizer = "YES">
</ArchiveAction>
</Scheme>

Просмотреть файл

@ -0,0 +1,99 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0930"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
buildImplicitDependencies = "YES">
<BuildActionEntries>
<BuildActionEntry
buildForTesting = "YES"
buildForRunning = "YES"
buildForProfiling = "YES"
buildForArchiving = "YES"
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "93011B31207F9CB10011BE1B"
BuildableName = "AzureMobile.framework"
BlueprintName = "AzureMobile macOS"
ReferencedContainer = "container:AzureMobile.xcodeproj">
</BuildableReference>
</BuildActionEntry>
</BuildActionEntries>
</BuildAction>
<TestAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES">
<Testables>
<TestableReference
skipped = "NO">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "93011B39207F9CB10011BE1B"
BuildableName = "AzureMobile macOS Tests.xctest"
BlueprintName = "AzureMobile macOS Tests"
ReferencedContainer = "container:AzureMobile.xcodeproj">
</BuildableReference>
</TestableReference>
</Testables>
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "93011B31207F9CB10011BE1B"
BuildableName = "AzureMobile.framework"
BlueprintName = "AzureMobile macOS"
ReferencedContainer = "container:AzureMobile.xcodeproj">
</BuildableReference>
</MacroExpansion>
<AdditionalOptions>
</AdditionalOptions>
</TestAction>
<LaunchAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
launchStyle = "0"
useCustomWorkingDirectory = "NO"
ignoresPersistentStateOnLaunch = "NO"
debugDocumentVersioning = "YES"
debugServiceExtension = "internal"
allowLocationSimulation = "YES">
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "93011B31207F9CB10011BE1B"
BuildableName = "AzureMobile.framework"
BlueprintName = "AzureMobile macOS"
ReferencedContainer = "container:AzureMobile.xcodeproj">
</BuildableReference>
</MacroExpansion>
<AdditionalOptions>
</AdditionalOptions>
</LaunchAction>
<ProfileAction
buildConfiguration = "Release"
shouldUseLaunchSchemeArgsEnv = "YES"
savedToolIdentifier = ""
useCustomWorkingDirectory = "NO"
debugDocumentVersioning = "YES">
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "93011B31207F9CB10011BE1B"
BuildableName = "AzureMobile.framework"
BlueprintName = "AzureMobile macOS"
ReferencedContainer = "container:AzureMobile.xcodeproj">
</BuildableReference>
</MacroExpansion>
</ProfileAction>
<AnalyzeAction
buildConfiguration = "Debug">
</AnalyzeAction>
<ArchiveAction
buildConfiguration = "Release"
revealArchiveInOrganizer = "YES">
</ArchiveAction>
</Scheme>

Просмотреть файл

@ -0,0 +1,99 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0930"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
buildImplicitDependencies = "YES">
<BuildActionEntries>
<BuildActionEntry
buildForTesting = "YES"
buildForRunning = "YES"
buildForProfiling = "YES"
buildForArchiving = "YES"
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "93011B4D207F9CD50011BE1B"
BuildableName = "AzureMobile.framework"
BlueprintName = "AzureMobile tvOS"
ReferencedContainer = "container:AzureMobile.xcodeproj">
</BuildableReference>
</BuildActionEntry>
</BuildActionEntries>
</BuildAction>
<TestAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES">
<Testables>
<TestableReference
skipped = "NO">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "93011B55207F9CD50011BE1B"
BuildableName = "AzureMobile tvOS Tests.xctest"
BlueprintName = "AzureMobile tvOS Tests"
ReferencedContainer = "container:AzureMobile.xcodeproj">
</BuildableReference>
</TestableReference>
</Testables>
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "93011B4D207F9CD50011BE1B"
BuildableName = "AzureMobile.framework"
BlueprintName = "AzureMobile tvOS"
ReferencedContainer = "container:AzureMobile.xcodeproj">
</BuildableReference>
</MacroExpansion>
<AdditionalOptions>
</AdditionalOptions>
</TestAction>
<LaunchAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
launchStyle = "0"
useCustomWorkingDirectory = "NO"
ignoresPersistentStateOnLaunch = "NO"
debugDocumentVersioning = "YES"
debugServiceExtension = "internal"
allowLocationSimulation = "YES">
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "93011B4D207F9CD50011BE1B"
BuildableName = "AzureMobile.framework"
BlueprintName = "AzureMobile tvOS"
ReferencedContainer = "container:AzureMobile.xcodeproj">
</BuildableReference>
</MacroExpansion>
<AdditionalOptions>
</AdditionalOptions>
</LaunchAction>
<ProfileAction
buildConfiguration = "Release"
shouldUseLaunchSchemeArgsEnv = "YES"
savedToolIdentifier = ""
useCustomWorkingDirectory = "NO"
debugDocumentVersioning = "YES">
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "93011B4D207F9CD50011BE1B"
BuildableName = "AzureMobile.framework"
BlueprintName = "AzureMobile tvOS"
ReferencedContainer = "container:AzureMobile.xcodeproj">
</BuildableReference>
</MacroExpansion>
</ProfileAction>
<AnalyzeAction
buildConfiguration = "Debug">
</AnalyzeAction>
<ArchiveAction
buildConfiguration = "Release"
revealArchiveInOrganizer = "YES">
</ArchiveAction>
</Scheme>

Просмотреть файл

@ -0,0 +1,80 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0930"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
buildImplicitDependencies = "YES">
<BuildActionEntries>
<BuildActionEntry
buildForTesting = "YES"
buildForRunning = "YES"
buildForProfiling = "YES"
buildForArchiving = "YES"
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "93011B69207F9CF50011BE1B"
BuildableName = "AzureMobile.framework"
BlueprintName = "AzureMobile watchOS"
ReferencedContainer = "container:AzureMobile.xcodeproj">
</BuildableReference>
</BuildActionEntry>
</BuildActionEntries>
</BuildAction>
<TestAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES">
<Testables>
</Testables>
<AdditionalOptions>
</AdditionalOptions>
</TestAction>
<LaunchAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
launchStyle = "0"
useCustomWorkingDirectory = "NO"
ignoresPersistentStateOnLaunch = "NO"
debugDocumentVersioning = "YES"
debugServiceExtension = "internal"
allowLocationSimulation = "YES">
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "93011B69207F9CF50011BE1B"
BuildableName = "AzureMobile.framework"
BlueprintName = "AzureMobile watchOS"
ReferencedContainer = "container:AzureMobile.xcodeproj">
</BuildableReference>
</MacroExpansion>
<AdditionalOptions>
</AdditionalOptions>
</LaunchAction>
<ProfileAction
buildConfiguration = "Release"
shouldUseLaunchSchemeArgsEnv = "YES"
savedToolIdentifier = ""
useCustomWorkingDirectory = "NO"
debugDocumentVersioning = "YES">
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "93011B69207F9CF50011BE1B"
BuildableName = "AzureMobile.framework"
BlueprintName = "AzureMobile watchOS"
ReferencedContainer = "container:AzureMobile.xcodeproj">
</BuildableReference>
</MacroExpansion>
</ProfileAction>
<AnalyzeAction
buildConfiguration = "Debug">
</AnalyzeAction>
<ArchiveAction
buildConfiguration = "Release"
revealArchiveInOrganizer = "YES">
</ArchiveAction>
</Scheme>

Просмотреть файл

@ -0,0 +1,34 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>SchemeUserState</key>
<dict>
<key>AzureMobile iOS.xcscheme_^#shared#^_</key>
<dict>
<key>orderHint</key>
<integer>0</integer>
</dict>
<key>AzureMobile macOS.xcscheme_^#shared#^_</key>
<dict>
<key>orderHint</key>
<integer>1</integer>
</dict>
<key>AzureMobile tvOS.xcscheme_^#shared#^_</key>
<dict>
<key>orderHint</key>
<integer>2</integer>
</dict>
<key>AzureMobile watchOS.xcscheme_^#shared#^_</key>
<dict>
<key>orderHint</key>
<integer>3</integer>
</dict>
<key>AzureMobile.xcscheme</key>
<dict>
<key>orderHint</key>
<integer>0</integer>
</dict>
</dict>
</dict>
</plist>

3
iOS/AzureMobile/Cartfile Normal file
Просмотреть файл

@ -0,0 +1,3 @@
github "Nike-Inc/Willow" ~> 5.0
github "kishikawakatsumi/KeychainAccess" ~> 3.1
github "Azure/Azure.iOS"

Просмотреть файл

@ -0,0 +1,3 @@
github "Azure/Azure.iOS" "v0.0.2"
github "Nike-Inc/Willow" "5.0.2"
github "kishikawakatsumi/KeychainAccess" "v3.1.1"

Просмотреть файл

@ -0,0 +1,13 @@
//
// AzureMobile.h
// AzureMobile
//
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
//
@import Foundation;
FOUNDATION_EXPORT double AzureMobileVersionNumber;
FOUNDATION_EXPORT const unsigned char AzureMobileVersionString[];

Просмотреть файл

@ -0,0 +1,98 @@
//
// DefaultPermissionProvider.swift
// AzureMobile
//
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
//
import Foundation
import AzureData
public struct PermissionRequest : Codable {
let databaseId: String
let collectionId: String
let documentId: String?
let tokenDuration: Int
let permissionMode: PermissionMode
}
public class DefaultPermissionProvider : PermissionProvider {
let baseUrl: URL
let session: URLSession
lazy var encoder: JSONEncoder = getPermissionEncoder()
lazy var decoder: JSONDecoder = getPermissionDecoder()
public var configuration: PermissionProviderConfiguration!
public init (withBaseUrl url: URL, providerConfiguration: PermissionProviderConfiguration = PermissionProviderConfiguration.default, sessionConfiguration: URLSessionConfiguration = URLSessionConfiguration.default) {
baseUrl = url
configuration = providerConfiguration
session = URLSession(configuration: sessionConfiguration)
}
public func getPermission(forCollectionWithId collectionId: String, inDatabase databaseId: String, withPermissionMode mode: PermissionMode, completion: @escaping (Response<Permission>) -> Void) {
let permissionRequest = PermissionRequest(databaseId: databaseId, collectionId: collectionId, documentId: nil, tokenDuration: Int(configuration.defaultTokenDuration), permissionMode: mode)
let url = baseUrl.appendingPathComponent("api/data/permission")
var request = URLRequest(url: url)
request.httpMethod = "POST"
request.addValue("application/json", forHTTPHeaderField: "Content-Type")
do {
request.httpBody = try encoder.encode(permissionRequest)
} catch {
completion(Response(PermissionProviderError.getPermissionFailed)); return;
}
session.dataTask(with: request) { (data, response, error) in
let httpResponse = response as? HTTPURLResponse
if let error = error {
completion(Response(request: request, data: data, response: httpResponse, result: .failure(error)))
} else if let data = data {
//Log.debugMessage(String(data: data, encoding: .utf8) ?? "fail")
do {
let permission = try self.decoder.decode(Permission.self, from: data)
completion(Response(request: request, data: data, response: httpResponse, result: .success(permission)))
} catch {
completion(Response(request: request, data: data, response: httpResponse, result: .failure(error))); return;
}
} else {
completion(Response(request: request, data: data, response: httpResponse, result: .failure(DocumentClientError(withKind: .unknownError)))); return;
}
}.resume()
}
public func getPermission(forDocumentWithId documentId: String, inCollection collectionId: String, inDatabase databaseId: String, withPermissionMode mode: PermissionMode, completion: @escaping (Response<Permission>) -> Void) {}
public func getPermission(forAttachmentsWithId attachmentId: String, onDocument documentId: String, inCollection collectionId: String, inDatabase databaseId: String, withPermissionMode mode: PermissionMode, completion: @escaping (Response<Permission>) -> Void) {}
public func getPermission(forStoredProcedureWithId storedProcedureId: String, inCollection collectionId: String, inDatabase databaseId: String, withPermissionMode mode: PermissionMode, completion: @escaping (Response<Permission>) -> Void) {}
public func getPermission(forUserDefinedFunctionWithId functionId: String, inCollection collectionId: String, inDatabase databaseId: String, withPermissionMode mode: PermissionMode, completion: @escaping (Response<Permission>) -> Void) {}
public func getPermission(forTriggerWithId triggerId: String, inCollection collectionId: String, inDatabase databaseId: String, withPermissionMode mode: PermissionMode, completion: @escaping (Response<Permission>) -> Void) {}
}

Просмотреть файл

@ -0,0 +1,24 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>$(DEVELOPMENT_LANGUAGE)</string>
<key>CFBundleExecutable</key>
<string>$(EXECUTABLE_NAME)</string>
<key>CFBundleIdentifier</key>
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>$(PRODUCT_NAME)</string>
<key>CFBundlePackageType</key>
<string>FMWK</string>
<key>CFBundleShortVersionString</key>
<string>0.0.2</string>
<key>CFBundleVersion</key>
<string>$(CURRENT_PROJECT_VERSION)</string>
<key>NSPrincipalClass</key>
<string></string>
</dict>
</plist>

Просмотреть файл

@ -0,0 +1,129 @@
//
// DefaultPermissionProviderTests.swift
// AzureMobile
//
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
//
import XCTest
import AzureData
@testable import AzureMobile
class DefaultPermissionProviderTests: XCTestCase {
let timeout: TimeInterval = 30.0
lazy var createExpectation = self.expectation(description: "should create and return colleciton")
lazy var listExpectation = self.expectation(description: "should return a list of colleciton")
lazy var getExpectation = self.expectation(description: "should get and return colleciton")
lazy var getDocExpectation = self.expectation(description: "should get and return document")
lazy var deleteExpectation = self.expectation(description: "should delete colleciton")
lazy var queryExpectation = self.expectation(description: "should query colleciton")
lazy var replaceExpectation = self.expectation(description: "should replace colleciton")
lazy var refreshExpectation = self.expectation(description: "should refresh colleciton")
fileprivate(set) var collection:DocumentCollection?
let customStringKey = "customStringKey"
let customStringValue = "customStringValue"
let customNumberKey = "customNumberKey"
let customNumberValue = 86
var functionUrl: URL? // = your function app url
var databaseName: String? // = your database name
override func setUp() {
super.setUp()
if let dbname = databaseName, !dbname.isEmpty, let baseUrl = functionUrl {
AzureData.configure(forAccountNamed: dbname, withPermissionProvider: DefaultPermissionProvider(withBaseUrl: baseUrl))
}
}
override func tearDown() {
// Put teardown code here. This method is called after the invocation of each test method in the class.
super.tearDown()
}
func testExample() {
if let dbname = databaseName, !dbname.isEmpty {
var getResponse: Response<DictionaryDocument>?
var listResponse: Response<Resources<DictionaryDocument>>?
var createResponse: Response<DictionaryDocument>?
var deleteResponse: Response<Data>?
AzureData.get(collectionWithId: "MyCollectionFive", inDatabase: "MyDatabaseFive") { r in
self.collection = r.resource
self.getExpectation.fulfill()
}
wait(for: [getExpectation], timeout: timeout)
XCTAssertNotNil(collection)
if let collection = collection {
let newDocument = DictionaryDocument("MyDocument")
newDocument[customStringKey] = customStringValue
newDocument[customNumberKey] = customNumberValue
collection.create(newDocument) { r in
createResponse = r
self.createExpectation.fulfill()
}
wait(for: [createExpectation], timeout: timeout)
XCTAssertNotNil(createResponse?.resource)
collection.get(documentsAs: DictionaryDocument.self) { r in
listResponse = r
self.listExpectation.fulfill()
}
wait(for: [listExpectation], timeout: timeout)
XCTAssertNotNil(listResponse?.resource)
collection.get(documentWithResourceId: newDocument.id, as: DictionaryDocument.self) { r in
getResponse = r
self.getDocExpectation.fulfill()
}
wait(for: [getDocExpectation], timeout: timeout)
XCTAssertNotNil(getResponse?.resource)
if let doc = getResponse?.resource ?? createResponse?.resource {
collection.delete(doc) { r in
deleteResponse = r
self.deleteExpectation.fulfill()
}
wait(for: [deleteExpectation], timeout: timeout)
}
XCTAssert(deleteResponse?.result.isSuccess ?? false)
}
}
}
func testPerformanceExample() {
// This is an example of a performance test case.
self.measure {
// Put the code you want to measure the time of here.
}
}
}

Просмотреть файл

@ -0,0 +1,22 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>$(DEVELOPMENT_LANGUAGE)</string>
<key>CFBundleExecutable</key>
<string>$(EXECUTABLE_NAME)</string>
<key>CFBundleIdentifier</key>
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>$(PRODUCT_NAME)</string>
<key>CFBundlePackageType</key>
<string>BNDL</string>
<key>CFBundleShortVersionString</key>
<string>1.0</string>
<key>CFBundleVersion</key>
<string>1</string>
</dict>
</plist>