Skip to content

Commit

Permalink
Merge pull request #235 from ForgeRock/2700-request-cache-control-2
Browse files Browse the repository at this point in the history
Set default Session Configuration's urlCache to nil
  • Loading branch information
spetrov authored Oct 3, 2023
2 parents 3e8867c + 8a3df9b commit 956fe92
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 3 deletions.
5 changes: 4 additions & 1 deletion FRCore/FRCore/Network/RestClient.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// RestClient.swift
// FRCore
//
// Copyright (c) 2020 ForgeRock. All rights reserved.
// Copyright (c) 2020-2023 ForgeRock. All rights reserved.
//
// This software may be modified and distributed under the terms
// of the MIT license. See the LICENSE file for details.
Expand Down Expand Up @@ -30,9 +30,12 @@ public class RestClient: NSObject {
static var defaultURLSessionConfiguration: URLSessionConfiguration {
get {
let config = URLSessionConfiguration.default
// Setting `httpCookieStorage` to nil disables cookie storage
config.httpCookieStorage = nil
config.httpCookieAcceptPolicy = .never
config.httpShouldSetCookies = false
// Setting `urlCache` to nil disables caching
config.urlCache = nil
return config
}
}
Expand Down
11 changes: 9 additions & 2 deletions FRCore/FRCoreTests/FRCore/Network/RestClientTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// RestClientTests.swift
// FRCoreTests
//
// Copyright (c) 2020 ForgeRock. All rights reserved.
// Copyright (c) 2020-2023 ForgeRock. All rights reserved.
//
// This software may be modified and distributed under the terms
// of the MIT license. See the LICENSE file for details.
Expand Down Expand Up @@ -125,5 +125,12 @@ class RestClientTests: FRBaseTestCase {
break
}
}


func test_04_test_cache_control() {

RestClient.shared.setURLSessionConfiguration(config: RestClient.defaultURLSessionConfiguration)

XCTAssertNil(RestClient.shared._urlSession?.configuration.urlCache)
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,14 @@
BlueprintName = "FRAuthTests"
ReferencedContainer = "container:../FRAuth/FRAuth.xcodeproj">
</BuildableReference>
<SkippedTests>
<Test
Identifier = "AA_05_DeviceBindingCallbackTest">
</Test>
<Test
Identifier = "AA_06_DeviceSigningVerifierCallbackTest">
</Test>
</SkippedTests>
</TestableReference>
<TestableReference
skipped = "NO">
Expand Down

0 comments on commit 956fe92

Please sign in to comment.