Skip to content

Commit

Permalink
Make BrokerUpdater obey file structure (#3322)
Browse files Browse the repository at this point in the history
Task/Issue URL:
https://app.asana.com/0/1203581873609357/1208362583268535/f
Tech Design URL:
CC:

**Description**:
Not doing this makes it way too easy to accidentally use the fake
brokers in prod, which windows has already fallen foul of.

**Steps to test this PR**:
1. In the DBP package, in resources, there is one json file at the top
level, rename it so fake isn't in the name. I changed fake to fish.
2. In the actual json file itself, change its name to something you'll
recognize
3. Go into the JSON subdirectory, and change the name of one of those to
something you'll recognize (the actual name in the JSON itself)
4. Start the app
5. Go to the debug menu, under PIR force a broker update
6. In the same menu run PIR in debug mode
7. Look in the list of brokers for the ones you renamed. You SHOULD see
the one in the subdirectory, you SHOULDN'T see the one from the top
level (so if you named them the same as me, there should be no fish)
8. You can also use the DB browser to check

<!--
Tagging instructions
If this PR isn't ready to be merged for whatever reason it should be
marked with the `DO NOT MERGE` label (particularly if it's a draft)
If it's pending Product Review/PFR, please add the `Pending Product
Review` label.

If at any point it isn't actively being worked on/ready for
review/otherwise moving forward (besides the above PR/PFR exception)
strongly consider closing it (or not opening it in the first place). If
you decide not to close it, make sure it's labelled to make it clear the
PRs state and comment with more information.
-->

**Definition of Done**:

* [ ] Does this PR satisfy our [Definition of
Done](https://app.asana.com/0/1202500774821704/1207634633537039/f)?

---
###### Internal references:
[Pull Request Review
Checklist](https://app.asana.com/0/1202500774821704/1203764234894239/f)
[Software Engineering
Expectations](https://app.asana.com/0/59792373528535/199064865822552)
[Technical Design
Template](https://app.asana.com/0/59792373528535/184709971311943)
[Pull Request
Documentation](https://app.asana.com/0/1202500774821704/1204012835277482/f)
  • Loading branch information
THISISDINOSAUR authored Sep 20, 2024
1 parent 4eff24f commit 83a67f8
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 4 deletions.
4 changes: 2 additions & 2 deletions LocalPackages/DataBrokerProtection/Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ let package = Package(
.product(name: "Configuration", package: "BrowserServicesKit"),
.product(name: "Persistence", package: "BrowserServicesKit"),
],
resources: [.process("Resources")],
resources: [.copy("Resources")],
swiftSettings: [
.define("DEBUG", .when(configuration: .debug))
]
Expand All @@ -56,7 +56,7 @@ let package = Package(
"BrowserServicesKit",
],
resources: [
.process("Resources")
.copy("Resources")
]
)
]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,10 @@ final class FileResources: ResourcesRepository {
throw FileResourcesError.bundleResourceURLNil
}

let brokersURL = resourceURL.appendingPathComponent("Resources").appendingPathComponent("JSON")
do {
let fileURLs = try fileManager.contentsOfDirectory(
at: resourceURL,
at: brokersURL,
includingPropertiesForKeys: nil,
options: [.skipsHiddenFiles]
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ final class DataBrokerProtectionDatabaseProviderTests: XCTestCase {
do {
// Sets up a test vault and restores data (with violations) from a `test-vault.sql` file
sut = try DefaultDataBrokerProtectionDatabaseProvider(file: vaultURL, key: key, registerMigrationsHandler: Migrations.v2Migrations)
let fileURL = Bundle.module.url(forResource: "test-vault", withExtension: "sql")!
let fileURL = Bundle.module.url(forResource: "test-vault", withExtension: "sql", subdirectory: "Resources")!
try sut.restoreDatabase(from: fileURL)
} catch {
XCTFail("Failed to create test-vault and insert data")
Expand Down

0 comments on commit 83a67f8

Please sign in to comment.