Repository: vapor/vapor
File: Tests/VaporTests/PasswordTests.swift (Swift)

Code before:
    }
    
    func testAsyncPlaintextRequestPassword() throws {
        let test = Environment(name: "testing", arguments: ["vapor"])
        let app = Application(test)
        defer { app.shutdown() }
        
        try assertAsyncRequestPasswordVerifies(.plaintext, on: app)
    }
    
    func testAsyncBCryptApplicationPassword() throws {
        let test = Environment(name: "testing", arguments: ["vapor"])
        let app = Application(test)
        defer { app.shutdown() }
        
        try assertAsyncApplicationPasswordVerifies(.bcrypt, on: app)
    }
    
    func testAsyncPlaintextApplicationPassword() throws {
        let test = Environment(name: "testing", arguments: ["vapor"])
        let app = Application(test)
        defer { app.shutdown() }
        
        try assertAsyncApplicationPasswordVerifies(.plaintext, on: app)
    }
    
    private func assertAsyncApplicationPasswordVerifies(
        _ provider: Application.Passwords.Provider,
        on app: Application,
        file: StaticString = #file,
        line: UInt = #line
    ) throws {
        app.passwords.use(provider)
        
        let asyncHash = try app.password
            .async(on: app.threadPool, hopTo: app.eventLoopGroup.next())
            .digest("vapor")
            .wait()
        
        let asyncVerifiy = try app.password
            .async(on: app.threadPool, hopTo: app.eventLoopGroup.next())
            .verify("vapor", created: asyncHash)
            .wait()
        
        XCTAssertTrue(asyncVerifiy, file: file, line: line)
    }
    
    private func assertAsyncRequestPasswordVerifies(
        _ provider: Application.Passwords.Provider,
        on app: Application,
        file: StaticString = #file,

Review comment (suggestion):
Can you add one final test to ensure the test works 😆 Basically just to make sure the async password uses the requested provider
```suggestion
    
    func testAsyncUsesProvider() throws {
         let test = Environment(name: "testing", arguments: ["vapor"])
         let app = Application(test)
         defer { app.shutdown() }
         app.passwords.use(.plaintext)
         let hash = try app.password.async(on: app.threadPool, hopTo: app.eventLoopGroup.next()).digest("vapor").wait()
         XCTAssertEqual(hash, "vapor")
     }
     
```

Code after:
    }
    
    func testAsyncPlaintextRequestPassword() throws {
        let test = Environment(name: "testing", arguments: ["vapor"])
        let app = Application(test)
        defer { app.shutdown() }
        
        try assertAsyncRequestPasswordVerifies(.plaintext, on: app)
    }
    
    func testAsyncBCryptApplicationPassword() throws {
        let test = Environment(name: "testing", arguments: ["vapor"])
        let app = Application(test)
        defer { app.shutdown() }
        
        try assertAsyncApplicationPasswordVerifies(.bcrypt, on: app)
    }
    
    func testAsyncPlaintextApplicationPassword() throws {
        let test = Environment(name: "testing", arguments: ["vapor"])
        let app = Application(test)
        defer { app.shutdown() }
        
        try assertAsyncApplicationPasswordVerifies(.plaintext, on: app)
    }
    
    func testAsyncUsesProvider() throws {
        let test = Environment(name: "testing", arguments: ["vapor"])
        let app = Application(test)
        defer { app.shutdown() }
        app.passwords.use(.plaintext)
        let hash = try app.password.async(on: app.threadPool, hopTo: app.eventLoopGroup.next()).digest("vapor").wait()
        XCTAssertEqual(hash, "vapor")
    }
    
    private func assertAsyncApplicationPasswordVerifies(
        _ provider: Application.Passwords.Provider,
        on app: Application,
        file: StaticString = #file,
        line: UInt = #line
    ) throws {
        app.passwords.use(provider)
        
        let asyncHash = try app.password
            .async(on: app.threadPool, hopTo: app.eventLoopGroup.next())
            .digest("vapor")
            .wait()
        
        let asyncVerifiy = try app.password
            .async(on: app.threadPool, hopTo: app.eventLoopGroup.next())
            .verify("vapor", created: asyncHash)