File: test_utils.html

package info (click to toggle)
firefox 143.0.3-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 4,617,328 kB
  • sloc: cpp: 7,478,492; javascript: 6,417,157; ansic: 3,720,058; python: 1,396,372; xml: 627,523; asm: 438,677; java: 186,156; sh: 63,477; makefile: 19,171; objc: 13,059; perl: 12,983; yacc: 4,583; cs: 3,846; pascal: 3,405; lex: 1,720; ruby: 1,003; exp: 762; php: 436; lisp: 258; awk: 247; sql: 66; sed: 53; csh: 10
file content (101 lines) | stat: -rw-r--r-- 4,026 bytes parent folder | download | duplicates (12)
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
92
93
94
95
96
97
98
99
100
101
<!DOCTYPE HTML>
<html>

<head>
  <title>Test for Messaging Layer Security</title>
  <!-- SimpleTest Helpers -->
  <script src="/tests/SimpleTest/SimpleTest.js"></script>
  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
  <!-- Local Helpers -->
  <script src="head_mls.js"></script>
</head>

<body>
  <pre id="test">
<script class="testbody" type="text/javascript">

  async function test_utils_get_group_identifier_and_epoch() {

    const mls = new MLS();

    // Generate Identities for Alice and Bob
    let alice = await mls.generateIdentity();
    let bob = await mls.generateIdentity();

    // Generate Credentials for Alice and Bob
    let credential_alice = await mls.generateCredential("alice");
    let credential_bob = await mls.generateCredential("bob");

    // Generate a KeyPackage for Bob
    let kp_bob = await mls.generateKeyPackage(bob, credential_bob);

    // Creation of a Group by Alice
    let group_alice = await mls.groupCreate(alice, credential_alice);

    // Test: compare the group identifier to the invalid value
    info("Group Id:", byteArrayToHexString(group_alice.groupId));
    isnot(byteArrayToHexString(group_alice.groupId), "", "Group Identifier != ''");

    // Alice adds Bob to a group
    let commit_output = await group_alice.add(kp_bob);

    // Test: compare the commit output to the invalid value
    info("Commit Output:", byteArrayToHexString(commit_output.commit));
    isnot(byteArrayToHexString(commit_output.commit), "", "Commit != ''");

    // Get the group details
    let details = await group_alice.details();
    info("Group Id:", byteArrayToHexString(details.groupId));
    info("Group Epoch:", byteArrayToHexString(details.groupEpoch));

    // Get the group identifier from the commit
    let gid_commit = await mls.getGroupIdFromMessage(commit_output.commit);
    info("Group Id from Commit Message:", byteArrayToHexString(gid_commit.content));

    // Get the group identifier from the commit
    let epoch_commit = await mls.getGroupEpochFromMessage(commit_output.commit);
    info("Group Epoch from Commit Message:", byteArrayToHexString(epoch_commit.content));

    // Note: the following is forbidden because Welcome is not an MLSMessage
    // let gid_welcome = await mls.getGroupIdFromMessage(commit_output.welcome);
    // info("Group Id from Welcome Message:", byteArrayToHexString(gid_welcome.content));

    // Test: compare the group id of the commit to the current group id
    is(byteArrayToHexString(details.groupId), byteArrayToHexString(gid_commit.content));
    // Test: compare the group epoch of the commit to the current group epoch
    is(byteArrayToHexString(details.groupEpoch), byteArrayToHexString(epoch_commit.content));

    // Alice: process her Add commit
    await group_alice.receive(commit_output.commit);

    // Get the group details after processing the commit
    let details2 = await group_alice.details();
    info("Group Epoch 2:", byteArrayToHexString(details2.groupEpoch));

    // Alice: removed Bob
    let commit_output2 = await group_alice.remove(bob);

    // Get the group identifier from the commit
    let gid_commit2 = await mls.getGroupIdFromMessage(commit_output2.commit);
    info("Group Id 2 from Commit Message 2:", byteArrayToHexString(gid_commit2.content));

    // Get the group identifier from the commit2
    let epoch_commit2 = await mls.getGroupEpochFromMessage(commit_output2.commit);
    info("Group Epoch 2 from Commit Message 2:", byteArrayToHexString(epoch_commit2.content));

    // Test: compare the group id of the commit to the current group id
    is(byteArrayToHexString(details2.groupId), byteArrayToHexString(gid_commit2.content));
    // Test: compare the group epoch of the commit to the current group epoch
    is(byteArrayToHexString(details2.groupEpoch), byteArrayToHexString(epoch_commit2.content));

    SimpleTest.finish();
  }

  SimpleTest.waitForExplicitFinish();
  test_utils_get_group_identifier_and_epoch();

</script>
</pre>
</body>

</html>