File tree Expand file tree Collapse file tree 2 files changed +14
-5
lines changed
Sources/App/Core/Authentication Expand file tree Collapse file tree 2 files changed +14
-5
lines changed Original file line number Diff line number Diff line change @@ -55,10 +55,10 @@ extension User {
5555 static var builder : Self { . init( name: " builder " , identifier: " builder " ) }
5656
5757 struct BuilderAuthenticator : AsyncBearerAuthenticator {
58+ @Dependency ( \. environment) var environment
59+
5860 func authenticate( bearer: BearerAuthorization , for request: Request ) async throws {
59- @Dependency ( \. environment) var environment
60- if let builderToken = environment. builderToken ( ) ,
61- bearer. token == builderToken {
61+ if let token = environment. builderToken ( ) , bearer. token == token {
6262 request. auth. login ( User . builder)
6363 }
6464 }
Original file line number Diff line number Diff line change 1414
1515@testable import App
1616
17+ import Dependencies
1718import NIOConcurrencyHelpers
1819import PostgresNIO
1920import SQLKit
@@ -35,8 +36,16 @@ class AppTestCase: XCTestCase {
3536 }
3637
3738 func setup( _ environment: Environment ) async throws -> Application {
38- try await Self . setupDb ( environment)
39- return try await Self . setupApp ( environment)
39+ try await withDependencies {
40+ // Setting builderToken here when it's also set in all tests may seem redundant but it's
41+ // what allows test_post_buildReport_large to work.
42+ // See https://github.com/pointfreeco/swift-dependencies/discussions/300#discussioncomment-11252906
43+ // for details.
44+ $0. environment. builderToken = { " secr3t " }
45+ } operation: {
46+ try await Self . setupDb ( environment)
47+ return try await Self . setupApp ( environment)
48+ }
4049 }
4150
4251 override func tearDown( ) async throws {
You can’t perform that action at this time.
0 commit comments