Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Show error when using audience in non OIDC mode #391

Merged
merged 1 commit into from
Feb 15, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Lock/OptionBuildable.swift
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ internal extension OptionBuildable {
guard !self.allow.isEmpty else { return UnrecoverableError.invalidOptions(cause: "Must allow at least one database mode") }
guard !self.usernameStyle.isEmpty else { return UnrecoverableError.invalidOptions(cause: "Must specify at least one username style") }
guard self.allow.contains(.Login) || self.closable || self.autoClose else { return UnrecoverableError.invalidOptions(cause: "Must enable autoclose or enable closable") }
guard self.oidcConformant || self.audience == nil else { return UnrecoverableError.invalidOptions(cause: "Must set OIDC-Conformant flag in Lock to use audience option") }
return nil
}
}
Expand Down
18 changes: 18 additions & 0 deletions LockTests/OptionsSpec.swift
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,24 @@ class OptionsSpec: QuickSpec {
expect(options.validate()).toNot(beNil())
}

it("should fail setting audience in non OIDC mode") {
options.oidcConformant = false
options.audience = "https://myapi.com"
expect(options.validate()).toNot(beNil())
}

it("should allow no audience in OIDC mode") {
options.oidcConformant = true
options.audience = nil
expect(options.validate()).to(beNil())
}

it("should allow audience in OIDC mode") {
options.oidcConformant = true
options.audience = "https://myapi.com"
expect(options.validate()).to(beNil())
}

context("auto close") {

it("should fail when autoclose is empty and no .Login allowed") {
Expand Down