<commit_before>import Quick
import Nimble
import Moya
import Result

final class AccessTokenPluginSpec: QuickSpec {
    struct TestTarget: TargetType, AccessTokenAuthorizable {
        let baseURL = URL(string: "http://www.api.com/")!
        let path = ""
        let method = Method.get
        let task = Task.requestPlain
        let sampleData = Data()
        let headers: [String: String]? = nil
        let authorizationType: AuthorizationType
    }

    let token = "eyeAm.AJsoN.weB<PASSWORD>"
    lazy var plugin = AccessTokenPlugin(tokenClosure: self.token)
    
    override func spec() {

        it("doesn't add an authorization header to TargetTypes by default") {
            let target = GitHub.zen
            let request = URLRequest(url: target.baseURL)
            let preparedRequest = plugin.prepare(request, target: target)
            expect(preparedRequest.allHTTPHeaderFields).to(beNil())
        }

        it("doesn't add an authorization header to AccessTokenAuthorizables when AuthorizationType is .none") {
            
            let authorizationType: AuthorizationType = .none
            let preparedRequest = self.createPreparedRequest(for: authorizationType)
            expect(preparedRequest.allHTTPHeaderFields).to(beNil())
        }

        it("adds a basic authorization header to AccessTokenAuthorizables when AuthorizationType is .basic") {
            
            let authorizationType: AuthorizationType = .basic
            let preparedRequest = self.createPreparedRequest(for: authorizationType)
            expect(preparedRequest.allHTTPHeaderFields) == ["Authorization": "\(authorizationType.value) \(self.token)"]
        }
        
        it("adds a bearer authorization header to AccessTokenAuthorizables when AuthorizationType is .bearer") {
            
            let authorizationType: AuthorizationType = .bearer
            let preparedRequest = self.createPreparedRequest(for: authorizationType)
            expect(preparedRequest.allHTTPHeaderFields) == ["Authorization": "\(authorizationType.value) \(self.token)"]
        }
        <commit_msg>fix explicit 'self' in test file.<commit_after>import Quick
import Nimble
import Moya
import Result

final class AccessTokenPluginSpec: QuickSpec {
    struct TestTarget: TargetType, AccessTokenAuthorizable {
        let baseURL = URL(string: "http://www.api.com/")!
        let path = ""
        let method = Method.get
        let task = Task.requestPlain
        let sampleData = Data()
        let headers: [String: String]? = nil
        let authorizationType: AuthorizationType
    }

    let token = "<PASSWORD>"
    lazy var plugin = AccessTokenPlugin(tokenClosure: self.token)
    
    override func spec() {

        it("doesn't add an authorization header to TargetTypes by default") {
            let target = GitHub.zen
            let request = URLRequest(url: target.baseURL)
            let preparedRequest = self.plugin.prepare(request, target: target)
            expect(preparedRequest.allHTTPHeaderFields).to(beNil())
        }

        it("doesn't add an authorization header to AccessTokenAuthorizables when AuthorizationType is .none") {
            
            let authorizationType: AuthorizationType = .none
            let preparedRequest = self.createPreparedRequest(for: authorizationType)
            expect(preparedRequest.allHTTPHeaderFields).to(beNil())
        }

        it("adds a basic authorization header to AccessTokenAuthorizables when AuthorizationType is .basic") {
            
            let authorizationType: AuthorizationType = .basic
            let preparedRequest = self.createPreparedRequest(for: authorizationType)
            expect(preparedRequest.allHTTPHeaderFields) == ["Authorization": "\(authorizationType.value) \(self.token)"]
        }
        
        it("adds a bearer authorization header to AccessTokenAuthorizables when AuthorizationType is .bearer") {
            
            let authorizationType: AuthorizationType = .bearer
            let preparedRequest = self.createPreparedRequest(for: authorizationType)
            expect(preparedRequest.allHTTPHeaderFields) == ["Authorization": "\(authorizationType.value) \(self.token)"]
        }
        
{'fraction_non_alphanumeric': 0.08356940509915015, 'fraction_numerical': 0.0, 'mean_word_length': 2.7101576182136604, 'pattern_counts': {'":': 4, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2626185', 'n_tokens_mistral': 1076, 'n_tokens_neox': 1027, 'n_words': 281}