You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
62 lines
1.8 KiB
62 lines
1.8 KiB
//
|
|
// TokenExemptionTests.swift
|
|
// PadelClubTests
|
|
//
|
|
// Created by Laurent Morvillier on 14/05/2024.
|
|
//
|
|
|
|
|
|
import XCTest
|
|
import LeStorage
|
|
@testable import PadelClub
|
|
|
|
final class TokenExemptionTests: XCTestCase {
|
|
|
|
let username: String = "test"
|
|
let password: String = "MyPass1234--"
|
|
|
|
override func setUpWithError() throws {
|
|
StoreCenter.main.configureURLs(secureScheme: false, domain: "127.0.0.1:8000")
|
|
StoreCenter.main.disconnect()
|
|
}
|
|
|
|
override func tearDownWithError() throws {
|
|
// Put teardown code here. This method is called after the invocation of each test method in the class.
|
|
}
|
|
|
|
func testClubCreation() async throws {
|
|
|
|
let user = try await self.login()
|
|
StoreCenter.main.disconnect()
|
|
|
|
let club: Club = Club(name: "mon club 2", acronym: "MC", phone: "132", code: "456", address: "l'adresse", city: "la ville", zipCode: "13131", latitude: 13.11111, longitude: 1.121212)
|
|
|
|
if let c = try await StoreCenter.main.service().post(club) {
|
|
assert(c.id == club.id)
|
|
} else {
|
|
XCTFail("missing data")
|
|
}
|
|
|
|
do {
|
|
_ = try await StoreCenter.main.service().put(club)
|
|
assertionFailure("the request above should fail without an authenticated user")
|
|
} catch {
|
|
// good stuff
|
|
}
|
|
|
|
let _ = try await self.login()
|
|
club.creator = user.id
|
|
|
|
if let uc = try await StoreCenter.main.service().put(club) {
|
|
assert(uc.creator == user.id)
|
|
} else {
|
|
XCTFail("missing data")
|
|
}
|
|
}
|
|
|
|
func login() async throws -> CustomUser {
|
|
let user: CustomUser = try await StoreCenter.main.service().login(username: self.username, password: self.password)
|
|
return user
|
|
}
|
|
|
|
}
|
|
|