Skip to content

Commit

Permalink
Migrates to Swift 4
Browse files Browse the repository at this point in the history
  • Loading branch information
Aaron Liberatore authored and Aaron Liberatore committed Oct 27, 2017
1 parent 232462d commit 0d67b58
Show file tree
Hide file tree
Showing 54 changed files with 3,917 additions and 987 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ Kitura-Credentials.xcodeproj
Packages
.build
build

Package.resolved
2 changes: 1 addition & 1 deletion .swift-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
3.1.1
4.0
8 changes: 0 additions & 8 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,9 @@ matrix:
- os: linux
dist: trusty
sudo: required
- os: linux
dist: trusty
sudo: required
env: SWIFT_SNAPSHOT=$SWIFT_4_DEV_SNAPSHOT
- os: osx
osx_image: xcode8.3
sudo: required
- os: osx
osx_image: xcode9
sudo: required
env: SWIFT_SNAPSHOT=$SWIFT_4_DEV_SNAPSHOT

before_install:
- git clone https://github.com/IBM-Swift/Package-Builder.git
Expand Down
7 changes: 0 additions & 7 deletions Package.pins

This file was deleted.

29 changes: 26 additions & 3 deletions Package.swift
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
// swift-tools-version:4.0
// The swift-tools-version declares the minimum version of Swift required to build this package.

/**
* Copyright IBM Corporation 2016, 2017
* Copyright IBM Corporation 2017
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -18,8 +21,28 @@ import PackageDescription

let package = Package(
name: "Kitura-Credentials",
products: [
// Products define the executables and libraries produced by a package, and make them visible to other packages.
.library(
name: "Credentials",
targets: ["Credentials"]
)
],
dependencies: [
.Package(url: "https://github.com/IBM-Swift/Kitura.git", majorVersion: 1, minor: 7),
.Package(url: "https://github.com/IBM-Swift/Kitura-Session.git", majorVersion: 1, minor: 7)
.package(url: "https://github.com/IBM-Swift/Kitura.git", .upToNextMinor(from: "2.0.0")),
.package(url: "https://github.com/IBM-Swift/Kitura-Session.git", .upToNextMinor(from: "2.0.0")),
.package(url: "https://github.com/IBM-Swift/SwiftyJSON.git", .upToNextMajor(from: "17.0.0")),
],
targets: [
// Targets are the basic building blocks of a package. A target can define a module or a test suite.
// Targets can depend on other targets in this package, and on products in packages which this package depends on.
.target(
name: "Credentials",
dependencies: ["Kitura", "KituraSession", "SwiftyJSON"]
),
.testTarget(
name: "CredentialsTests",
dependencies: ["Credentials", "SwiftyJSON"]
)
]
)
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ In the scope of OAuth2 Authorization Code flow, authentication is performed by a
* [License](#license)

## Swift version
The latest version of Kitura-Credentials requires **Swift 3.0**. You can download this version of the Swift binaries by following this [link](https://swift.org/download/). Compatibility with other Swift versions is not guaranteed.
The latest version of Kitura-Credentials requires **Swift 4.0**. You can download this version of the Swift binaries by following this [link](https://swift.org/download/). Compatibility with other Swift versions is not guaranteed.


## Example
Expand Down
18 changes: 3 additions & 15 deletions Sources/Credentials/Credentials.swift
Original file line number Diff line number Diff line change
Expand Up @@ -192,11 +192,7 @@ public class Credentials : RouterMiddleware {
try response.redirect(redirect)
}
catch {
#if os(Linux)
response.error = NSError(domain: "Credentials", code: 1, userInfo: [NSLocalizedDescriptionKey:"Failed to redirect unauthorized request"])
#else
response.error = NSError(domain: "Credentials", code: 1, userInfo: [NSLocalizedDescriptionKey as NSString:"Failed to redirect unauthorized request"])
#endif
response.error = NSError(domain: "Credentials", code: 1, userInfo: [NSLocalizedDescriptionKey: "Failed to redirect unauthorized request"])
}
}
else {
Expand All @@ -222,11 +218,7 @@ public class Credentials : RouterMiddleware {
try response.redirect(redirect)
}
catch {
#if os(Linux)
response.error = NSError(domain: "Credentials", code: 1, userInfo: [NSLocalizedDescriptionKey:"Failed to redirect successfuly authorized request"])
#else
response.error = NSError(domain: "Credentials", code: 1, userInfo: [NSLocalizedDescriptionKey as NSString:"Failed to redirect successfuly authorized request"])
#endif
response.error = NSError(domain: "Credentials", code: 1, userInfo: [NSLocalizedDescriptionKey: "Failed to redirect successfuly authorized request"])
}
}
}
Expand Down Expand Up @@ -279,11 +271,7 @@ public class Credentials : RouterMiddleware {
else {
let error = "The server was not configured properly: no session found for redirecting authentication"
Log.error(error)
#if os(Linux)
response.error = NSError(domain: "Credentials", code: 1, userInfo: [NSLocalizedDescriptionKey: error])
#else
response.error = NSError(domain: "Credentials", code: 1, userInfo: [NSLocalizedDescriptionKey as NSString: error])
#endif
response.error = NSError(domain: "Credentials", code: 1, userInfo: [NSLocalizedDescriptionKey: error])
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion Tests/CredentialsTests/CredentialsTest.swift
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ extension CredentialsTest {
// sleep(10)
}

func performServerTest(router: ServerDelegate, asyncTasks: @escaping (XCTestExpectation) -> Void...) {
func performServerTest(router: ServerDelegate, asyncTasks: (XCTestExpectation) -> Void...) {
do {
let server = try HTTPServer.listen(on: 8090, delegate: router)
let requestQueue = DispatchQueue(label: "Request queue")
Expand Down
5 changes: 5 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
test:
image: ibmcom/swift-ubuntu:4.0
volumes:
- .:/Kitura-Credentials
command: bash -c "cd /Kitura-Credentials && swift package clean && swift build && swift test"
25 changes: 17 additions & 8 deletions docs/Classes.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@
<script src="js/jquery.min.js" defer></script>
<script src="js/jazzy.js" defer></script>

<script src="js/lunr.min.js" defer></script>
<script src="js/typeahead.jquery.js" defer></script>
<script src="js/jazzy.search.js" defer></script>
</head>
<body>

Expand All @@ -22,6 +25,12 @@
(100% documented)
</p>

<p class="header-col--secondary">
<form role="search" action="search.json">
<input type="text" placeholder="Search documentation" data-typeahead>
</form>
</p>

<p class="header-col header-col--secondary">
<a class="header-link" href="https://github.com/IBM-Swift/Kitura-Credentials/">
<img class="header-icon" src="img/gh.png"/>
Expand Down Expand Up @@ -101,9 +110,9 @@ <h1>Classes</h1>
<li class="item">
<div>
<code>
<a name="/s:C11Credentials16BaseCacheElement"></a>
<a name="/s:11Credentials16BaseCacheElementC"></a>
<a name="//apple_ref/swift/Class/BaseCacheElement" class="dashAnchor"></a>
<a class="token" href="#/s:C11Credentials16BaseCacheElement">BaseCacheElement</a>
<a class="token" href="#/s:11Credentials16BaseCacheElementC">BaseCacheElement</a>
</code>
</div>
<div class="height-container">
Expand Down Expand Up @@ -133,9 +142,9 @@ <h4>Declaration</h4>
<li class="item">
<div>
<code>
<a name="/s:C11Credentials11Credentials"></a>
<a name="/s:11CredentialsAAC"></a>
<a name="//apple_ref/swift/Class/Credentials" class="dashAnchor"></a>
<a class="token" href="#/s:C11Credentials11Credentials">Credentials</a>
<a class="token" href="#/s:11CredentialsAAC">Credentials</a>
</code>
</div>
<div class="height-container">
Expand Down Expand Up @@ -165,9 +174,9 @@ <h4>Declaration</h4>
<li class="item">
<div>
<code>
<a name="/s:C11Credentials11UserProfile"></a>
<a name="/s:11Credentials11UserProfileC"></a>
<a name="//apple_ref/swift/Class/UserProfile" class="dashAnchor"></a>
<a class="token" href="#/s:C11Credentials11UserProfile">UserProfile</a>
<a class="token" href="#/s:11Credentials11UserProfileC">UserProfile</a>
</code>
</div>
<div class="height-container">
Expand Down Expand Up @@ -199,8 +208,8 @@ <h4>Declaration</h4>
</article>
</div>
<section class="footer">
<p>&copy; 2017 <a class="link" href="" target="_blank" rel="external">IBM</a>. All rights reserved. (Last updated: 2017-04-26)</p>
<p>Generated by <a class="link" href="https://github.com/realm/jazzy" target="_blank" rel="external">jazzy ♪♫ v0.7.0</a>, a <a class="link" href="http://realm.io" target="_blank" rel="external">Realm</a> project.</p>
<p>&copy; 2017 <a class="link" href="" target="_blank" rel="external">IBM</a>. All rights reserved. (Last updated: 2017-10-27)</p>
<p>Generated by <a class="link" href="https://github.com/realm/jazzy" target="_blank" rel="external">jazzy ♪♫ v0.8.4</a>, a <a class="link" href="http://realm.io" target="_blank" rel="external">Realm</a> project.</p>
</section>
</body>
</div>
Expand Down
30 changes: 16 additions & 14 deletions docs/Classes/BaseCacheElement.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@
<script src="../js/jquery.min.js" defer></script>
<script src="../js/jazzy.js" defer></script>

<script src="../js/lunr.min.js" defer></script>
<script src="../js/typeahead.jquery.js" defer></script>
<script src="../js/jazzy.search.js" defer></script>
</head>
<body>

Expand All @@ -23,6 +26,12 @@
(100% documented)
</p>

<p class="header-col--secondary">
<form role="search" action="../search.json">
<input type="text" placeholder="Search documentation" data-typeahead>
</form>
</p>

<p class="header-col header-col--secondary">
<a class="header-link" href="https://github.com/IBM-Swift/Kitura-Credentials/">
<img class="header-icon" src="../img/gh.png"/>
Expand Down Expand Up @@ -108,9 +117,9 @@ <h1>BaseCacheElement</h1>
<li class="item">
<div>
<code>
<a name="/s:vC11Credentials16BaseCacheElement11userProfileCS_11UserProfile"></a>
<a name="/s:11Credentials16BaseCacheElementC11userProfileAA04UserF0Cv"></a>
<a name="//apple_ref/swift/Property/userProfile" class="dashAnchor"></a>
<a class="token" href="#/s:vC11Credentials16BaseCacheElement11userProfileCS_11UserProfile">userProfile</a>
<a class="token" href="#/s:11Credentials16BaseCacheElementC11userProfileAA04UserF0Cv">userProfile</a>
</code>
</div>
<div class="height-container">
Expand All @@ -135,9 +144,9 @@ <h4>Declaration</h4>
<li class="item">
<div>
<code>
<a name="/s:FC11Credentials16BaseCacheElementcFT7profileCS_11UserProfile_S0_"></a>
<a name="/s:11Credentials16BaseCacheElementCAcA11UserProfileC7profile_tcfc"></a>
<a name="//apple_ref/swift/Method/init(profile:)" class="dashAnchor"></a>
<a class="token" href="#/s:FC11Credentials16BaseCacheElementcFT7profileCS_11UserProfile_S0_">init(profile:)</a>
<a class="token" href="#/s:11Credentials16BaseCacheElementCAcA11UserProfileC7profile_tcfc">init(profile:)</a>
</code>
</div>
<div class="height-container">
Expand All @@ -147,12 +156,6 @@ <h4>Declaration</h4>
<div class="abstract">
<p>Initialize a <code>BaseCacheElement</code>.</p>

<div class="aside aside-parameter">
<p class="aside-title">Parameter</p>
Parameter profile: the <code><a href="../Classes/UserProfile.html">UserProfile</a></code> to store.

</div>

</div>
<div class="declaration">
<h4>Declaration</h4>
Expand All @@ -174,8 +177,7 @@ <h4>Parameters</h4>
</td>
<td>
<div>
<p>the <code>UserProfile</code> to store.</p>

<p>the <code><a href="../Classes/UserProfile.html">UserProfile</a></code> to store.</p>
</div>
</td>
</tr>
Expand All @@ -193,8 +195,8 @@ <h4>Parameters</h4>
</article>
</div>
<section class="footer">
<p>&copy; 2017 <a class="link" href="" target="_blank" rel="external">IBM</a>. All rights reserved. (Last updated: 2017-04-26)</p>
<p>Generated by <a class="link" href="https://github.com/realm/jazzy" target="_blank" rel="external">jazzy ♪♫ v0.7.0</a>, a <a class="link" href="http://realm.io" target="_blank" rel="external">Realm</a> project.</p>
<p>&copy; 2017 <a class="link" href="" target="_blank" rel="external">IBM</a>. All rights reserved. (Last updated: 2017-10-27)</p>
<p>Generated by <a class="link" href="https://github.com/realm/jazzy" target="_blank" rel="external">jazzy ♪♫ v0.8.4</a>, a <a class="link" href="http://realm.io" target="_blank" rel="external">Realm</a> project.</p>
</section>
</body>
</div>
Expand Down
Loading

0 comments on commit 0d67b58

Please sign in to comment.