diff --git a/Tests/TartTests/WWWAuthenticateTests.swift b/Tests/TartTests/WWWAuthenticateTests.swift new file mode 100644 index 00000000..1e00d265 --- /dev/null +++ b/Tests/TartTests/WWWAuthenticateTests.swift @@ -0,0 +1,18 @@ +import XCTest +@testable import tart + +final class WWWAuthenticateTests: XCTestCase { + func testExample() throws { + // Test example from Token Authentication Specification[1] + // + // [1]: https://docs.docker.com/registry/spec/auth/token/ + let wwwAuthenticate = try WWWAuthenticate(rawHeaderValue: "Bearer realm=\"https://auth.docker.io/token\",service=\"registry.docker.io\",scope=\"repository:samalba/my-app:pull,push\"") + + XCTAssertEqual("Bearer", wwwAuthenticate.scheme) + XCTAssertEqual([ + "realm": "https://auth.docker.io/token", + "service": "registry.docker.io", + "scope": "repository:samalba/my-app:pull,push", + ], wwwAuthenticate.kvs) + } +}