From ac651bb885c7989823c9d4ad32b961043e8061bd Mon Sep 17 00:00:00 2001 From: Gwynne Raskind Date: Wed, 1 Dec 2021 19:16:42 -0600 Subject: [PATCH] Additional package infrastructure work (#6) * Add SPDX license header to all source files. Also remove many many unnecessary instances of "import Foundation" * Add updating of OS packages to Dockerfile * Add soundness check and API breakage check scripts. * Retool soundness script to do fancy rules-based stuff for license header checks, because why the heck not * Make GH Actions workflow do tests and such * Include derivation notice and derivation source license headers as required by Apache 2.0. * Specify sufficiently new macOS runner, disable tests on Linux for now due to XCTest lacking async support * add missing workaround for XCTest brokenness annoyances * Enable back-deployment for concurrency, hopefully. * Fix percent encoding handling of filter strings correctly by adding workaround implementation of `URLComponents.percentEncodedQueryItems` where it's needed. * Add workaround to the async test method so the tests can run on Linux, and reenable Linux testing. --- .github/workflows/linux.yml | 13 -- .github/workflows/test.yml | 43 ++++++ Dockerfile | 25 +++- LICENSE => LICENSE.txt | 0 NOTICE.txt | 27 ++++ Package.swift | 17 ++- .../Client/Application+OneRosterClient.swift | 13 +- Sources/OneRoster/Client/OAuth1.swift | 12 +- Sources/OneRoster/Client/OAuth2.swift | 12 +- Sources/OneRoster/Client/OneRosterAPI.swift | 12 +- .../OneRoster/Client/OneRosterClient.swift | 45 +++++- .../Client/Request+OneRosterClient.swift | 13 +- .../OneRoster/Enumerations/ClassType.swift | 15 +- Sources/OneRoster/Enumerations/GUIDType.swift | 15 +- Sources/OneRoster/Enumerations/Gender.swift | 15 +- Sources/OneRoster/Enumerations/Grade.swift | 14 +- .../OneRoster/Enumerations/Importance.swift | 15 +- Sources/OneRoster/Enumerations/OrgType.swift | 14 +- .../Enumerations/ResidenceStatus.swift | 18 ++- Sources/OneRoster/Enumerations/RoleType.swift | 14 +- .../OneRoster/Enumerations/ScoreStatus.swift | 14 +- .../OneRoster/Enumerations/SessionType.swift | 14 +- .../OneRoster/Enumerations/StateCode.swift | 14 +- .../OneRoster/Enumerations/StatusType.swift | 14 +- .../OneRoster/Models/AcademicSession.swift | 14 +- Sources/OneRoster/Models/Class.swift | 14 +- Sources/OneRoster/Models/Course.swift | 14 +- .../OneRoster/Models/DemographicData.swift | 14 +- Sources/OneRoster/Models/Enrollment.swift | 14 +- Sources/OneRoster/Models/LineItem.swift | 14 +- .../OneRoster/Models/LineItemCategory.swift | 14 +- Sources/OneRoster/Models/Org.swift | 14 +- Sources/OneRoster/Models/Resource.swift | 14 +- Sources/OneRoster/Models/Result.swift | 14 +- Sources/OneRoster/Models/User.swift | 14 +- Sources/OneRoster/Partials/GUIDRef.swift | 14 +- .../OneRoster/Partials/OneRosterError.swift | 14 +- .../OneRoster/Partials/StringyBoolean.swift | 14 +- Sources/OneRoster/Partials/UserId.swift | 14 +- .../OneRoster/Protocols/OneRosterBase.swift | 14 +- .../Protocols/OneRosterResponse.swift | 14 +- .../OneRoster/Responses/ClassesResponse.swift | 14 +- .../OneRoster/Responses/CoursesResponse.swift | 14 +- .../Responses/DemographicResponse.swift | 14 +- .../Responses/DemographicsResponse.swift | 14 +- .../Responses/EnrollmentResponse.swift | 14 +- .../Responses/EnrollmentsResponse.swift | 14 +- Sources/OneRoster/Responses/OrgResponse.swift | 14 +- .../OneRoster/Responses/OrgsResponse.swift | 14 +- .../OneRoster/Responses/SchoolResponse.swift | 14 +- .../OneRoster/Responses/SchoolsResponse.swift | 14 +- .../OneRoster/Responses/StudentResponse.swift | 14 +- .../Responses/StudentsForSchoolResponse.swift | 14 +- .../Responses/StudentsResponse.swift | 14 +- .../OneRoster/Responses/TeacherResponse.swift | 14 +- .../Responses/TeachersForSchoolResponse.swift | 14 +- .../Responses/TeachersResponse.swift | 14 +- .../OneRoster/Responses/UserResponse.swift | 14 +- .../OneRoster/Responses/UsersResponse.swift | 14 +- Tests/OneRosterTests/OneRosterTests.swift | 18 ++- scripts/check_no_api_breakages.sh | 138 ++++++++++++++++++ scripts/soundness.sh | 87 +++++++++++ scripts/spdx_header_rules.json | 57 ++++++++ 63 files changed, 915 insertions(+), 283 deletions(-) delete mode 100644 .github/workflows/linux.yml create mode 100644 .github/workflows/test.yml rename LICENSE => LICENSE.txt (100%) create mode 100644 NOTICE.txt create mode 100755 scripts/check_no_api_breakages.sh create mode 100755 scripts/soundness.sh create mode 100755 scripts/spdx_header_rules.json diff --git a/.github/workflows/linux.yml b/.github/workflows/linux.yml deleted file mode 100644 index 483e74b..0000000 --- a/.github/workflows/linux.yml +++ /dev/null @@ -1,13 +0,0 @@ -name: test -on: { pull_request: {} } - -jobs: - test-queues: - runs-on: ubuntu-latest - container: swift:5.5.1-focal - steps: - - name: Check out - uses: actions/checkout@v2 - - name: Build - timeout-minutes: 30 - run: swift build -c release \ No newline at end of file diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 0000000..ed1814e --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,43 @@ +name: test +on: + pull_request: + +jobs: + linux: + runs-on: ubuntu-latest + container: swift:5.5-focal + steps: + - name: Check out code + uses: actions/checkout@v2 + - name: Run tests with Thread Sanitizer + run: swift test --enable-test-discovery --sanitize=thread + - name: Verify release build + timeout-minutes: 30 + run: swift build -c release + + macos: + runs-on: macos-11 + steps: + - name: Select latest available Xcode + uses: maxim-lobanov/setup-xcode@v1 + with: + xcode-version: latest + - name: Check out code + uses: actions/checkout@v2 + - name: Run tests + timeout-minutes: 30 + run: | + swift test -Xlinker -rpath \ + -Xlinker $(xcode-select -p)/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift-5.5/macosx + +# windows: +# runs-on: windows-latest +# steps: +# - uses: compnerd/gha-setup-swift@main +# with: +# branch: swift-5.5-release +# tag: 5.5-RELEASE +# - name: Check out code +# uses: actions/checkout@v2 +# - name: Run tests +# run: swift test diff --git a/Dockerfile b/Dockerfile index 2496958..07bbd5b 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,6 +1,27 @@ +##===----------------------------------------------------------------------===## +## +## This source file is part of the OneRoster open source project +## +## Copyright (c) 2021 the OneRoster project authors +## Licensed under Apache License v2.0 +## +## See LICENSE.txt for license information +## +## SPDX-License-Identifier: Apache-2.0 +## +##===----------------------------------------------------------------------===## + # Build image # ================================ -FROM swift:5.5.1-focal as build +FROM swift:5.5-focal as build + +# Install OS updates +RUN export DEBIAN_FRONTEND=noninteractive DEBCONF_NONINTERACTIVE_SEEN=true \ + && apt-get -q update \ + && apt-get -q dist-upgrade -y \ + && rm -rf /var/lib/apt/lists/* + +# Set up a build area WORKDIR /build # First just resolve dependencies. @@ -14,4 +35,4 @@ RUN swift package resolve COPY . . # Compile with optimizations -RUN swift build -c release \ No newline at end of file +RUN swift build -c release diff --git a/LICENSE b/LICENSE.txt similarity index 100% rename from LICENSE rename to LICENSE.txt diff --git a/NOTICE.txt b/NOTICE.txt new file mode 100644 index 0000000..a1b4e9b --- /dev/null +++ b/NOTICE.txt @@ -0,0 +1,27 @@ + + The Swift OneRoster Client Project + ================================== + +Copyright The Swift OneRoster Client Project + +The Swift OneRoster Client Project licenses this file to you under the +Apache License, version 2.0 (the "License"); you may not use this file +except in compliance with the License. You may obtain a copy of the +License at: + + https://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +License for the specific language governing permissions and limitations +under the License. + +------------------------------------------------------------------------------- + +This product contains a derivation of various scripts from SwiftNIO. + + * LICENSE (Apache License 2.0): + * https://www.apache.org/licenses/LICENSE-2.0 + * HOMEPAGE: + * https://github.com/apple/swift-nio diff --git a/Package.swift b/Package.swift index 3c42dc4..c87b6b3 100644 --- a/Package.swift +++ b/Package.swift @@ -1,10 +1,23 @@ // swift-tools-version:5.5 +//===----------------------------------------------------------------------===// +// +// This source file is part of the OneRoster open source project +// +// Copyright (c) 2021 the OneRoster project authors +// Licensed under Apache License v2.0 +// +// See LICENSE.txt for license information +// +// SPDX-License-Identifier: Apache-2.0 +// +//===----------------------------------------------------------------------===// + import PackageDescription let package = Package( name: "OneRoster", platforms: [ - .macOS(.v12) + .macOS(.v11), ], products: [ .library(name: "OneRoster", targets: ["OneRoster"]), @@ -21,6 +34,6 @@ let package = Package( .testTarget(name: "OneRosterTests", dependencies: [ .target(name: "OneRoster"), .product(name: "XCTVapor", package: "vapor"), - ]) + ]), ] ) diff --git a/Sources/OneRoster/Client/Application+OneRosterClient.swift b/Sources/OneRoster/Client/Application+OneRosterClient.swift index 92998bd..e76cf51 100644 --- a/Sources/OneRoster/Client/Application+OneRosterClient.swift +++ b/Sources/OneRoster/Client/Application+OneRosterClient.swift @@ -1,13 +1,20 @@ +//===----------------------------------------------------------------------===// // -// Application+OneRosterClient.swift -// OneRoster +// This source file is part of the OneRoster open source project // -// Created by Jimmy McDermott on 4/10/20. +// Copyright (c) 2021 the OneRoster project authors +// Licensed under Apache License v2.0 // +// See LICENSE.txt for license information +// +// SPDX-License-Identifier: Apache-2.0 +// +//===----------------------------------------------------------------------===// import Foundation import Vapor +@available(macOS 12, iOS 15, tvOS 15, watchOS 8, *) extension Application { /// Get a `OneRosterClient` suitable for making OneRoster requests to the given base URL without authentication. /// diff --git a/Sources/OneRoster/Client/OAuth1.swift b/Sources/OneRoster/Client/OAuth1.swift index 56a35a3..92483bc 100644 --- a/Sources/OneRoster/Client/OAuth1.swift +++ b/Sources/OneRoster/Client/OAuth1.swift @@ -1,9 +1,15 @@ +//===----------------------------------------------------------------------===// // -// OAuth1.swift -// OneRoster +// This source file is part of the OneRoster open source project // -// Copyright Slate Solutions, Inc 2021. +// Copyright (c) 2021 the OneRoster project authors +// Licensed under Apache License v2.0 // +// See LICENSE.txt for license information +// +// SPDX-License-Identifier: Apache-2.0 +// +//===----------------------------------------------------------------------===// import Foundation import Vapor diff --git a/Sources/OneRoster/Client/OAuth2.swift b/Sources/OneRoster/Client/OAuth2.swift index 08659f2..1da8a17 100644 --- a/Sources/OneRoster/Client/OAuth2.swift +++ b/Sources/OneRoster/Client/OAuth2.swift @@ -1,9 +1,15 @@ +//===----------------------------------------------------------------------===// // -// OAuth2.swift -// OneRoster +// This source file is part of the OneRoster open source project // -// Copyright Slate Solutions, Inc 2021. +// Copyright (c) 2021 the OneRoster project authors +// Licensed under Apache License v2.0 // +// See LICENSE.txt for license information +// +// SPDX-License-Identifier: Apache-2.0 +// +//===----------------------------------------------------------------------===// import Foundation import Vapor diff --git a/Sources/OneRoster/Client/OneRosterAPI.swift b/Sources/OneRoster/Client/OneRosterAPI.swift index 35491f9..c63f9c3 100644 --- a/Sources/OneRoster/Client/OneRosterAPI.swift +++ b/Sources/OneRoster/Client/OneRosterAPI.swift @@ -1,9 +1,15 @@ +//===----------------------------------------------------------------------===// // -// OneRosterAPI.swift -// OneRoster +// This source file is part of the OneRoster open source project // -// Copyright Slate Solutions, Inc 2019. +// Copyright (c) 2021 the OneRoster project authors +// Licensed under Apache License v2.0 // +// See LICENSE.txt for license information +// +// SPDX-License-Identifier: Apache-2.0 +// +//===----------------------------------------------------------------------===// import Foundation diff --git a/Sources/OneRoster/Client/OneRosterClient.swift b/Sources/OneRoster/Client/OneRosterClient.swift index c3e5b92..68325df 100644 --- a/Sources/OneRoster/Client/OneRosterClient.swift +++ b/Sources/OneRoster/Client/OneRosterClient.swift @@ -1,15 +1,22 @@ +//===----------------------------------------------------------------------===// // -// OneRosterClient.swift -// OneRoster +// This source file is part of the OneRoster open source project // -// Copyright Slate Solutions, Inc 2019. +// Copyright (c) 2021 the OneRoster project authors +// Licensed under Apache License v2.0 // +// See LICENSE.txt for license information +// +// SPDX-License-Identifier: Apache-2.0 +// +//===----------------------------------------------------------------------===// import Foundation import Crypto import Vapor import Logging +@available(macOS 12, iOS 15, tvOS 15, watchOS 8, *) public struct OneRosterClient { public let baseUrl: URL public let client: Client @@ -146,9 +153,31 @@ extension URLComponents { /// Add a `URLQueryItem` with the given percent-encoded name and value to the `percentEncodedQueryItems` component. /// /// The `percentEncodedQueryItems` array is created if it is currently `nil`. -// public mutating func appendPercentEncodedQueryItem(name: String, value: String? = nil) { -// self.percentEncodedQueryItems = (self.percentEncodedQueryItems ?? []) + [URLQueryItem(name: name, value: value)] -// } + public mutating func appendPercentEncodedQueryItem(name: String, value: String? = nil) { + self.percentEncodedQueryItems = (self.percentEncodedQueryItems ?? []) + [URLQueryItem(name: name, value: value)] + } + +#if os(Linux) && swift(<5.6) + public var percentEncodedQueryItems: [URLQueryItem]? { + get { + guard let percentEncodedQuery = self.percentEncodedQuery else { + return nil + } + // Since the query string is already percent-encoded, we don't have to do anything fancy to + // parse it out; surprisingly, and conveniently, simple string splitting is plenty. + return percentEncodedQuery.split(separator: "&", maxSplits: .max, omittingEmptySubsequences: true).map { + $0.split(separator: "=", maxSplits: 1, omittingEmptySubsequences: false) + }.map { + URLQueryItem(name: String($0[0]), value: $0.last.map(String.init)) + } + } + set { + // Since the individual items are already percent-encoded, we can do simple joins to construct + // the query string. Again, surprisingly convenient. + self.percentEncodedQuery = newValue?.map { i in i.value.map { "\(i.name)=\($0)" } ?? i.name }.joined(separator: "&") + } + } +#endif } extension OneRosterAPI.Endpoint { @@ -168,8 +197,8 @@ extension OneRosterAPI.Endpoint { if let offset = offset { components.appendQueryItem(name: "offset", value: "\(offset)") } - if let filterString = filterString, let encoded = filterString.addingPercentEncoding(withAllowedCharacters: .alphanumerics) { - components.appendQueryItem(name: "filter", value: encoded) + if let filterString = filterString { + components.appendPercentEncodedQueryItem(name: "filter", value: filterString) } guard var paramUrl = components.url else { diff --git a/Sources/OneRoster/Client/Request+OneRosterClient.swift b/Sources/OneRoster/Client/Request+OneRosterClient.swift index af41200..fe19ce6 100644 --- a/Sources/OneRoster/Client/Request+OneRosterClient.swift +++ b/Sources/OneRoster/Client/Request+OneRosterClient.swift @@ -1,13 +1,20 @@ +//===----------------------------------------------------------------------===// // -// Request+OneRosterClient.swift -// OneRoster +// This source file is part of the OneRoster open source project // -// Created by Jimmy McDermott on 4/10/20. +// Copyright (c) 2021 the OneRoster project authors +// Licensed under Apache License v2.0 // +// See LICENSE.txt for license information +// +// SPDX-License-Identifier: Apache-2.0 +// +//===----------------------------------------------------------------------===// import Foundation import Vapor +@available(macOS 12, iOS 15, tvOS 15, watchOS 8, *) extension Request { /// Get a `OneRosterClient` suitable for making OneRoster requests to the given base URL without authentication. /// diff --git a/Sources/OneRoster/Enumerations/ClassType.swift b/Sources/OneRoster/Enumerations/ClassType.swift index 4800690..a6bc38a 100644 --- a/Sources/OneRoster/Enumerations/ClassType.swift +++ b/Sources/OneRoster/Enumerations/ClassType.swift @@ -1,15 +1,18 @@ +//===----------------------------------------------------------------------===// // -// ClassType.swift -// OneRoster +// This source file is part of the OneRoster open source project // -// Copyright Slate Solutions, Inc 2019. +// Copyright (c) 2021 the OneRoster project authors +// Licensed under Apache License v2.0 // - -import Foundation +// See LICENSE.txt for license information +// +// SPDX-License-Identifier: Apache-2.0 +// +//===----------------------------------------------------------------------===// /// The set of permitted tokens for the type of class public enum ClassType: String, Codable { - /// The homeroom (form) assigned to the class. case homeroom diff --git a/Sources/OneRoster/Enumerations/GUIDType.swift b/Sources/OneRoster/Enumerations/GUIDType.swift index e558bf6..3b8fd9d 100644 --- a/Sources/OneRoster/Enumerations/GUIDType.swift +++ b/Sources/OneRoster/Enumerations/GUIDType.swift @@ -1,15 +1,18 @@ +//===----------------------------------------------------------------------===// // -// GUIDType.swift -// OneRoster +// This source file is part of the OneRoster open source project // -// Copyright Slate Solutions, Inc 2019. +// Copyright (c) 2021 the OneRoster project authors +// Licensed under Apache License v2.0 // - -import Foundation +// See LICENSE.txt for license information +// +// SPDX-License-Identifier: Apache-2.0 +// +//===----------------------------------------------------------------------===// /// Describes the entity type of a returned GUIDRef public enum GUIDType: String, Codable { - /// An AcademicSession case academicSession diff --git a/Sources/OneRoster/Enumerations/Gender.swift b/Sources/OneRoster/Enumerations/Gender.swift index d661a7e..805a83b 100644 --- a/Sources/OneRoster/Enumerations/Gender.swift +++ b/Sources/OneRoster/Enumerations/Gender.swift @@ -1,15 +1,18 @@ +//===----------------------------------------------------------------------===// // -// Gender.swift -// OneRoster +// This source file is part of the OneRoster open source project // -// Copyright Slate Solutions, Inc 2019. +// Copyright (c) 2021 the OneRoster project authors +// Licensed under Apache License v2.0 // - -import Foundation +// See LICENSE.txt for license information +// +// SPDX-License-Identifier: Apache-2.0 +// +//===----------------------------------------------------------------------===// /// The set of permitted tokens for the type of gender. public enum Gender: String, Codable { - /// Gender of Male. case male diff --git a/Sources/OneRoster/Enumerations/Grade.swift b/Sources/OneRoster/Enumerations/Grade.swift index 8dc74a1..e819e84 100644 --- a/Sources/OneRoster/Enumerations/Grade.swift +++ b/Sources/OneRoster/Enumerations/Grade.swift @@ -1,11 +1,15 @@ +//===----------------------------------------------------------------------===// // -// Grade.swift -// OneRoster +// This source file is part of the OneRoster open source project // -// Copyright Slate Solutions, Inc 2019. +// Copyright (c) 2021 the OneRoster project authors +// Licensed under Apache License v2.0 // - -import Foundation +// See LICENSE.txt for license information +// +// SPDX-License-Identifier: Apache-2.0 +// +//===----------------------------------------------------------------------===// /// See https://ceds.ed.gov/CEDSElementDetails.aspx?TermId=7100 public enum Grade: String, Codable { diff --git a/Sources/OneRoster/Enumerations/Importance.swift b/Sources/OneRoster/Enumerations/Importance.swift index 7c3e3b1..ac06697 100644 --- a/Sources/OneRoster/Enumerations/Importance.swift +++ b/Sources/OneRoster/Enumerations/Importance.swift @@ -1,15 +1,18 @@ +//===----------------------------------------------------------------------===// // -// Importance.swift -// OneRoster +// This source file is part of the OneRoster open source project // -// Copyright Slate Solutions, Inc 2019. +// Copyright (c) 2021 the OneRoster project authors +// Licensed under Apache License v2.0 // - -import Foundation +// See LICENSE.txt for license information +// +// SPDX-License-Identifier: Apache-2.0 +// +//===----------------------------------------------------------------------===// /// The set of permitted tokens for the importance. public enum Importance: String, Codable { - /// A resource of primary usage. case primary diff --git a/Sources/OneRoster/Enumerations/OrgType.swift b/Sources/OneRoster/Enumerations/OrgType.swift index fe39426..94d5f29 100644 --- a/Sources/OneRoster/Enumerations/OrgType.swift +++ b/Sources/OneRoster/Enumerations/OrgType.swift @@ -1,18 +1,22 @@ +//===----------------------------------------------------------------------===// // -// OrgType.swift -// OneRoster +// This source file is part of the OneRoster open source project // -// Copyright Slate Solutions, Inc 2019. +// Copyright (c) 2021 the OneRoster project authors +// Licensed under Apache License v2.0 // +// See LICENSE.txt for license information +// +// SPDX-License-Identifier: Apache-2.0 +// +//===----------------------------------------------------------------------===// -import Foundation /// The set of permitted tokens for the type of organization. /// The explicit hierarchy is: national -> state -> local -> district -> school. /// /// Note: A 'department' may be inserted below any entity other than national and above any entity other than national and state i.e. national -> state-> department -> local -> department -> district -> department -> school -> department. public enum OrgType: String, Codable { - /// Denotes a department. A department may be a subset in a school or a set of schools. Added in V1.1. case department diff --git a/Sources/OneRoster/Enumerations/ResidenceStatus.swift b/Sources/OneRoster/Enumerations/ResidenceStatus.swift index 23ed901..78777bd 100644 --- a/Sources/OneRoster/Enumerations/ResidenceStatus.swift +++ b/Sources/OneRoster/Enumerations/ResidenceStatus.swift @@ -1,17 +1,19 @@ +//===----------------------------------------------------------------------===// // -// ResidenceStatus.swift -// OneRoster +// This source file is part of the OneRoster open source project // -// Copyright Slate Solutions, Inc 2019. +// Copyright (c) 2021 the OneRoster project authors +// Licensed under Apache License v2.0 // - - -import Foundation +// See LICENSE.txt for license information +// +// SPDX-License-Identifier: Apache-2.0 +// +//===----------------------------------------------------------------------===// /// Defines the student's residence status. /// Based on https://ceds.ed.gov/CEDSElementDetails.aspx?TermxTopicId=20863 -public enum ResidenceStatus: String, Codable { - +public enum ResidenceStatus: String, Codable { /// Resident of administrative unit and usual school attendance area case usualSchoolAttendanceArea = "01652" diff --git a/Sources/OneRoster/Enumerations/RoleType.swift b/Sources/OneRoster/Enumerations/RoleType.swift index 4514800..0a26d5f 100644 --- a/Sources/OneRoster/Enumerations/RoleType.swift +++ b/Sources/OneRoster/Enumerations/RoleType.swift @@ -1,11 +1,15 @@ +//===----------------------------------------------------------------------===// // -// RoleType.swift -// OneRoster +// This source file is part of the OneRoster open source project // -// Copyright Slate Solutions, Inc 2019. +// Copyright (c) 2021 the OneRoster project authors +// Licensed under Apache License v2.0 // - -import Foundation +// See LICENSE.txt for license information +// +// SPDX-License-Identifier: Apache-2.0 +// +//===----------------------------------------------------------------------===// /// Represents an access level for a `User` public enum RoleType: String, Codable { diff --git a/Sources/OneRoster/Enumerations/ScoreStatus.swift b/Sources/OneRoster/Enumerations/ScoreStatus.swift index 9ce01cf..d4dfd59 100644 --- a/Sources/OneRoster/Enumerations/ScoreStatus.swift +++ b/Sources/OneRoster/Enumerations/ScoreStatus.swift @@ -1,11 +1,15 @@ +//===----------------------------------------------------------------------===// // -// ScoreStatus.swift -// OneRoster +// This source file is part of the OneRoster open source project // -// Copyright Slate Solutions, Inc 2019. +// Copyright (c) 2021 the OneRoster project authors +// Licensed under Apache License v2.0 // - -import Foundation +// See LICENSE.txt for license information +// +// SPDX-License-Identifier: Apache-2.0 +// +//===----------------------------------------------------------------------===// /// The set of permitted tokens for the type of score status. /// diff --git a/Sources/OneRoster/Enumerations/SessionType.swift b/Sources/OneRoster/Enumerations/SessionType.swift index 0100d3e..97307b9 100644 --- a/Sources/OneRoster/Enumerations/SessionType.swift +++ b/Sources/OneRoster/Enumerations/SessionType.swift @@ -1,11 +1,15 @@ +//===----------------------------------------------------------------------===// // -// SessionType.swift -// OneRoster +// This source file is part of the OneRoster open source project // -// Copyright Slate Solutions, Inc 2019. +// Copyright (c) 2021 the OneRoster project authors +// Licensed under Apache License v2.0 // - -import Foundation +// See LICENSE.txt for license information +// +// SPDX-License-Identifier: Apache-2.0 +// +//===----------------------------------------------------------------------===// /// The set of permitted tokens for the type of academic session. public enum SessionType: String, Codable { diff --git a/Sources/OneRoster/Enumerations/StateCode.swift b/Sources/OneRoster/Enumerations/StateCode.swift index fa1b818..7626586 100644 --- a/Sources/OneRoster/Enumerations/StateCode.swift +++ b/Sources/OneRoster/Enumerations/StateCode.swift @@ -1,11 +1,15 @@ +//===----------------------------------------------------------------------===// // -// StateCode.swift -// OneRoster +// This source file is part of the OneRoster open source project // -// Copyright Slate Solutions, Inc 2019. +// Copyright (c) 2021 the OneRoster project authors +// Licensed under Apache License v2.0 // - -import Foundation +// See LICENSE.txt for license information +// +// SPDX-License-Identifier: Apache-2.0 +// +//===----------------------------------------------------------------------===// /// Defines the state's code. /// Based on https://ceds.ed.gov/CEDSElementDetails.aspx?TermxTopicId=20837 diff --git a/Sources/OneRoster/Enumerations/StatusType.swift b/Sources/OneRoster/Enumerations/StatusType.swift index beb2ae4..9e07fd0 100644 --- a/Sources/OneRoster/Enumerations/StatusType.swift +++ b/Sources/OneRoster/Enumerations/StatusType.swift @@ -1,11 +1,15 @@ +//===----------------------------------------------------------------------===// // -// StatusType.swift -// OneRoster +// This source file is part of the OneRoster open source project // -// Copyright Slate Solutions, Inc 2019. +// Copyright (c) 2021 the OneRoster project authors +// Licensed under Apache License v2.0 // - -import Foundation +// See LICENSE.txt for license information +// +// SPDX-License-Identifier: Apache-2.0 +// +//===----------------------------------------------------------------------===// /// Represents the current status for the user public enum StatusType: String, Codable { diff --git a/Sources/OneRoster/Models/AcademicSession.swift b/Sources/OneRoster/Models/AcademicSession.swift index 7e7596d..2bf7a4f 100644 --- a/Sources/OneRoster/Models/AcademicSession.swift +++ b/Sources/OneRoster/Models/AcademicSession.swift @@ -1,11 +1,15 @@ +//===----------------------------------------------------------------------===// // -// AcademicSession.swift -// OneRoster +// This source file is part of the OneRoster open source project // -// Copyright Slate Solutions, Inc 2019. +// Copyright (c) 2021 the OneRoster project authors +// Licensed under Apache License v2.0 // - -import Foundation +// See LICENSE.txt for license information +// +// SPDX-License-Identifier: Apache-2.0 +// +//===----------------------------------------------------------------------===// /// AcademicSession represent durations of time. Typically they are used to describe terms, grading periods, and other durations e.g. school years. /// Term is used to describe a period of time during which learning will take place. Other words for term could be in common use around the world e.g. diff --git a/Sources/OneRoster/Models/Class.swift b/Sources/OneRoster/Models/Class.swift index c04b6b9..17f7457 100644 --- a/Sources/OneRoster/Models/Class.swift +++ b/Sources/OneRoster/Models/Class.swift @@ -1,11 +1,15 @@ +//===----------------------------------------------------------------------===// // -// Class.swift -// OneRoster +// This source file is part of the OneRoster open source project // -// Copyright Slate Solutions, Inc 2019. +// Copyright (c) 2021 the OneRoster project authors +// Licensed under Apache License v2.0 // - -import Foundation +// See LICENSE.txt for license information +// +// SPDX-License-Identifier: Apache-2.0 +// +//===----------------------------------------------------------------------===// /// A class is an instance of a course, onto which students and teachers are enrolled. /// A class is typically held within a term. diff --git a/Sources/OneRoster/Models/Course.swift b/Sources/OneRoster/Models/Course.swift index 89988c3..6d81181 100644 --- a/Sources/OneRoster/Models/Course.swift +++ b/Sources/OneRoster/Models/Course.swift @@ -1,11 +1,15 @@ +//===----------------------------------------------------------------------===// // -// Course.swift -// OneRoster +// This source file is part of the OneRoster open source project // -// Copyright Slate Solutions, Inc 2019. +// Copyright (c) 2021 the OneRoster project authors +// Licensed under Apache License v2.0 // - -import Foundation +// See LICENSE.txt for license information +// +// SPDX-License-Identifier: Apache-2.0 +// +//===----------------------------------------------------------------------===// /// A Course is a course of study that, typically, has a shared curriculum although it may be taught to different /// students by different teachers. It is likely that several classes of a single course may be taught in a term. diff --git a/Sources/OneRoster/Models/DemographicData.swift b/Sources/OneRoster/Models/DemographicData.swift index 8986589..bc483d3 100644 --- a/Sources/OneRoster/Models/DemographicData.swift +++ b/Sources/OneRoster/Models/DemographicData.swift @@ -1,11 +1,15 @@ +//===----------------------------------------------------------------------===// // -// DemographicData.swift -// OneRoster +// This source file is part of the OneRoster open source project // -// Copyright Slate Solutions, Inc 2019. +// Copyright (c) 2021 the OneRoster project authors +// Licensed under Apache License v2.0 // - -import Foundation +// See LICENSE.txt for license information +// +// SPDX-License-Identifier: Apache-2.0 +// +//===----------------------------------------------------------------------===// /// Demographics information is taken from the Common Educational Data Standards from the US government. (http://ceds.ed.gov). Demographics are /// OPTIONAL. diff --git a/Sources/OneRoster/Models/Enrollment.swift b/Sources/OneRoster/Models/Enrollment.swift index dbcdaba..b617ca7 100644 --- a/Sources/OneRoster/Models/Enrollment.swift +++ b/Sources/OneRoster/Models/Enrollment.swift @@ -1,11 +1,15 @@ +//===----------------------------------------------------------------------===// // -// Enrollment.swift -// OneRoster +// This source file is part of the OneRoster open source project // -// Copyright Slate Solutions, Inc 2019. +// Copyright (c) 2021 the OneRoster project authors +// Licensed under Apache License v2.0 // - -import Foundation +// See LICENSE.txt for license information +// +// SPDX-License-Identifier: Apache-2.0 +// +//===----------------------------------------------------------------------===// /// An enrollment is the name given to an individual taking part in a course or class. /// In the vast majority of cases, users will be students learning in a class, diff --git a/Sources/OneRoster/Models/LineItem.swift b/Sources/OneRoster/Models/LineItem.swift index 6775f32..572d68d 100644 --- a/Sources/OneRoster/Models/LineItem.swift +++ b/Sources/OneRoster/Models/LineItem.swift @@ -1,11 +1,15 @@ +//===----------------------------------------------------------------------===// // -// LineItem.swift -// OneRoster +// This source file is part of the OneRoster open source project // -// Copyright Slate Solutions, Inc 2019. +// Copyright (c) 2021 the OneRoster project authors +// Licensed under Apache License v2.0 // - -import Foundation +// See LICENSE.txt for license information +// +// SPDX-License-Identifier: Apache-2.0 +// +//===----------------------------------------------------------------------===// /// Line Items are assignments in LIS, they make up the column headings in a gradebook, /// and many students will each complete lineItems as they are assessed. It is proposed diff --git a/Sources/OneRoster/Models/LineItemCategory.swift b/Sources/OneRoster/Models/LineItemCategory.swift index e8cd730..aa69681 100644 --- a/Sources/OneRoster/Models/LineItemCategory.swift +++ b/Sources/OneRoster/Models/LineItemCategory.swift @@ -1,11 +1,15 @@ +//===----------------------------------------------------------------------===// // -// LineItemCategory.swift -// OneRoster +// This source file is part of the OneRoster open source project // -// Copyright Slate Solutions, Inc 2019. +// Copyright (c) 2021 the OneRoster project authors +// Licensed under Apache License v2.0 // - -import Foundation +// See LICENSE.txt for license information +// +// SPDX-License-Identifier: Apache-2.0 +// +//===----------------------------------------------------------------------===// /// A Category is the name given to a grouping of line items. /// (Line Items being equivalent to assignments which students will complete). diff --git a/Sources/OneRoster/Models/Org.swift b/Sources/OneRoster/Models/Org.swift index 0ecb35e..da32354 100644 --- a/Sources/OneRoster/Models/Org.swift +++ b/Sources/OneRoster/Models/Org.swift @@ -1,11 +1,15 @@ +//===----------------------------------------------------------------------===// // -// Org.swift -// OneRoster +// This source file is part of the OneRoster open source project // -// Copyright Slate Solutions, Inc 2019. +// Copyright (c) 2021 the OneRoster project authors +// Licensed under Apache License v2.0 // - -import Foundation +// See LICENSE.txt for license information +// +// SPDX-License-Identifier: Apache-2.0 +// +//===----------------------------------------------------------------------===// /// ORG is defined here as a structure for holding organizational information. /// An ORG might be a school, or it might be a local, statewide, or national entity. diff --git a/Sources/OneRoster/Models/Resource.swift b/Sources/OneRoster/Models/Resource.swift index c1b5685..cb4a636 100644 --- a/Sources/OneRoster/Models/Resource.swift +++ b/Sources/OneRoster/Models/Resource.swift @@ -1,11 +1,15 @@ +//===----------------------------------------------------------------------===// // -// Resource.swift -// OneRoster +// This source file is part of the OneRoster open source project // -// Copyright Slate Solutions, Inc 2019. +// Copyright (c) 2021 the OneRoster project authors +// Licensed under Apache License v2.0 // - -import Foundation +// See LICENSE.txt for license information +// +// SPDX-License-Identifier: Apache-2.0 +// +//===----------------------------------------------------------------------===// /// A resource is a description of learning content that is related to a course and/or a class. /// This identifies a resource that is used by a teacher, learner, etc. diff --git a/Sources/OneRoster/Models/Result.swift b/Sources/OneRoster/Models/Result.swift index 366dfef..a5f4b50 100644 --- a/Sources/OneRoster/Models/Result.swift +++ b/Sources/OneRoster/Models/Result.swift @@ -1,11 +1,15 @@ +//===----------------------------------------------------------------------===// // -// Result.swift -// OneRoster +// This source file is part of the OneRoster open source project // -// Copyright Slate Solutions, Inc 2019. +// Copyright (c) 2021 the OneRoster project authors +// Licensed under Apache License v2.0 // - -import Foundation +// See LICENSE.txt for license information +// +// SPDX-License-Identifier: Apache-2.0 +// +//===----------------------------------------------------------------------===// /// It is proposed that the OneRoster Result object takes a subset of the /// equivalent LIS elements as shown in Figure 4.12/Table 4.11. diff --git a/Sources/OneRoster/Models/User.swift b/Sources/OneRoster/Models/User.swift index 85c9fa2..21c9c3d 100644 --- a/Sources/OneRoster/Models/User.swift +++ b/Sources/OneRoster/Models/User.swift @@ -1,11 +1,15 @@ +//===----------------------------------------------------------------------===// // -// User.swift -// OneRoster +// This source file is part of the OneRoster open source project // -// Copyright Slate Solutions, Inc 2019. +// Copyright (c) 2021 the OneRoster project authors +// Licensed under Apache License v2.0 // - -import Foundation +// See LICENSE.txt for license information +// +// SPDX-License-Identifier: Apache-2.0 +// +//===----------------------------------------------------------------------===// /// Users, Teachers and Students are human beings that are teaching or studying in a class respectively. /// LIS represents these with Person. For the case of binding, it is proposed that a single User class diff --git a/Sources/OneRoster/Partials/GUIDRef.swift b/Sources/OneRoster/Partials/GUIDRef.swift index 9e226ae..9c2ef7f 100644 --- a/Sources/OneRoster/Partials/GUIDRef.swift +++ b/Sources/OneRoster/Partials/GUIDRef.swift @@ -1,11 +1,15 @@ +//===----------------------------------------------------------------------===// // -// GUIDRef.swift -// OneRoster +// This source file is part of the OneRoster open source project // -// Copyright Slate Solutions, Inc 2019. +// Copyright (c) 2021 the OneRoster project authors +// Licensed under Apache License v2.0 // - -import Foundation +// See LICENSE.txt for license information +// +// SPDX-License-Identifier: Apache-2.0 +// +//===----------------------------------------------------------------------===// /// Represents a reference to another entity within the system public struct GUIDRef: Codable { diff --git a/Sources/OneRoster/Partials/OneRosterError.swift b/Sources/OneRoster/Partials/OneRosterError.swift index 0457f0b..4e09138 100644 --- a/Sources/OneRoster/Partials/OneRosterError.swift +++ b/Sources/OneRoster/Partials/OneRosterError.swift @@ -1,12 +1,18 @@ +//===----------------------------------------------------------------------===// // -// OneRosterError.swift -// OneRoster +// This source file is part of the OneRoster open source project // -// Created by Jimmy McDermott on 5/25/19. +// Copyright (c) 2021 the OneRoster project authors +// Licensed under Apache License v2.0 // +// See LICENSE.txt for license information +// +// SPDX-License-Identifier: Apache-2.0 +// +//===----------------------------------------------------------------------===// -import Foundation import Vapor +import NIOHTTP1 public struct OneRosterErrorPayload: Codable { /// CodeMajor - specifies success or failure diff --git a/Sources/OneRoster/Partials/StringyBoolean.swift b/Sources/OneRoster/Partials/StringyBoolean.swift index e08e413..d4da46d 100644 --- a/Sources/OneRoster/Partials/StringyBoolean.swift +++ b/Sources/OneRoster/Partials/StringyBoolean.swift @@ -1,11 +1,15 @@ +//===----------------------------------------------------------------------===// // -// StringyBoolean.swift -// OneRoster +// This source file is part of the OneRoster open source project // -// Created by Jimmy McDermott on 5/25/19. +// Copyright (c) 2021 the OneRoster project authors +// Licensed under Apache License v2.0 // - -import Foundation +// See LICENSE.txt for license information +// +// SPDX-License-Identifier: Apache-2.0 +// +//===----------------------------------------------------------------------===// extension KeyedDecodingContainer where K: CodingKey { func stringBoolean(forKey key: KeyedDecodingContainer.Key) throws -> Bool { diff --git a/Sources/OneRoster/Partials/UserId.swift b/Sources/OneRoster/Partials/UserId.swift index 5f26ca1..860f623 100644 --- a/Sources/OneRoster/Partials/UserId.swift +++ b/Sources/OneRoster/Partials/UserId.swift @@ -1,11 +1,15 @@ +//===----------------------------------------------------------------------===// // -// UserId.swift -// OneRoster +// This source file is part of the OneRoster open source project // -// Copyright Slate Solutions, Inc 2019. +// Copyright (c) 2021 the OneRoster project authors +// Licensed under Apache License v2.0 // - -import Foundation +// See LICENSE.txt for license information +// +// SPDX-License-Identifier: Apache-2.0 +// +//===----------------------------------------------------------------------===// /// Represents an identifier for a user public struct UserId: Codable { diff --git a/Sources/OneRoster/Protocols/OneRosterBase.swift b/Sources/OneRoster/Protocols/OneRosterBase.swift index e36510c..18cc8c7 100644 --- a/Sources/OneRoster/Protocols/OneRosterBase.swift +++ b/Sources/OneRoster/Protocols/OneRosterBase.swift @@ -1,11 +1,15 @@ +//===----------------------------------------------------------------------===// // -// OneRosterBase.swift -// OneRoster +// This source file is part of the OneRoster open source project // -// Copyright Slate Solutions, Inc 2019. +// Copyright (c) 2021 the OneRoster project authors +// Licensed under Apache License v2.0 // - -import Foundation +// See LICENSE.txt for license information +// +// SPDX-License-Identifier: Apache-2.0 +// +//===----------------------------------------------------------------------===// /// Represents the base model that all OneRoster entities inherit from public protocol OneRosterBase { diff --git a/Sources/OneRoster/Protocols/OneRosterResponse.swift b/Sources/OneRoster/Protocols/OneRosterResponse.swift index 463f390..e123979 100644 --- a/Sources/OneRoster/Protocols/OneRosterResponse.swift +++ b/Sources/OneRoster/Protocols/OneRosterResponse.swift @@ -1,11 +1,15 @@ +//===----------------------------------------------------------------------===// // -// OneRosterResponse.swift -// OneRoster +// This source file is part of the OneRoster open source project // -// Copyright Slate Solutions, Inc 2019. +// Copyright (c) 2021 the OneRoster project authors +// Licensed under Apache License v2.0 // - -import Foundation +// See LICENSE.txt for license information +// +// SPDX-License-Identifier: Apache-2.0 +// +//===----------------------------------------------------------------------===// public protocol OneRosterResponse: Codable { associatedtype InnerType: OneRosterBase diff --git a/Sources/OneRoster/Responses/ClassesResponse.swift b/Sources/OneRoster/Responses/ClassesResponse.swift index d743105..d4e0b78 100644 --- a/Sources/OneRoster/Responses/ClassesResponse.swift +++ b/Sources/OneRoster/Responses/ClassesResponse.swift @@ -1,11 +1,15 @@ +//===----------------------------------------------------------------------===// // -// File.swift -// File +// This source file is part of the OneRoster open source project // -// Created by James McDermott on 8/24/21. +// Copyright (c) 2021 the OneRoster project authors +// Licensed under Apache License v2.0 // - -import Foundation +// See LICENSE.txt for license information +// +// SPDX-License-Identifier: Apache-2.0 +// +//===----------------------------------------------------------------------===// /// See `Class` public struct ClassesResponse: Codable, OneRosterResponse { diff --git a/Sources/OneRoster/Responses/CoursesResponse.swift b/Sources/OneRoster/Responses/CoursesResponse.swift index 9dd890c..d752d97 100644 --- a/Sources/OneRoster/Responses/CoursesResponse.swift +++ b/Sources/OneRoster/Responses/CoursesResponse.swift @@ -1,11 +1,15 @@ +//===----------------------------------------------------------------------===// // -// File.swift -// +// This source file is part of the OneRoster open source project // -// Created by Jimmy McDermott on 12/11/20. +// Copyright (c) 2021 the OneRoster project authors +// Licensed under Apache License v2.0 // - -import Foundation +// See LICENSE.txt for license information +// +// SPDX-License-Identifier: Apache-2.0 +// +//===----------------------------------------------------------------------===// /// See `Course` public struct CoursesResponse: Codable, OneRosterResponse { diff --git a/Sources/OneRoster/Responses/DemographicResponse.swift b/Sources/OneRoster/Responses/DemographicResponse.swift index 78ca980..d10d310 100644 --- a/Sources/OneRoster/Responses/DemographicResponse.swift +++ b/Sources/OneRoster/Responses/DemographicResponse.swift @@ -1,11 +1,15 @@ +//===----------------------------------------------------------------------===// // -// DemographicResponse.swift -// OneRoster +// This source file is part of the OneRoster open source project // -// Copyright Slate Solutions, Inc 2019. +// Copyright (c) 2021 the OneRoster project authors +// Licensed under Apache License v2.0 // - -import Foundation +// See LICENSE.txt for license information +// +// SPDX-License-Identifier: Apache-2.0 +// +//===----------------------------------------------------------------------===// /// See `DemographicData` public struct DemographicResponse: Codable, OneRosterResponse { diff --git a/Sources/OneRoster/Responses/DemographicsResponse.swift b/Sources/OneRoster/Responses/DemographicsResponse.swift index ca46964..3922b89 100644 --- a/Sources/OneRoster/Responses/DemographicsResponse.swift +++ b/Sources/OneRoster/Responses/DemographicsResponse.swift @@ -1,11 +1,15 @@ +//===----------------------------------------------------------------------===// // -// DemographicsResponse.swift -// OneRoster +// This source file is part of the OneRoster open source project // -// Copyright Slate Solutions, Inc 2019. +// Copyright (c) 2021 the OneRoster project authors +// Licensed under Apache License v2.0 // - -import Foundation +// See LICENSE.txt for license information +// +// SPDX-License-Identifier: Apache-2.0 +// +//===----------------------------------------------------------------------===// /// See `DemographicData` public struct DemographicsResponse: Codable, OneRosterResponse { diff --git a/Sources/OneRoster/Responses/EnrollmentResponse.swift b/Sources/OneRoster/Responses/EnrollmentResponse.swift index 3200825..19a45f9 100644 --- a/Sources/OneRoster/Responses/EnrollmentResponse.swift +++ b/Sources/OneRoster/Responses/EnrollmentResponse.swift @@ -1,11 +1,15 @@ +//===----------------------------------------------------------------------===// // -// EnrollmentResponse.swift -// OneRoster +// This source file is part of the OneRoster open source project // -// Copyright Slate Solutions, Inc 2019. +// Copyright (c) 2021 the OneRoster project authors +// Licensed under Apache License v2.0 // - -import Foundation +// See LICENSE.txt for license information +// +// SPDX-License-Identifier: Apache-2.0 +// +//===----------------------------------------------------------------------===// /// See `Enrollment` public struct EnrollmentResponse: Codable, OneRosterResponse { diff --git a/Sources/OneRoster/Responses/EnrollmentsResponse.swift b/Sources/OneRoster/Responses/EnrollmentsResponse.swift index 952f610..5d00f16 100644 --- a/Sources/OneRoster/Responses/EnrollmentsResponse.swift +++ b/Sources/OneRoster/Responses/EnrollmentsResponse.swift @@ -1,11 +1,15 @@ +//===----------------------------------------------------------------------===// // -// EnrollmentsResponse.swift -// OneRoster +// This source file is part of the OneRoster open source project // -// Copyright Slate Solutions, Inc 2019. +// Copyright (c) 2021 the OneRoster project authors +// Licensed under Apache License v2.0 // - -import Foundation +// See LICENSE.txt for license information +// +// SPDX-License-Identifier: Apache-2.0 +// +//===----------------------------------------------------------------------===// /// See `Enrollment` public struct EnrollmentsResponse: Codable, OneRosterResponse { diff --git a/Sources/OneRoster/Responses/OrgResponse.swift b/Sources/OneRoster/Responses/OrgResponse.swift index 010390d..916087f 100644 --- a/Sources/OneRoster/Responses/OrgResponse.swift +++ b/Sources/OneRoster/Responses/OrgResponse.swift @@ -1,11 +1,15 @@ +//===----------------------------------------------------------------------===// // -// OrgResponse.swift -// OneRoster +// This source file is part of the OneRoster open source project // -// Copyright Slate Solutions, Inc 2019. +// Copyright (c) 2021 the OneRoster project authors +// Licensed under Apache License v2.0 // - -import Foundation +// See LICENSE.txt for license information +// +// SPDX-License-Identifier: Apache-2.0 +// +//===----------------------------------------------------------------------===// /// See `Org` public struct OrgResponse: Codable, OneRosterResponse { diff --git a/Sources/OneRoster/Responses/OrgsResponse.swift b/Sources/OneRoster/Responses/OrgsResponse.swift index 0a92371..dd607c8 100644 --- a/Sources/OneRoster/Responses/OrgsResponse.swift +++ b/Sources/OneRoster/Responses/OrgsResponse.swift @@ -1,11 +1,15 @@ +//===----------------------------------------------------------------------===// // -// OrgsResponse.swift -// OneRoster +// This source file is part of the OneRoster open source project // -// Copyright Slate Solutions, Inc 2019. +// Copyright (c) 2021 the OneRoster project authors +// Licensed under Apache License v2.0 // - -import Foundation +// See LICENSE.txt for license information +// +// SPDX-License-Identifier: Apache-2.0 +// +//===----------------------------------------------------------------------===// /// See `Org` public struct OrgsResponse: Codable, OneRosterResponse { diff --git a/Sources/OneRoster/Responses/SchoolResponse.swift b/Sources/OneRoster/Responses/SchoolResponse.swift index 085b965..28190c9 100644 --- a/Sources/OneRoster/Responses/SchoolResponse.swift +++ b/Sources/OneRoster/Responses/SchoolResponse.swift @@ -1,11 +1,15 @@ +//===----------------------------------------------------------------------===// // -// SchoolResponse.swift -// OneRoster +// This source file is part of the OneRoster open source project // -// Copyright Slate Solutions, Inc 2019. +// Copyright (c) 2021 the OneRoster project authors +// Licensed under Apache License v2.0 // - -import Foundation +// See LICENSE.txt for license information +// +// SPDX-License-Identifier: Apache-2.0 +// +//===----------------------------------------------------------------------===// /// See `Org` public struct SchoolResponse: Codable, OneRosterResponse { diff --git a/Sources/OneRoster/Responses/SchoolsResponse.swift b/Sources/OneRoster/Responses/SchoolsResponse.swift index f312bb7..44b63fc 100644 --- a/Sources/OneRoster/Responses/SchoolsResponse.swift +++ b/Sources/OneRoster/Responses/SchoolsResponse.swift @@ -1,11 +1,15 @@ +//===----------------------------------------------------------------------===// // -// SchoolsResponse.swift -// OneRoster +// This source file is part of the OneRoster open source project // -// Copyright Slate Solutions, Inc 2019. +// Copyright (c) 2021 the OneRoster project authors +// Licensed under Apache License v2.0 // - -import Foundation +// See LICENSE.txt for license information +// +// SPDX-License-Identifier: Apache-2.0 +// +//===----------------------------------------------------------------------===// /// See `Org` public struct SchoolsResponse: Codable, OneRosterResponse { diff --git a/Sources/OneRoster/Responses/StudentResponse.swift b/Sources/OneRoster/Responses/StudentResponse.swift index 7003987..721e5fe 100644 --- a/Sources/OneRoster/Responses/StudentResponse.swift +++ b/Sources/OneRoster/Responses/StudentResponse.swift @@ -1,11 +1,15 @@ +//===----------------------------------------------------------------------===// // -// StudentResponse.swift -// OneRoster +// This source file is part of the OneRoster open source project // -// Copyright Slate Solutions, Inc 2019. +// Copyright (c) 2021 the OneRoster project authors +// Licensed under Apache License v2.0 // - -import Foundation +// See LICENSE.txt for license information +// +// SPDX-License-Identifier: Apache-2.0 +// +//===----------------------------------------------------------------------===// /// See `User` public struct StudentResponse: Codable, OneRosterResponse { diff --git a/Sources/OneRoster/Responses/StudentsForSchoolResponse.swift b/Sources/OneRoster/Responses/StudentsForSchoolResponse.swift index 55b3dd7..765a69c 100644 --- a/Sources/OneRoster/Responses/StudentsForSchoolResponse.swift +++ b/Sources/OneRoster/Responses/StudentsForSchoolResponse.swift @@ -1,11 +1,15 @@ +//===----------------------------------------------------------------------===// // -// StudentsForSchoolResponse.swift -// OneRoster +// This source file is part of the OneRoster open source project // -// Copyright Slate Solutions, Inc 2019. +// Copyright (c) 2021 the OneRoster project authors +// Licensed under Apache License v2.0 // - -import Foundation +// See LICENSE.txt for license information +// +// SPDX-License-Identifier: Apache-2.0 +// +//===----------------------------------------------------------------------===// /// See `User` public struct StudentsForSchoolResponse: Codable, OneRosterResponse { diff --git a/Sources/OneRoster/Responses/StudentsResponse.swift b/Sources/OneRoster/Responses/StudentsResponse.swift index e0f1f84..2cad85d 100644 --- a/Sources/OneRoster/Responses/StudentsResponse.swift +++ b/Sources/OneRoster/Responses/StudentsResponse.swift @@ -1,11 +1,15 @@ +//===----------------------------------------------------------------------===// // -// StudentsResponse.swift -// OneRoster +// This source file is part of the OneRoster open source project // -// Copyright Slate Solutions, Inc 2019. +// Copyright (c) 2021 the OneRoster project authors +// Licensed under Apache License v2.0 // - -import Foundation +// See LICENSE.txt for license information +// +// SPDX-License-Identifier: Apache-2.0 +// +//===----------------------------------------------------------------------===// /// See `User` public struct StudentsResponse: Codable, OneRosterResponse { diff --git a/Sources/OneRoster/Responses/TeacherResponse.swift b/Sources/OneRoster/Responses/TeacherResponse.swift index 37a2ee1..9baee92 100644 --- a/Sources/OneRoster/Responses/TeacherResponse.swift +++ b/Sources/OneRoster/Responses/TeacherResponse.swift @@ -1,11 +1,15 @@ +//===----------------------------------------------------------------------===// // -// TeacherResponse.swift -// OneRoster +// This source file is part of the OneRoster open source project // -// Copyright Slate Solutions, Inc 2019. +// Copyright (c) 2021 the OneRoster project authors +// Licensed under Apache License v2.0 // - -import Foundation +// See LICENSE.txt for license information +// +// SPDX-License-Identifier: Apache-2.0 +// +//===----------------------------------------------------------------------===// /// See `User` public struct TeacherResponse: Codable, OneRosterResponse { diff --git a/Sources/OneRoster/Responses/TeachersForSchoolResponse.swift b/Sources/OneRoster/Responses/TeachersForSchoolResponse.swift index 17fb78e..54f5d14 100644 --- a/Sources/OneRoster/Responses/TeachersForSchoolResponse.swift +++ b/Sources/OneRoster/Responses/TeachersForSchoolResponse.swift @@ -1,11 +1,15 @@ +//===----------------------------------------------------------------------===// // -// TeachersForSchoolResponse.swift -// OneRoster +// This source file is part of the OneRoster open source project // -// Copyright Slate Solutions, Inc 2019. +// Copyright (c) 2021 the OneRoster project authors +// Licensed under Apache License v2.0 // - -import Foundation +// See LICENSE.txt for license information +// +// SPDX-License-Identifier: Apache-2.0 +// +//===----------------------------------------------------------------------===// /// See `User` public struct TeachersForSchoolResponse: Codable, OneRosterResponse { diff --git a/Sources/OneRoster/Responses/TeachersResponse.swift b/Sources/OneRoster/Responses/TeachersResponse.swift index 7e069e7..d94f496 100644 --- a/Sources/OneRoster/Responses/TeachersResponse.swift +++ b/Sources/OneRoster/Responses/TeachersResponse.swift @@ -1,11 +1,15 @@ +//===----------------------------------------------------------------------===// // -// TeachersResponse.swift -// OneRoster +// This source file is part of the OneRoster open source project // -// Copyright Slate Solutions, Inc 2019. +// Copyright (c) 2021 the OneRoster project authors +// Licensed under Apache License v2.0 // - -import Foundation +// See LICENSE.txt for license information +// +// SPDX-License-Identifier: Apache-2.0 +// +//===----------------------------------------------------------------------===// /// See `User` public struct TeachersResponse: Codable, OneRosterResponse { diff --git a/Sources/OneRoster/Responses/UserResponse.swift b/Sources/OneRoster/Responses/UserResponse.swift index abe84c0..20133dd 100644 --- a/Sources/OneRoster/Responses/UserResponse.swift +++ b/Sources/OneRoster/Responses/UserResponse.swift @@ -1,11 +1,15 @@ +//===----------------------------------------------------------------------===// // -// UserResponse.swift -// OneRoster +// This source file is part of the OneRoster open source project // -// Copyright Slate Solutions, Inc 2019. +// Copyright (c) 2021 the OneRoster project authors +// Licensed under Apache License v2.0 // - -import Foundation +// See LICENSE.txt for license information +// +// SPDX-License-Identifier: Apache-2.0 +// +//===----------------------------------------------------------------------===// /// See `User` public struct UserResponse: Codable, OneRosterResponse { diff --git a/Sources/OneRoster/Responses/UsersResponse.swift b/Sources/OneRoster/Responses/UsersResponse.swift index 2fa5447..befe913 100644 --- a/Sources/OneRoster/Responses/UsersResponse.swift +++ b/Sources/OneRoster/Responses/UsersResponse.swift @@ -1,11 +1,15 @@ +//===----------------------------------------------------------------------===// // -// UsersResponse.swift -// OneRoster +// This source file is part of the OneRoster open source project // -// Copyright Slate Solutions, Inc 2019. +// Copyright (c) 2021 the OneRoster project authors +// Licensed under Apache License v2.0 // - -import Foundation +// See LICENSE.txt for license information +// +// SPDX-License-Identifier: Apache-2.0 +// +//===----------------------------------------------------------------------===// /// See `User` public struct UsersResponse: Codable, OneRosterResponse { diff --git a/Tests/OneRosterTests/OneRosterTests.swift b/Tests/OneRosterTests/OneRosterTests.swift index aaea601..d267101 100644 --- a/Tests/OneRosterTests/OneRosterTests.swift +++ b/Tests/OneRosterTests/OneRosterTests.swift @@ -1,8 +1,22 @@ +//===----------------------------------------------------------------------===// +// +// This source file is part of the OneRoster open source project +// +// Copyright (c) 2021 the OneRoster project authors +// Licensed under Apache License v2.0 +// +// See LICENSE.txt for license information +// +// SPDX-License-Identifier: Apache-2.0 +// +//===----------------------------------------------------------------------===// + import Vapor import XCTest import XCTVapor @testable import OneRoster +@available(macOS 12, iOS 15, tvOS 15, watchOS 8, *) final class OneRosterTests: XCTestCase { func testEndpointRequestUrls() throws { XCTAssertEqual(OneRosterAPI.Endpoint.getAllOrgs.makeRequestUrl(from: .init(string: "https://test.com")!)?.absoluteString, "https://test.com/ims/oneroster/v1p1/orgs") @@ -34,7 +48,7 @@ final class OneRosterTests: XCTestCase { XCTAssertEqual(headerString, expectedHeaderString) } - func testMultiObjectRequest() async throws { + func testMultiObjectRequest() throws { let app = Application(.testing) defer { app.shutdown() } @@ -74,7 +88,7 @@ final class OneRosterTests: XCTestCase { try app.start() - let response: [Org] = try await app.oneRoster(baseUrl: .init(string: "http://localhost:8080")!).request(.getAllOrgs, as: OrgsResponse.self) + let response: [Org] = try app.eventLoopGroup.performWithTask { try await app.oneRoster(baseUrl: .init(string: "http://localhost:8080")!).request(.getAllOrgs, as: OrgsResponse.self) }.wait() XCTAssertEqual(response.count, 4) } diff --git a/scripts/check_no_api_breakages.sh b/scripts/check_no_api_breakages.sh new file mode 100755 index 0000000..fb25ee7 --- /dev/null +++ b/scripts/check_no_api_breakages.sh @@ -0,0 +1,138 @@ +#!/bin/bash +##===----------------------------------------------------------------------===## +## +## This source file is part of the OneRoster open source project +## +## Copyright (c) 2021 the OneRoster project authors +## Licensed under Apache License v2.0 +## +## See LICENSE.txt for license information +## +## SPDX-License-Identifier: Apache-2.0 +## +##===----------------------------------------------------------------------===## + +##===----------------------------------------------------------------------===## +## +## This source file is part of the SwiftNIO open source project +## +## Copyright (c) 2017-2020 Apple Inc. and the SwiftNIO project authors +## Licensed under Apache License v2.0 +## +## See LICENSE.txt for license information +## See CONTRIBUTORS.txt for the list of SwiftNIO project authors +## +## SPDX-License-Identifier: Apache-2.0 +## +##===----------------------------------------------------------------------===## + +set -eu + +# repodir +function all_modules() { + local repodir="$1" + ( + set -eu + cd "$repodir" + swift package dump-package | jq '.products | + map(select(.type | has("library") )) | + map(.name) | .[]' | tr -d '"' + ) +} + +# repodir tag output +function build_and_do() { + local repodir=$1 + local tag=$2 + local output=$3 + + ( + cd "$repodir" + git checkout -q "$tag" + swift build + while read -r module; do + swift api-digester -sdk "$sdk" -dump-sdk -module "$module" \ + -o "$output/$module.json" -I "$repodir/.build/debug" + done < <(all_modules "$repodir") + ) +} + +function usage() { + echo >&2 "Usage: $0 REPO-GITHUB-URL NEW-VERSION OLD-VERSIONS..." + echo >&2 + echo >&2 "This script requires a Swift 5.2+ toolchain." + echo >&2 + echo >&2 "Examples:" + echo >&2 + echo >&2 "Check between main and tag 2.1.1 of swift-nio:" + echo >&2 " $0 $(git remote get-url origin) main 2.1.1" + echo >&2 + echo >&2 "Check between HEAD and commit 64cf63d7 using the provided toolchain:" + echo >&2 " xcrun --toolchain org.swift.5120190702a $0 ../some-local-repo HEAD 64cf63d7" +} + +if [[ $# -lt 3 ]]; then + usage + exit 1 +fi + +sdk=/ +if [[ "$(uname -s)" == Darwin ]]; then + sdk=$(xcrun --show-sdk-path) +fi + +hash jq 2> /dev/null || { echo >&2 "ERROR: jq must be installed"; exit 1; } +tmpdir=$(mktemp -d /tmp/.check-api_XXXXXX) +repo_url=$1 +new_tag=$2 +shift 2 + +repodir="$tmpdir/repo" +git clone "$repo_url" "$repodir" +git -C "$repodir" fetch -q origin '+refs/pull/*:refs/remotes/origin/pr/*' +errors=0 + +for old_tag in "$@"; do + mkdir "$tmpdir/api-old" + mkdir "$tmpdir/api-new" + + echo "Checking public API breakages from $old_tag to $new_tag" + + build_and_do "$repodir" "$new_tag" "$tmpdir/api-new/" + build_and_do "$repodir" "$old_tag" "$tmpdir/api-old/" + + for f in "$tmpdir/api-new"/*; do + f=$(basename "$f") + report="$tmpdir/$f.report" + if [[ ! -f "$tmpdir/api-old/$f" ]]; then + echo "NOTICE: NEW MODULE $f" + continue + fi + + echo -n "Checking $f... " + swift api-digester -sdk "$sdk" -diagnose-sdk \ + --input-paths "$tmpdir/api-old/$f" -input-paths "$tmpdir/api-new/$f" 2>&1 \ + > "$report" 2>&1 + + # the shasum here is for an empty report, i.e. no changes + # if the shasum of the new report is different, then there's + # obviously an API change + if ! shasum "$report" | grep -q afd2a1b542b33273920d65821deddc653063c700; then + echo ERROR + echo >&2 "==============================" + echo >&2 "ERROR: public API change in $f" + echo >&2 "==============================" + cat >&2 "$report" + errors=$(( errors + 1 )) + else + echo OK + fi + done + rm -rf "$tmpdir/api-new" "$tmpdir/api-old" +done + +if [[ "$errors" == 0 ]]; then + echo "OK, all seems good" +fi +echo done +exit "$errors" diff --git a/scripts/soundness.sh b/scripts/soundness.sh new file mode 100755 index 0000000..851d0bf --- /dev/null +++ b/scripts/soundness.sh @@ -0,0 +1,87 @@ +#!/bin/bash +##===----------------------------------------------------------------------===## +## +## This source file is part of the OneRoster open source project +## +## Copyright (c) 2021 the OneRoster project authors +## Licensed under Apache License v2.0 +## +## See LICENSE.txt for license information +## +## SPDX-License-Identifier: Apache-2.0 +## +##===----------------------------------------------------------------------===## + +##===----------------------------------------------------------------------===## +## +## This source file is part of the SwiftNIO open source project +## +## Copyright (c) 2017-2019 Apple Inc. and the SwiftNIO project authors +## Licensed under Apache License v2.0 +## +## See LICENSE.txt for license information +## See CONTRIBUTORS.txt for the list of SwiftNIO project authors +## +## SPDX-License-Identifier: Apache-2.0 +## +##===----------------------------------------------------------------------===## + +set -eu +here="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" + +command -v swiftformat >/dev/null 2>&1 || { echo >&2 "swiftformat needs to be installed but is not available in the path."; exit 1; } + +function replace_acceptable_years() { sed -e 's/202[1-9]/YEARS/' ; } +function red_text() { printf '%b%s%b\n' '\033[0;31m' "$1" '\033[0m' ; } +function green_text() { printf '%b%s%b\n' '\033[0;32m' "$1" '\033[0m' ; } + +printf "=> Checking format... " +FIRST_OUT="$(git status --porcelain)" +swiftformat . > /dev/null 2>&1 +SECOND_OUT="$(git status --porcelain)" +if [[ "$FIRST_OUT" != "$SECOND_OUT" ]]; then + red_text 'formatting issues!' + git --no-pager diff + exit 1 +fi +green_text 'okay.' + +printf "=> Checking for unacceptable language... " +# This greps for unacceptable terminology. +unacceptable_terms=( + -e blacklis[t] + -e whitelis[t] + -e slav[e] + -e sanit[y] +) + +# We have to exclude the code of conduct as it gives examples of unacceptable language. +if git grep --color=never -i "${unacceptable_terms[@]}" -- . ":(exclude)CODE_OF_CONDUCT.md" > /dev/null; then + red_text 'Unacceptable language found.' + git grep -i "${unacceptable_terms[@]}" -- . ":(exclude)CODE_OF_CONDUCT.md" + exit 1 +fi +green_text 'okay.' + +printf "=> Checking license headers...\n" +rules="$(sed -e '/^#/d' "${here}/spdx_header_rules.json")" +jq -r '.languages|keys[]' <<<"${rules}" | while read -r lang; do + printf " * checking $lang... " + + lang_hdr="$(jq -r "$(printf '.languages["%s"] as {marker:$m}|.header|($m+.[0]+$m,(.[1:-1][]|$m+.),$m+.[-1]+$m)' "$lang")" <<<"${rules}")" + shebang="$(jq -r "$(printf '.languages["%s"].has_shebang' "$lang")" <<<"${rules}")" + matchexpr="$(jq -r "$(printf '.languages["%s"].match_expression|join(" ")' "$lang")" <<<"${rules}")" + + hdrlines="$(wc -l <<<"${lang_hdr}")" + hdrdigest="$(shasum -U -a 256 <<<"${lang_hdr}")" + headlines=$([[ "${shebang}" == "true" ]] && echo $((hdrlines + 1)) || echo $hdrlines) + + find "${here}/.." \( \! -path './.build/*' -and \( ${matchexpr} \) \) | while read -r path; do + if [[ "$(head -n "${headlines}" "${path}" | tail -n "${hdrlines}" | replace_acceptable_years | shasum -U -a 256)" != "${hdrdigest}" ]]; then + red_text "missing or incorrect headers in file '${path}'!" + diff -u <(head -n "${headlines}" "${path}" | tail -n "${hdrlines}" | replace_acceptable_years) <(echo "${lang_hdr}") + exit 1 + fi + done + green_text 'okay.' +done diff --git a/scripts/spdx_header_rules.json b/scripts/spdx_header_rules.json new file mode 100755 index 0000000..eebf086 --- /dev/null +++ b/scripts/spdx_header_rules.json @@ -0,0 +1,57 @@ +#!/usr/bin/env jq +##===----------------------------------------------------------------------===## +## +## This source file is part of the OneRoster open source project +## +## Copyright (c) 2021 the OneRoster project authors +## Licensed under Apache License v2.0 +## +## See LICENSE.txt for license information +## +## SPDX-License-Identifier: Apache-2.0 +## +##===----------------------------------------------------------------------===## +# Note: The logic which loads this JSON file strips lines beginning with #. + +{ + "header": [ + "===----------------------------------------------------------------------===", + "", + " This source file is part of the OneRoster open source project", + "", + " Copyright (c) YEARS the OneRoster project authors", + " Licensed under Apache License v2.0", + "", + " See LICENSE.txt for license information", + "", + " SPDX-License-Identifier: Apache-2.0", + "", + "===----------------------------------------------------------------------===" + ], + "languages": { + "swift-manifest": { + "match_expression": ["-name", "Package.swift"], + "has_shebang": true, + "marker": "//" + }, + "swift-or-c": { + "match_expression": [ + "(", "-iname", "*.swift", "-and", "-not", "-name", "Package.swift", ")", + "-or", "-iname", "*.c", "-or", "-iname", "*.h" + ], + "has_shebang": false, + "marker": "//" + }, + "shell": { + "match_expression": ["-iname", "*.sh", "-or", "-name", "spdx_header_rules.json"], + "has_shebang": true, + "marker": "##" +# }, +# "header rules example: { +# "match_expression": ["-path", "*/scripts/header example ?.*"], +# "has_shebang": false, +# "marker_prefix_top": "/*", "marker_suffix_top": "*", +# "marker_prefix": " *", "marker_suffix_bottom": "*/" + } + } +}