Skip to content

Commit

Permalink
udpate tests
Browse files Browse the repository at this point in the history
  • Loading branch information
nodeselector committed Aug 2, 2024
1 parent e9dbb9a commit c9b0030
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 15 deletions.
7 changes: 2 additions & 5 deletions __tests__/app-store-connect-api-key.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,16 +30,13 @@ describe('certificate', () => {

await appStoreConnectApiKey(base64ApiKey, testDir)

const gotAppStoreAuthObjPath = path.join(
testDir,
'.app-store-connect-api-key.json'
)
const gotAppStoreAuthObjPath = path.join(testDir, 'keyinfo.json')
const gotAppStoreAuthObj = JSON.parse(
fs.readFileSync(gotAppStoreAuthObjPath, 'utf-8')
)
expect(gotAppStoreAuthObj).toEqual(appStoreConnectConfig)

const privateKeyPath = path.join(testDir, '.app-store-connect-api-key.p8')
const privateKeyPath = path.join(testDir, 'AuthKey_keyId.p8')
const gotPrivateKey = fs.readFileSync(privateKeyPath, 'utf-8')
expect(gotPrivateKey).toEqual(
Buffer.from(appStoreConnectConfig.privateKey, 'base64').toString('utf-8')
Expand Down
2 changes: 1 addition & 1 deletion badges/coverage.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion dist/index.js.map

Large diffs are not rendered by default.

18 changes: 10 additions & 8 deletions src/app-store-connect-api-key.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,20 +11,20 @@ type AppStoreAuthConfig = {

export async function appStoreConnectApiKey(
secretValue: string,
destinationDir: string = ''
destinationDir = ''
): Promise<void> {
if (!destinationDir) {
// see man altool for path expectations. most of the xcode tools allow you to specify a path
// but notably, not altool.
destinationDir = path.join(process.env.HOME as string, '.appstoreconnect/private_keys')
destinationDir = path.join(
process.env.HOME as string,
'.appstoreconnect/private_keys'
)
fs.mkdirSync(destinationDir, { recursive: true })
}
const decodedSecret = Buffer.from(secretValue, 'base64').toString('utf-8')
const appStoreAuthConfig: AppStoreAuthConfig = JSON.parse(decodedSecret)
const apiKeyPath = path.join(
destinationDir,
'keyinfo.json'
)
const apiKeyPath = path.join(destinationDir, 'keyinfo.json')
fs.writeFileSync(apiKeyPath, decodedSecret)
const decodedPrivateKey = Buffer.from(
appStoreAuthConfig.privateKey,
Expand All @@ -38,8 +38,10 @@ export async function appStoreConnectApiKey(

core.setOutput('app-store-connect-api-key-key-path', privateKeyPath)
core.setOutput('app-store-connect-api-key-key-id', appStoreAuthConfig.keyId)
core.setOutput('app-store-connect-api-key-issuer-id', appStoreAuthConfig.issuerId)

core.setOutput(
'app-store-connect-api-key-issuer-id',
appStoreAuthConfig.issuerId
)
}

export async function buildAppStoreConnectApiKeyObject(
Expand Down

0 comments on commit c9b0030

Please sign in to comment.