@nymphjs/tilmeld 1.0.0-beta.111 → 1.0.0-beta.113
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +10 -0
- package/dist/Tilmeld.js +84 -36
- package/dist/Tilmeld.js.map +1 -1
- package/dist/testArtifacts.js +214 -1
- package/dist/testArtifacts.js.map +1 -1
- package/package.json +9 -7
- package/src/Tilmeld.ts +109 -29
- package/src/testArtifacts.ts +440 -1
package/src/testArtifacts.ts
CHANGED
|
@@ -1,4 +1,9 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
Entity,
|
|
3
|
+
Nymph,
|
|
4
|
+
TilmeldAccessLevels,
|
|
5
|
+
TilmeldAccessRequest,
|
|
6
|
+
} from '@nymphjs/nymph';
|
|
2
7
|
|
|
3
8
|
import Tilmeld from './Tilmeld.js';
|
|
4
9
|
import { AccessControlError } from './errors/index.js';
|
|
@@ -1482,4 +1487,438 @@ export function TilmeldTest(
|
|
|
1482
1487
|
|
|
1483
1488
|
expect(testEntityAlice).toBeNull();
|
|
1484
1489
|
});
|
|
1490
|
+
|
|
1491
|
+
it('alice can access an entity with an access request', async () => {
|
|
1492
|
+
const { bob, alice } = await makeUsers();
|
|
1493
|
+
|
|
1494
|
+
await tilmeld.fillSession(alice);
|
|
1495
|
+
|
|
1496
|
+
const alicesEntity = await TestModel.factory();
|
|
1497
|
+
alicesEntity.name = "Alice's Entity";
|
|
1498
|
+
expect(await alicesEntity.$save()).toEqual(true);
|
|
1499
|
+
|
|
1500
|
+
expect(alicesEntity.guid).not.toBeNull();
|
|
1501
|
+
expect(alice.$is(alicesEntity.user)).toEqual(true);
|
|
1502
|
+
|
|
1503
|
+
const testEntityAlice = await nymph.getEntity(
|
|
1504
|
+
{ class: TestModel, acRequest: TilmeldAccessRequest.USER_OWNED },
|
|
1505
|
+
{ type: '&', guid: alicesEntity.guid || '' },
|
|
1506
|
+
);
|
|
1507
|
+
|
|
1508
|
+
expect(testEntityAlice).not.toBeNull();
|
|
1509
|
+
expect(testEntityAlice?.guid).toEqual(alicesEntity.guid);
|
|
1510
|
+
|
|
1511
|
+
tilmeld.clearSession();
|
|
1512
|
+
});
|
|
1513
|
+
|
|
1514
|
+
it("access request for user owned doesn't return group owned entity", async () => {
|
|
1515
|
+
const { bob, alice } = await makeUsers();
|
|
1516
|
+
|
|
1517
|
+
await tilmeld.fillSession(bob);
|
|
1518
|
+
|
|
1519
|
+
const bobsEntity = await TestModel.factory();
|
|
1520
|
+
bobsEntity.name = "Bob's Entity";
|
|
1521
|
+
bobsEntity.group = alice.group;
|
|
1522
|
+
expect(await bobsEntity.$save()).toEqual(true);
|
|
1523
|
+
|
|
1524
|
+
expect(bobsEntity.guid).not.toBeNull();
|
|
1525
|
+
expect(bob.$is(bobsEntity.user)).toEqual(true);
|
|
1526
|
+
|
|
1527
|
+
const testEntityBob = await nymph.getEntity(
|
|
1528
|
+
{ class: TestModel },
|
|
1529
|
+
{ type: '&', guid: bobsEntity.guid || '' },
|
|
1530
|
+
);
|
|
1531
|
+
|
|
1532
|
+
expect(testEntityBob).not.toBeNull();
|
|
1533
|
+
expect(testEntityBob?.guid).toEqual(bobsEntity.guid);
|
|
1534
|
+
|
|
1535
|
+
tilmeld.clearSession();
|
|
1536
|
+
await tilmeld.fillSession(alice);
|
|
1537
|
+
|
|
1538
|
+
const testEntityAlice = await nymph.getEntity(
|
|
1539
|
+
{ class: TestModel },
|
|
1540
|
+
{ type: '&', guid: bobsEntity.guid || '' },
|
|
1541
|
+
);
|
|
1542
|
+
|
|
1543
|
+
expect(testEntityAlice).not.toBeNull();
|
|
1544
|
+
|
|
1545
|
+
const testFailureEntityAlice = await nymph.getEntity(
|
|
1546
|
+
{ class: TestModel, acRequest: TilmeldAccessRequest.USER_OWNED },
|
|
1547
|
+
{ type: '&', guid: bobsEntity.guid || '' },
|
|
1548
|
+
);
|
|
1549
|
+
|
|
1550
|
+
expect(testFailureEntityAlice).toBeNull();
|
|
1551
|
+
|
|
1552
|
+
const testSuccessEntityAlice = await nymph.getEntity(
|
|
1553
|
+
{ class: TestModel, acRequest: TilmeldAccessRequest.PRIMARY_GROUP_OWNED },
|
|
1554
|
+
{ type: '&', guid: bobsEntity.guid || '' },
|
|
1555
|
+
);
|
|
1556
|
+
|
|
1557
|
+
expect(testSuccessEntityAlice).not.toBeNull();
|
|
1558
|
+
});
|
|
1559
|
+
|
|
1560
|
+
it("access request for user owned doesn't return acOther accessible entity", async () => {
|
|
1561
|
+
const { bob, alice } = await makeUsers();
|
|
1562
|
+
|
|
1563
|
+
await tilmeld.fillSession(bob);
|
|
1564
|
+
|
|
1565
|
+
const bobsEntity = await TestModel.factory();
|
|
1566
|
+
bobsEntity.name = "Bob's Entity";
|
|
1567
|
+
bobsEntity.acOther = TilmeldAccessLevels.READ_ACCESS;
|
|
1568
|
+
expect(await bobsEntity.$save()).toEqual(true);
|
|
1569
|
+
|
|
1570
|
+
expect(bobsEntity.guid).not.toBeNull();
|
|
1571
|
+
expect(bob.$is(bobsEntity.user)).toEqual(true);
|
|
1572
|
+
|
|
1573
|
+
const testEntityBob = await nymph.getEntity(
|
|
1574
|
+
{ class: TestModel },
|
|
1575
|
+
{ type: '&', guid: bobsEntity.guid || '' },
|
|
1576
|
+
);
|
|
1577
|
+
|
|
1578
|
+
expect(testEntityBob).not.toBeNull();
|
|
1579
|
+
expect(testEntityBob?.guid).toEqual(bobsEntity.guid);
|
|
1580
|
+
|
|
1581
|
+
tilmeld.clearSession();
|
|
1582
|
+
await tilmeld.fillSession(alice);
|
|
1583
|
+
|
|
1584
|
+
const testEntityAlice = await nymph.getEntity(
|
|
1585
|
+
{ class: TestModel },
|
|
1586
|
+
{ type: '&', guid: bobsEntity.guid || '' },
|
|
1587
|
+
);
|
|
1588
|
+
|
|
1589
|
+
expect(testEntityAlice).not.toBeNull();
|
|
1590
|
+
|
|
1591
|
+
const testFailureEntityAlice = await nymph.getEntity(
|
|
1592
|
+
{ class: TestModel, acRequest: TilmeldAccessRequest.USER_OWNED },
|
|
1593
|
+
{ type: '&', guid: bobsEntity.guid || '' },
|
|
1594
|
+
);
|
|
1595
|
+
|
|
1596
|
+
expect(testFailureEntityAlice).toBeNull();
|
|
1597
|
+
|
|
1598
|
+
const testSuccessEntityAlice = await nymph.getEntity(
|
|
1599
|
+
{ class: TestModel, acRequest: TilmeldAccessRequest.OTHER_ACCESSIBLE },
|
|
1600
|
+
{ type: '&', guid: bobsEntity.guid || '' },
|
|
1601
|
+
);
|
|
1602
|
+
|
|
1603
|
+
expect(testSuccessEntityAlice).not.toBeNull();
|
|
1604
|
+
});
|
|
1605
|
+
|
|
1606
|
+
it("access request for user owned doesn't return user acRead accessible entity", async () => {
|
|
1607
|
+
const { bob, alice } = await makeUsers();
|
|
1608
|
+
|
|
1609
|
+
await tilmeld.fillSession(bob);
|
|
1610
|
+
|
|
1611
|
+
const bobsEntity = await TestModel.factory();
|
|
1612
|
+
bobsEntity.name = "Bob's Entity";
|
|
1613
|
+
bobsEntity.acRead = [alice.guid ?? ''];
|
|
1614
|
+
expect(await bobsEntity.$save()).toEqual(true);
|
|
1615
|
+
|
|
1616
|
+
expect(bobsEntity.guid).not.toBeNull();
|
|
1617
|
+
expect(bob.$is(bobsEntity.user)).toEqual(true);
|
|
1618
|
+
|
|
1619
|
+
const testEntityBob = await nymph.getEntity(
|
|
1620
|
+
{ class: TestModel },
|
|
1621
|
+
{ type: '&', guid: bobsEntity.guid || '' },
|
|
1622
|
+
);
|
|
1623
|
+
|
|
1624
|
+
expect(testEntityBob).not.toBeNull();
|
|
1625
|
+
expect(testEntityBob?.guid).toEqual(bobsEntity.guid);
|
|
1626
|
+
|
|
1627
|
+
tilmeld.clearSession();
|
|
1628
|
+
await tilmeld.fillSession(alice);
|
|
1629
|
+
|
|
1630
|
+
const testEntityAlice = await nymph.getEntity(
|
|
1631
|
+
{ class: TestModel },
|
|
1632
|
+
{ type: '&', guid: bobsEntity.guid || '' },
|
|
1633
|
+
);
|
|
1634
|
+
|
|
1635
|
+
expect(testEntityAlice).not.toBeNull();
|
|
1636
|
+
|
|
1637
|
+
const testFailureEntityAlice = await nymph.getEntity(
|
|
1638
|
+
{ class: TestModel, acRequest: TilmeldAccessRequest.USER_OWNED },
|
|
1639
|
+
{ type: '&', guid: bobsEntity.guid || '' },
|
|
1640
|
+
);
|
|
1641
|
+
|
|
1642
|
+
expect(testFailureEntityAlice).toBeNull();
|
|
1643
|
+
|
|
1644
|
+
const testSuccessEntityAlice = await nymph.getEntity(
|
|
1645
|
+
{ class: TestModel, acRequest: TilmeldAccessRequest.USER_ACCESSIBLE },
|
|
1646
|
+
{ type: '&', guid: bobsEntity.guid || '' },
|
|
1647
|
+
);
|
|
1648
|
+
|
|
1649
|
+
expect(testSuccessEntityAlice).not.toBeNull();
|
|
1650
|
+
});
|
|
1651
|
+
|
|
1652
|
+
it("access request for user owned doesn't return group acRead accessible entity", async () => {
|
|
1653
|
+
const { bob, alice } = await makeUsers();
|
|
1654
|
+
|
|
1655
|
+
await tilmeld.fillSession(bob);
|
|
1656
|
+
|
|
1657
|
+
const bobsEntity = await TestModel.factory();
|
|
1658
|
+
bobsEntity.name = "Bob's Entity";
|
|
1659
|
+
bobsEntity.acWrite = [alice.group?.guid ?? ''];
|
|
1660
|
+
expect(await bobsEntity.$save()).toEqual(true);
|
|
1661
|
+
|
|
1662
|
+
expect(bobsEntity.guid).not.toBeNull();
|
|
1663
|
+
expect(bob.$is(bobsEntity.user)).toEqual(true);
|
|
1664
|
+
|
|
1665
|
+
const testEntityBob = await nymph.getEntity(
|
|
1666
|
+
{ class: TestModel },
|
|
1667
|
+
{ type: '&', guid: bobsEntity.guid || '' },
|
|
1668
|
+
);
|
|
1669
|
+
|
|
1670
|
+
expect(testEntityBob).not.toBeNull();
|
|
1671
|
+
expect(testEntityBob?.guid).toEqual(bobsEntity.guid);
|
|
1672
|
+
|
|
1673
|
+
tilmeld.clearSession();
|
|
1674
|
+
await tilmeld.fillSession(alice);
|
|
1675
|
+
|
|
1676
|
+
const testEntityAlice = await nymph.getEntity(
|
|
1677
|
+
{ class: TestModel },
|
|
1678
|
+
{ type: '&', guid: bobsEntity.guid || '' },
|
|
1679
|
+
);
|
|
1680
|
+
|
|
1681
|
+
expect(testEntityAlice).not.toBeNull();
|
|
1682
|
+
|
|
1683
|
+
const testFailureEntityAlice = await nymph.getEntity(
|
|
1684
|
+
{ class: TestModel, acRequest: TilmeldAccessRequest.USER_OWNED },
|
|
1685
|
+
{ type: '&', guid: bobsEntity.guid || '' },
|
|
1686
|
+
);
|
|
1687
|
+
|
|
1688
|
+
expect(testFailureEntityAlice).toBeNull();
|
|
1689
|
+
|
|
1690
|
+
const testSuccessEntityAlice = await nymph.getEntity(
|
|
1691
|
+
{
|
|
1692
|
+
class: TestModel,
|
|
1693
|
+
acRequest: TilmeldAccessRequest.PRIMARY_GROUP_ACCESSIBLE,
|
|
1694
|
+
},
|
|
1695
|
+
{ type: '&', guid: bobsEntity.guid || '' },
|
|
1696
|
+
);
|
|
1697
|
+
|
|
1698
|
+
expect(testSuccessEntityAlice).not.toBeNull();
|
|
1699
|
+
});
|
|
1700
|
+
|
|
1701
|
+
it("access request for user owned doesn't return secondary group owned entity", async () => {
|
|
1702
|
+
const { bob, alice, abgroup } = await makeUsers();
|
|
1703
|
+
|
|
1704
|
+
await tilmeld.fillSession(bob);
|
|
1705
|
+
|
|
1706
|
+
const bobsEntity = await TestModel.factory();
|
|
1707
|
+
bobsEntity.name = "Bob's Entity";
|
|
1708
|
+
bobsEntity.group = abgroup;
|
|
1709
|
+
expect(await bobsEntity.$save()).toEqual(true);
|
|
1710
|
+
|
|
1711
|
+
expect(bobsEntity.guid).not.toBeNull();
|
|
1712
|
+
expect(bob.$is(bobsEntity.user)).toEqual(true);
|
|
1713
|
+
|
|
1714
|
+
const testEntityBob = await nymph.getEntity(
|
|
1715
|
+
{ class: TestModel },
|
|
1716
|
+
{ type: '&', guid: bobsEntity.guid || '' },
|
|
1717
|
+
);
|
|
1718
|
+
|
|
1719
|
+
expect(testEntityBob).not.toBeNull();
|
|
1720
|
+
expect(testEntityBob?.guid).toEqual(bobsEntity.guid);
|
|
1721
|
+
|
|
1722
|
+
tilmeld.clearSession();
|
|
1723
|
+
await tilmeld.fillSession(alice);
|
|
1724
|
+
|
|
1725
|
+
const testEntityAlice = await nymph.getEntity(
|
|
1726
|
+
{ class: TestModel },
|
|
1727
|
+
{ type: '&', guid: bobsEntity.guid || '' },
|
|
1728
|
+
);
|
|
1729
|
+
|
|
1730
|
+
expect(testEntityAlice).not.toBeNull();
|
|
1731
|
+
|
|
1732
|
+
const testFailureEntityAlice = await nymph.getEntity(
|
|
1733
|
+
{ class: TestModel, acRequest: TilmeldAccessRequest.USER_OWNED },
|
|
1734
|
+
{ type: '&', guid: bobsEntity.guid || '' },
|
|
1735
|
+
);
|
|
1736
|
+
|
|
1737
|
+
expect(testFailureEntityAlice).toBeNull();
|
|
1738
|
+
|
|
1739
|
+
const testSuccessEntityAlice = await nymph.getEntity(
|
|
1740
|
+
{
|
|
1741
|
+
class: TestModel,
|
|
1742
|
+
acRequest: TilmeldAccessRequest.SECONDARY_GROUP_OWNED,
|
|
1743
|
+
},
|
|
1744
|
+
{ type: '&', guid: bobsEntity.guid || '' },
|
|
1745
|
+
);
|
|
1746
|
+
|
|
1747
|
+
expect(testSuccessEntityAlice).not.toBeNull();
|
|
1748
|
+
});
|
|
1749
|
+
|
|
1750
|
+
it("access request for user owned doesn't return secondary group accessible entity", async () => {
|
|
1751
|
+
const { bob, alice, abgroup } = await makeUsers();
|
|
1752
|
+
|
|
1753
|
+
await tilmeld.fillSession(bob);
|
|
1754
|
+
|
|
1755
|
+
const bobsEntity = await TestModel.factory();
|
|
1756
|
+
bobsEntity.name = "Bob's Entity";
|
|
1757
|
+
bobsEntity.acFull = [abgroup.guid ?? ''];
|
|
1758
|
+
expect(await bobsEntity.$save()).toEqual(true);
|
|
1759
|
+
|
|
1760
|
+
expect(bobsEntity.guid).not.toBeNull();
|
|
1761
|
+
expect(bob.$is(bobsEntity.user)).toEqual(true);
|
|
1762
|
+
|
|
1763
|
+
const testEntityBob = await nymph.getEntity(
|
|
1764
|
+
{ class: TestModel },
|
|
1765
|
+
{ type: '&', guid: bobsEntity.guid || '' },
|
|
1766
|
+
);
|
|
1767
|
+
|
|
1768
|
+
expect(testEntityBob).not.toBeNull();
|
|
1769
|
+
expect(testEntityBob?.guid).toEqual(bobsEntity.guid);
|
|
1770
|
+
|
|
1771
|
+
tilmeld.clearSession();
|
|
1772
|
+
await tilmeld.fillSession(alice);
|
|
1773
|
+
|
|
1774
|
+
const testEntityAlice = await nymph.getEntity(
|
|
1775
|
+
{ class: TestModel },
|
|
1776
|
+
{ type: '&', guid: bobsEntity.guid || '' },
|
|
1777
|
+
);
|
|
1778
|
+
|
|
1779
|
+
expect(testEntityAlice).not.toBeNull();
|
|
1780
|
+
|
|
1781
|
+
const testFailureEntityAlice = await nymph.getEntity(
|
|
1782
|
+
{ class: TestModel, acRequest: TilmeldAccessRequest.USER_OWNED },
|
|
1783
|
+
{ type: '&', guid: bobsEntity.guid || '' },
|
|
1784
|
+
);
|
|
1785
|
+
|
|
1786
|
+
expect(testFailureEntityAlice).toBeNull();
|
|
1787
|
+
|
|
1788
|
+
const testSuccessEntityAlice = await nymph.getEntity(
|
|
1789
|
+
{
|
|
1790
|
+
class: TestModel,
|
|
1791
|
+
acRequest: TilmeldAccessRequest.SECONDARY_GROUP_ACCESSIBLE,
|
|
1792
|
+
},
|
|
1793
|
+
{ type: '&', guid: bobsEntity.guid || '' },
|
|
1794
|
+
);
|
|
1795
|
+
|
|
1796
|
+
expect(testSuccessEntityAlice).not.toBeNull();
|
|
1797
|
+
|
|
1798
|
+
// Test or-ing two levels together.
|
|
1799
|
+
const testSuccessEntityAlice2 = await nymph.getEntity(
|
|
1800
|
+
{
|
|
1801
|
+
class: TestModel,
|
|
1802
|
+
acRequest:
|
|
1803
|
+
TilmeldAccessRequest.SECONDARY_GROUP_ACCESSIBLE |
|
|
1804
|
+
TilmeldAccessRequest.PRIMARY_GROUP_ACCESSIBLE,
|
|
1805
|
+
},
|
|
1806
|
+
{ type: '&', guid: bobsEntity.guid || '' },
|
|
1807
|
+
);
|
|
1808
|
+
|
|
1809
|
+
expect(testSuccessEntityAlice2).not.toBeNull();
|
|
1810
|
+
});
|
|
1811
|
+
|
|
1812
|
+
it('access request for entity still works when filtering user owned entities manually', async () => {
|
|
1813
|
+
const { bob, alice } = await makeUsers();
|
|
1814
|
+
|
|
1815
|
+
await tilmeld.fillSession(bob);
|
|
1816
|
+
|
|
1817
|
+
const bobsEntity = await TestModel.factory();
|
|
1818
|
+
bobsEntity.name = "Bob's Entity";
|
|
1819
|
+
bobsEntity.acFull = [alice.guid ?? ''];
|
|
1820
|
+
expect(await bobsEntity.$save()).toEqual(true);
|
|
1821
|
+
|
|
1822
|
+
expect(bobsEntity.guid).not.toBeNull();
|
|
1823
|
+
expect(bob.$is(bobsEntity.user)).toEqual(true);
|
|
1824
|
+
|
|
1825
|
+
const testEntityBob = await nymph.getEntity(
|
|
1826
|
+
{ class: TestModel },
|
|
1827
|
+
{ type: '&', guid: bobsEntity.guid || '' },
|
|
1828
|
+
);
|
|
1829
|
+
|
|
1830
|
+
expect(testEntityBob).not.toBeNull();
|
|
1831
|
+
expect(testEntityBob?.guid).toEqual(bobsEntity.guid);
|
|
1832
|
+
|
|
1833
|
+
tilmeld.clearSession();
|
|
1834
|
+
await tilmeld.fillSession(alice);
|
|
1835
|
+
|
|
1836
|
+
const alicesEntity = await TestModel.factory();
|
|
1837
|
+
alicesEntity.name = "Alice's Entity";
|
|
1838
|
+
expect(await alicesEntity.$save()).toEqual(true);
|
|
1839
|
+
|
|
1840
|
+
expect(alicesEntity.guid).not.toBeNull();
|
|
1841
|
+
expect(alice.$is(alicesEntity.user)).toEqual(true);
|
|
1842
|
+
|
|
1843
|
+
const testEntityAlice = await nymph.getEntity(
|
|
1844
|
+
{ class: TestModel },
|
|
1845
|
+
{ type: '&', guid: bobsEntity.guid || '' },
|
|
1846
|
+
);
|
|
1847
|
+
|
|
1848
|
+
expect(testEntityAlice).not.toBeNull();
|
|
1849
|
+
|
|
1850
|
+
const testWithoutFiltering = await nymph.getEntities(
|
|
1851
|
+
{ class: TestModel, acRequest: TilmeldAccessRequest.USER_OWNED },
|
|
1852
|
+
{ type: '|', guid: [alicesEntity.guid || '', bobsEntity.guid || ''] },
|
|
1853
|
+
);
|
|
1854
|
+
|
|
1855
|
+
expect(testWithoutFiltering.length).toEqual(1);
|
|
1856
|
+
expect(testWithoutFiltering[0].guid).toEqual(alicesEntity?.guid || '');
|
|
1857
|
+
|
|
1858
|
+
const testWithFiltering = await nymph.getEntities(
|
|
1859
|
+
{
|
|
1860
|
+
class: TestModel,
|
|
1861
|
+
acRequest: TilmeldAccessRequest.USER_OWNED,
|
|
1862
|
+
},
|
|
1863
|
+
{ type: '|', guid: [alicesEntity.guid || '', bobsEntity.guid || ''] },
|
|
1864
|
+
{ type: '!&', ref: ['user', alice] },
|
|
1865
|
+
);
|
|
1866
|
+
|
|
1867
|
+
expect(testWithFiltering.length).toEqual(0);
|
|
1868
|
+
|
|
1869
|
+
const testInclusive = await nymph.getEntities({ class: TestModel });
|
|
1870
|
+
|
|
1871
|
+
const testInclusiveWithFiltering = await nymph.getEntities(
|
|
1872
|
+
{ class: TestModel },
|
|
1873
|
+
{ type: '!&', ref: ['user', alice] },
|
|
1874
|
+
);
|
|
1875
|
+
|
|
1876
|
+
expect(testInclusiveWithFiltering.length).toBeGreaterThanOrEqual(1);
|
|
1877
|
+
const guids = testInclusiveWithFiltering.map((entity) => entity.guid);
|
|
1878
|
+
expect(guids).not.toContain(alicesEntity?.guid || '');
|
|
1879
|
+
expect(guids).toContain(bobsEntity?.guid || '');
|
|
1880
|
+
|
|
1881
|
+
const allDefaultGuids = testInclusive.map((entity) => entity.guid);
|
|
1882
|
+
for (let guid of guids) {
|
|
1883
|
+
expect(allDefaultGuids).toContain(guid);
|
|
1884
|
+
}
|
|
1885
|
+
});
|
|
1886
|
+
|
|
1887
|
+
it("access request for invalid access control doesn't return any inaccessible entities", async () => {
|
|
1888
|
+
const { bob, alice, abgroup } = await makeUsers();
|
|
1889
|
+
|
|
1890
|
+
await tilmeld.fillSession(bob);
|
|
1891
|
+
|
|
1892
|
+
const bobsEntity = await TestModel.factory();
|
|
1893
|
+
bobsEntity.name = "Bob's Entity";
|
|
1894
|
+
expect(await bobsEntity.$save()).toEqual(true);
|
|
1895
|
+
|
|
1896
|
+
expect(bobsEntity.guid).not.toBeNull();
|
|
1897
|
+
expect(bob.$is(bobsEntity.user)).toEqual(true);
|
|
1898
|
+
|
|
1899
|
+
const testEntityBob = await nymph.getEntity(
|
|
1900
|
+
{ class: TestModel },
|
|
1901
|
+
{ type: '&', guid: bobsEntity.guid || '' },
|
|
1902
|
+
);
|
|
1903
|
+
|
|
1904
|
+
expect(testEntityBob).not.toBeNull();
|
|
1905
|
+
expect(testEntityBob?.guid).toEqual(bobsEntity.guid);
|
|
1906
|
+
|
|
1907
|
+
tilmeld.clearSession();
|
|
1908
|
+
await tilmeld.fillSession(alice);
|
|
1909
|
+
|
|
1910
|
+
const testEntityAlice = await nymph.getEntity(
|
|
1911
|
+
{ class: TestModel },
|
|
1912
|
+
{ type: '&', guid: bobsEntity.guid || '' },
|
|
1913
|
+
);
|
|
1914
|
+
|
|
1915
|
+
expect(testEntityAlice).toBeNull();
|
|
1916
|
+
|
|
1917
|
+
const testFailureEntityAlice = await nymph.getEntity(
|
|
1918
|
+
{ class: TestModel, acRequest: TilmeldAccessRequest.UNOWNED * 2 },
|
|
1919
|
+
{ type: '&', guid: bobsEntity.guid || '' },
|
|
1920
|
+
);
|
|
1921
|
+
|
|
1922
|
+
expect(testFailureEntityAlice).toBeNull();
|
|
1923
|
+
});
|
|
1485
1924
|
}
|