Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Harness] Fix bug in TCCDb editing that is missing using the watchapp id. #8098

Merged
merged 1 commit into from
Mar 12, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions tests/xharness/Hardware/TCCDatabase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -91,17 +91,17 @@ public async Task AgreeToPromptsAsync (string simRuntime, string TCCDb, ILog log
switch (GetTCCFormat (simRuntime)) {
case 1:
// CREATE TABLE access (service TEXT NOT NULL, client TEXT NOT NULL, client_type INTEGER NOT NULL, allowed INTEGER NOT NULL, prompt_count INTEGER NOT NULL, csreq BLOB, CONSTRAINT key PRIMARY KEY (service, client, client_type));
sql.AppendFormat ("DELETE FROM access WHERE service = '{0}' AND client = '{1}';\n", service, bundle_identifier);
sql.AppendFormat ("INSERT INTO access VALUES('{0}','{1}',0,1,0,NULL);\n", service, bundle_identifier);
sql.AppendFormat ("DELETE FROM access WHERE service = '{0}' AND client = '{1}';\n", service, bundle_id);
sql.AppendFormat ("INSERT INTO access VALUES('{0}','{1}',0,1,0,NULL);\n", service, bundle_id);
break;
case 2:
// CREATE TABLE access (service TEXT NOT NULL, client TEXT NOT NULL, client_type INTEGER NOT NULL, allowed INTEGER NOT NULL, prompt_count INTEGER NOT NULL, csreq BLOB, policy_id INTEGER, PRIMARY KEY (service, client, client_type), FOREIGN KEY (policy_id) REFERENCES policies(id) ON DELETE CASCADE ON UPDATE CASCADE);
sql.AppendFormat ("DELETE FROM access WHERE service = '{0}' AND client = '{1}';\n", service, bundle_identifier);
sql.AppendFormat ("INSERT INTO access VALUES('{0}','{1}',0,1,0,NULL,NULL);\n", service, bundle_identifier);
sql.AppendFormat ("DELETE FROM access WHERE service = '{0}' AND client = '{1}';\n", service, bundle_id);
sql.AppendFormat ("INSERT INTO access VALUES('{0}','{1}',0,1,0,NULL,NULL);\n", service, bundle_id);
break;
case 3: // Xcode 10+
// CREATE TABLE access ( service TEXT NOT NULL, client TEXT NOT NULL, client_type INTEGER NOT NULL, allowed INTEGER NOT NULL, prompt_count INTEGER NOT NULL, csreq BLOB, policy_id INTEGER, indirect_object_identifier_type INTEGER, indirect_object_identifier TEXT, indirect_object_code_identity BLOB, flags INTEGER, last_modified INTEGER NOT NULL DEFAULT (CAST(strftime('%s','now') AS INTEGER)), PRIMARY KEY (service, client, client_type, indirect_object_identifier), FOREIGN KEY (policy_id) REFERENCES policies(id) ON DELETE CASCADE ON UPDATE CASCADE)
sql.AppendFormat ("INSERT OR REPLACE INTO access VALUES('{0}','{1}',0,1,0,NULL,NULL,NULL,'UNUSED',NULL,NULL,{2});\n", service, bundle_identifier, DateTimeOffset.Now.ToUnixTimeSeconds ());
sql.AppendFormat ("INSERT OR REPLACE INTO access VALUES('{0}','{1}',0,1,0,NULL,NULL,NULL,'UNUSED',NULL,NULL,{2});\n", service, bundle_id, DateTimeOffset.Now.ToUnixTimeSeconds ());
break;
default:
throw new NotImplementedException ();
Expand Down
39 changes: 20 additions & 19 deletions tests/xharness/Xharness.Tests/Hardware/Tests/TCCDatabaseTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -101,27 +101,28 @@ public async Task AgreeToPropmtsAsyncSuccessTest (string runtime, int dbVersion)
"kTCCServiceUbiquity",
"kTCCServiceWillow"
};
var expectedArgs = new StringBuilder ();
var expectedArgs = new StringBuilder ("\n");
// assert the sql used depending on the version
switch (dbVersion) {
case 1:
foreach (var s in services) {
expectedArgs.AppendFormat ("INSERT INTO access VALUES('{0}','{1}',0,1,0,NULL);", s, bundleIdentifier);
expectedArgs.AppendFormat ("INSERT INTO access VALUES('{0}','{1}',0,1,0,NULL);", s, bundleIdentifier + ".watchkitapp");
foreach (var id in new [] { bundleIdentifier, bundleIdentifier + ".watchkitapp" }) {
switch (dbVersion) {
case 1:
foreach (var s in services) {
expectedArgs.AppendFormat ("DELETE FROM access WHERE service = '{0}' AND client = '{1}';\n", s, id);
expectedArgs.AppendFormat ("INSERT INTO access VALUES('{0}','{1}',0,1,0,NULL);\n", s, id);
}
break;
case 2:
foreach (var s in services) {
expectedArgs.AppendFormat ("DELETE FROM access WHERE service = '{0}' AND client = '{1}';\n", s, id);
expectedArgs.AppendFormat ("INSERT INTO access VALUES('{0}','{1}',0,1,0,NULL,NULL);\n", s, id);
}
break;
case 3:
foreach (var s in services) {
expectedArgs.AppendFormat ("INSERT OR REPLACE INTO access VALUES('{0}','{1}',0,1,0,NULL,NULL,NULL,'UNUSED',NULL,NULL,{2});\n", s, id, DateTimeOffset.Now.ToUnixTimeSeconds ());
}
break;
}
break;
case 2:
foreach (var s in services) {
expectedArgs.AppendFormat ("INSERT INTO access VALUES('{0}','{1}',0,1,0,NULL,NULL);", s, bundleIdentifier);
expectedArgs.AppendFormat ("INSERT INTO access VALUES('{0}','{1}',0,1,0,NULL,NULL);", s, bundleIdentifier + ".watchkitapp");
}
break;
case 3:
foreach (var s in services) {
expectedArgs.AppendFormat ("INSERT OR REPLACE INTO access VALUES('{0}','{1}',0,1,0,NULL,NULL,NULL,'UNUSED',NULL,NULL,{2});", s, bundleIdentifier, DateTimeOffset.Now.ToUnixTimeSeconds ());
expectedArgs.AppendFormat ("INSERT OR REPLACE INTO access VALUES('{0}','{1}',0,1,0,NULL,NULL,NULL,'UNUSED',NULL,NULL,{2});", s, bundleIdentifier + ".watchkitapp", DateTimeOffset.Now.ToUnixTimeSeconds ());
}
break;
}
string processName = null;
IList<string> args = new List<string> ();
Expand Down