Skip to content

Commit

Permalink
Add "Generate individual keys" user role (#149)
Browse files Browse the repository at this point in the history
* Add GENERATE_INDIVIDUAL_KEYS user role

* Regenerate

---------

Co-authored-by: Morten Bjerg Gregersen <[email protected]>
  • Loading branch information
MortenGregersen and MortenGregersen authored Jan 17, 2024
1 parent 5e2b467 commit 977c832
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 13 deletions.
27 changes: 14 additions & 13 deletions Sources/Bagbutik-Models/Extensions/UserRole+PrettyName.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,21 @@ public extension UserRole {
/// A pretty name for the case. The names are added as best effort, and a better name could exist.
var prettyName: String {
switch self {
case .admin: return "Admin"
case .finance: return "Finance"
case .accessToReports: return "Access to Reports"
case .sales: return "Sales"
case .developer: return "Developer"
case .appManager: return "App Manager"
case .customerSupport: return "Customer Support"
case .marketing: return "Marketing"
case .accountHolder: return "Account Holder"
case .admin: "Admin"
case .finance: "Finance"
case .accessToReports: "Access to Reports"
case .sales: "Sales"
case .developer: "Developer"
case .appManager: "App Manager"
case .customerSupport: "Customer Support"
case .marketing: "Marketing"
case .accountHolder: "Account Holder"
// Not mentioned in documentation: https://developer.apple.com/support/roles
case .createApps: return "Create Apps"
case .cloudManagedDeveloperId: return "Cloud Managed Developer ID"
case .cloudManagedAppDistribution: return "Cloud Managed App Distribution"
case .imageManager: return "Image Manager"
case .createApps: "Create Apps"
case .cloudManagedDeveloperId: "Cloud Managed Developer ID"
case .cloudManagedAppDistribution: "Cloud Managed App Distribution"
case .imageManager: "Image Manager"
case .generateIndividualKeys: "Generate Individual Keys"
}
}
}
1 change: 1 addition & 0 deletions Sources/Bagbutik-Models/Users/UserRole.swift
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,5 @@ public enum UserRole: String, ParameterValue, Codable, CaseIterable {
case cloudManagedDeveloperId = "CLOUD_MANAGED_DEVELOPER_ID"
/// Permission to submit requests for apps and software to be signed by a cloud-managed Apple Distribution certificate. App Store Connect automatically creates a certificate if one doesn’t exist. The system grants this permission by default to Account Holder and Admin roles. Account Holder, Admin, and App Manager roles may grant access to this permission to other users with App Manager or Developer roles. This permission requires that the user has access to Certificates, Identifiers & Profiles.
case cloudManagedAppDistribution = "CLOUD_MANAGED_APP_DISTRIBUTION"
case generateIndividualKeys = "GENERATE_INDIVIDUAL_KEYS"
}
9 changes: 9 additions & 0 deletions Sources/BagbutikSpecDecoder/Spec.swift
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,15 @@ public struct Spec: Decodable {
deviceSchema.properties["attributes"]?.type = .schema(deviceAttributesSchema)
components.schemas["Device"] = .object(deviceSchema)
}

// Add the case `GENERATE_INDIVIDUAL_KEYS` to UserRole
// Apple's OpenAPI spec doesn't include the role for generating individual keys. Reported to Apple 17/1/24 as FB13546172.
if case .enum(var userRoleSchema) = components.schemas["UserRole"] {
if !userRoleSchema.cases.contains(where: { $0.value == "GENERATE_INDIVIDUAL_KEYS" }) {
userRoleSchema.cases.append(EnumCase(id: "generateIndividualKeys", value: "GENERATE_INDIVIDUAL_KEYS"))
}
components.schemas["UserRole"] = .enum(userRoleSchema)
}

// Add the case `VISION_OS` to Platform
// Apple's OpenAPI spec doesn't include visionOS for App Categories. Reported to Apple 28/8/23 as FB13071298.
Expand Down
11 changes: 11 additions & 0 deletions Tests/BagbutikSpecDecoderTests/SpecTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -835,6 +835,10 @@ final class SpecTests: XCTestCase {
"type" : "string",
"enum" : [ "IOS", "MAC_OS", "TV_OS" ]
},
"UserRole" : {
"type" : "string",
"enum" : [ "ADMIN", "FINANCE", "ACCOUNT_HOLDER" ]
},
"ScreenshotDisplayType" : {
"type" : "string",
"enum" : [ "APP_IPHONE_67", "APP_APPLE_TV", "APP_DESKTOP" ]
Expand Down Expand Up @@ -895,6 +899,13 @@ final class SpecTests: XCTestCase {
let platformCaseValues = bundleIdPlatformSchema.cases.map(\.value)
XCTAssertEqual(platformCaseValues.count, 4)
XCTAssertTrue(platformCaseValues.contains("VISION_OS"))

guard case .enum(let userRoleSchema) = spec.components.schemas["UserRole"] else {
XCTFail(); return
}
let userRoleCaseValues = userRoleSchema.cases.map(\.value)
XCTAssertEqual(userRoleCaseValues.count, 4)
XCTAssertTrue(userRoleCaseValues.contains("GENERATE_INDIVIDUAL_KEYS"))

guard case .enum(let screenshotDisplayTypeSchema) = spec.components.schemas["ScreenshotDisplayType"] else {
XCTFail(); return
Expand Down

0 comments on commit 977c832

Please sign in to comment.