๐Ÿ“ฆ ionic-team / trapeze

๐Ÿ“„ ios.entitlements.test.ts ยท 92 lines
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92import { copy } from '@ionic/utils-fs';
import { join } from 'path';
import { temporaryDirectory } from 'tempy';

import { Context, loadContext } from '../../src/ctx';
import { IosEntitlementsOperation, Operation } from '../../src/definitions';
import Op from '../../src/operations/ios/entitlements';

describe('op: ios.entitlements', () => {
  let dir: string;
  let ctx: Context;

  beforeEach(async () => {
    dir = temporaryDirectory();

    await copy('../common/test/fixtures/ios-and-android', dir);

    ctx = await loadContext(dir);
    ctx.args.quiet = true;
  });

  it('should add to entitlements', async () => {
    const op: IosEntitlementsOperation = {
      value: [
        {
          'keychain-access-groups': ['com.microsoft.intune.mam', 'com.microsoft.adalcache']
        },
      ],
    };

    await Op(ctx, op as Operation);

    const entitlements = await ctx.project.ios!.getEntitlements('App');
    expect(entitlements).toMatchObject({
      'keychain-access-groups': ['com.microsoft.intune.mam', 'com.microsoft.adalcache']
    });
  });

  it('should add entitlements with config', async () => {
    let op: IosEntitlementsOperation = {
      value: {
        replace: false,
        entries: [
          {
            'keychain-access-groups': ['com.microsoft.intune.mam', 'com.microsoft.adalcache']
          }
        ]
      },
    };

    await Op(ctx, op as Operation);

    const entitlements = await ctx.project.ios!.getEntitlements('App');
    expect(entitlements).toMatchObject({
      'keychain-access-groups': ['com.microsoft.intune.mam', 'com.microsoft.adalcache']
    });
  });

  it('should set entitlements', async () => {
    let op: IosEntitlementsOperation = {
      value: {
        replace: true,
        entries: [
          {
            'keychain-access-groups': ['com.microsoft.intune.mam', 'com.microsoft.adalcache']
          }
        ]
      },
    };

    await Op(ctx, op as Operation);

    op = {
      value: {
        replace: true,
        entries: [
          {
            'keychain-access-groups': ['com.ionicframework.blah']
          }
        ]
      },
    };

    await Op(ctx, op as Operation);

    const entitlements = await ctx.project.ios!.getEntitlements('App');
    expect(entitlements).toMatchObject({
      'keychain-access-groups': ['com.ionicframework.blah']
    });
  });
});