Skip to content
Draft
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
13 changes: 13 additions & 0 deletions ios/BUILD
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
load("@bazel_skylib//rules:build_test.bzl", "build_test")
load("@rules_apple//apple:ios.bzl", "ios_application", "ios_ui_test", "ios_unit_test")
load("@rules_apple//apple:macos.bzl", "macos_unit_test")
load("@rules_swift//swift:swift.bzl", "swift_library")

swift_library(
Expand Down Expand Up @@ -52,4 +53,16 @@ ios_ui_test(
runner = "@rules_apple//apple/testing/default_runner:ios_xctestrun_ordered_runner",
test_host = ":HelloApp",
deps = [":HelloAppUITestLib"],
exec_properties = {
"sandboxAllowed": "False",
},
)

macos_unit_test(
name = "HelloMacTest",
minimum_os_version = "14.0",
deps = [":HelloTestLib"],
exec_properties = {
"sandboxAllowed": "False",
},
)
10 changes: 4 additions & 6 deletions ios/HelloTest.swift
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
import Testing
import XCTest

@Suite
struct HelloTest {
@Test
func example() {
class HelloTest: XCTestCase {
func testExample() {
print("Hello from HelloTest")
#expect(1 + 1 == 2)
XCTAssertEqual(1 + 1, 2)
}
}
38 changes: 38 additions & 0 deletions ios/kcpasswd.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
#!/usr/bin/env python3

# Port of Gavin Brock's Perl kcpassword generator to Python, by Tom Taylor
# <tom@tomtaylor.co.uk>.
# Perl version: http://www.brock-family.org/gavin/perl/kcpassword.html
# https://github.com/timsutton/osx-vm-templates/blob/master/scripts/support/set_kcpassword.py

import getpass
import sys
import os


def kcpassword(passwd):
# The magic 11 bytes - these are just repeated
# 0x7D 0x89 0x52 0x23 0xD2 0xBC 0xDD 0xEA 0xA3 0xB9 0x1F
key = [125, 137, 82, 35, 210, 188, 221, 234, 163, 185, 31]
key_len = len(key)

passwd = list(bytearray(passwd, "utf8"))
# pad passwd length out to an even multiple of key length
r = len(passwd) % key_len
if (r > 0):
passwd = passwd + [0] * (key_len - r)

for n in range(0, len(passwd), len(key)):
for j in range(n, min(n + len(key), len(passwd))):
passwd[j] = passwd[j] ^ key[j % key_len]

return bytearray(passwd)


if __name__ == "__main__":
secret = getpass.getpass("Autologin user password: ")
passwd = kcpassword(secret)
fd = os.open('/etc/kcpassword', os.O_WRONLY | os.O_CREAT, 0o600)
file = os.fdopen(fd, 'wb')
file.write(passwd)
file.close()
Loading