@sasjs/api 0.43.0 → 0.44.0
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/build/browser.js +545 -193
- package/build/cjs/corpus/drive.js +305 -26
- package/build/cjs/host/dispatch.js +44 -18
- package/build/cjs/identity/records.js +10 -0
- package/build/cjs/routes/generated.js +48 -0
- package/build/esm/corpus/drive.d.ts +1 -1
- package/build/esm/corpus/drive.d.ts.map +1 -1
- package/build/esm/corpus/drive.js +305 -26
- package/build/esm/host/dispatch.d.ts +5 -1
- package/build/esm/host/dispatch.d.ts.map +1 -1
- package/build/esm/host/dispatch.js +44 -18
- package/build/esm/identity/records.d.ts +3 -2
- package/build/esm/identity/records.d.ts.map +1 -1
- package/build/esm/identity/records.js +10 -0
- package/build/esm/routes/generated.d.ts.map +1 -1
- package/build/esm/routes/generated.js +48 -0
- package/package.json +1 -1
package/build/browser.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/* @sasjs/api 0.
|
|
1
|
+
/* @sasjs/api 0.44.0 - the SASjs Server API, for a service worker. https://github.com/sasjs/api */
|
|
2
2
|
"use strict";
|
|
3
3
|
var SASjsApi = (() => {
|
|
4
4
|
var __defProp = Object.defineProperty;
|
|
@@ -1687,6 +1687,10 @@ var SASjsApi = (() => {
|
|
|
1687
1687
|
status: 400,
|
|
1688
1688
|
description: "Invalid Format"
|
|
1689
1689
|
},
|
|
1690
|
+
{
|
|
1691
|
+
status: 401,
|
|
1692
|
+
description: "Unauthorized"
|
|
1693
|
+
},
|
|
1690
1694
|
{
|
|
1691
1695
|
status: 404,
|
|
1692
1696
|
description: "No app is published with that id"
|
|
@@ -1753,6 +1757,10 @@ var SASjsApi = (() => {
|
|
|
1753
1757
|
status: 400,
|
|
1754
1758
|
description: "Invalid Format"
|
|
1755
1759
|
},
|
|
1760
|
+
{
|
|
1761
|
+
status: 401,
|
|
1762
|
+
description: "Unauthorized"
|
|
1763
|
+
},
|
|
1756
1764
|
{
|
|
1757
1765
|
status: 413,
|
|
1758
1766
|
description: "File tree exceeds the deploy limit"
|
|
@@ -1823,6 +1831,10 @@ var SASjsApi = (() => {
|
|
|
1823
1831
|
status: 400,
|
|
1824
1832
|
description: "Invalid Format"
|
|
1825
1833
|
},
|
|
1834
|
+
{
|
|
1835
|
+
status: 401,
|
|
1836
|
+
description: "Unauthorized"
|
|
1837
|
+
},
|
|
1826
1838
|
{
|
|
1827
1839
|
status: 413,
|
|
1828
1840
|
description: "File tree exceeds the deploy limit"
|
|
@@ -1857,6 +1869,10 @@ var SASjsApi = (() => {
|
|
|
1857
1869
|
status: 400,
|
|
1858
1870
|
description: "Can't delete file outside drive"
|
|
1859
1871
|
},
|
|
1872
|
+
{
|
|
1873
|
+
status: 401,
|
|
1874
|
+
description: "Unauthorized"
|
|
1875
|
+
},
|
|
1860
1876
|
{
|
|
1861
1877
|
status: 404,
|
|
1862
1878
|
description: "File doesn't exist"
|
|
@@ -1897,6 +1913,10 @@ var SASjsApi = (() => {
|
|
|
1897
1913
|
status: 400,
|
|
1898
1914
|
description: "A path outside the drive, a refused extension, or a request naming neither or both"
|
|
1899
1915
|
},
|
|
1916
|
+
{
|
|
1917
|
+
status: 401,
|
|
1918
|
+
description: "Unauthorized"
|
|
1919
|
+
},
|
|
1900
1920
|
{
|
|
1901
1921
|
status: 404,
|
|
1902
1922
|
description: "File doesn't exist"
|
|
@@ -1939,6 +1959,10 @@ var SASjsApi = (() => {
|
|
|
1939
1959
|
status: 400,
|
|
1940
1960
|
description: "Can't modify file outside drive"
|
|
1941
1961
|
},
|
|
1962
|
+
{
|
|
1963
|
+
status: 401,
|
|
1964
|
+
description: "Unauthorized"
|
|
1965
|
+
},
|
|
1942
1966
|
{
|
|
1943
1967
|
status: 404,
|
|
1944
1968
|
description: "File doesn't exist"
|
|
@@ -1981,6 +2005,10 @@ var SASjsApi = (() => {
|
|
|
1981
2005
|
status: 400,
|
|
1982
2006
|
description: "Can't put file outside drive"
|
|
1983
2007
|
},
|
|
2008
|
+
{
|
|
2009
|
+
status: 401,
|
|
2010
|
+
description: "Unauthorized"
|
|
2011
|
+
},
|
|
1984
2012
|
{
|
|
1985
2013
|
status: 409,
|
|
1986
2014
|
description: "File already exists"
|
|
@@ -2006,6 +2034,10 @@ var SASjsApi = (() => {
|
|
|
2006
2034
|
{
|
|
2007
2035
|
status: 200,
|
|
2008
2036
|
description: "Ok"
|
|
2037
|
+
},
|
|
2038
|
+
{
|
|
2039
|
+
status: 401,
|
|
2040
|
+
description: "Unauthorized"
|
|
2009
2041
|
}
|
|
2010
2042
|
]
|
|
2011
2043
|
},
|
|
@@ -2033,6 +2065,10 @@ var SASjsApi = (() => {
|
|
|
2033
2065
|
status: 400,
|
|
2034
2066
|
description: "Can't delete folder outside drive"
|
|
2035
2067
|
},
|
|
2068
|
+
{
|
|
2069
|
+
status: 401,
|
|
2070
|
+
description: "Unauthorized"
|
|
2071
|
+
},
|
|
2036
2072
|
{
|
|
2037
2073
|
status: 404,
|
|
2038
2074
|
description: "Folder doesn't exist"
|
|
@@ -2063,6 +2099,10 @@ var SASjsApi = (() => {
|
|
|
2063
2099
|
status: 400,
|
|
2064
2100
|
description: "Can't get folder outside drive"
|
|
2065
2101
|
},
|
|
2102
|
+
{
|
|
2103
|
+
status: 401,
|
|
2104
|
+
description: "Unauthorized"
|
|
2105
|
+
},
|
|
2066
2106
|
{
|
|
2067
2107
|
status: 404,
|
|
2068
2108
|
description: "Folder doesn't exist"
|
|
@@ -2093,6 +2133,10 @@ var SASjsApi = (() => {
|
|
|
2093
2133
|
status: 400,
|
|
2094
2134
|
description: "Can't put folder outside drive"
|
|
2095
2135
|
},
|
|
2136
|
+
{
|
|
2137
|
+
status: 401,
|
|
2138
|
+
description: "Unauthorized"
|
|
2139
|
+
},
|
|
2096
2140
|
{
|
|
2097
2141
|
status: 409,
|
|
2098
2142
|
description: "Folder already exists. The body is that message as plain text."
|
|
@@ -2129,6 +2173,10 @@ var SASjsApi = (() => {
|
|
|
2129
2173
|
status: 400,
|
|
2130
2174
|
description: "Can't rename outside drive"
|
|
2131
2175
|
},
|
|
2176
|
+
{
|
|
2177
|
+
status: 401,
|
|
2178
|
+
description: "Unauthorized"
|
|
2179
|
+
},
|
|
2132
2180
|
{
|
|
2133
2181
|
status: 404,
|
|
2134
2182
|
description: "No file/folder found for provided path"
|
|
@@ -6661,6 +6709,40 @@ var SASjsApi = (() => {
|
|
|
6661
6709
|
};
|
|
6662
6710
|
};
|
|
6663
6711
|
|
|
6712
|
+
// src/identity/routeAccess.ts
|
|
6713
|
+
var TOP_LEVEL_ROUTES = ["/AppStream", "/SASjsApi"];
|
|
6714
|
+
var ALWAYS_VISIBLE_ROUTES = ["/AppStream"];
|
|
6715
|
+
var STATIC_AUTHORIZED_ROUTES = [
|
|
6716
|
+
"/SASjsApi/code/execute",
|
|
6717
|
+
"/SASjsApi/stp/execute",
|
|
6718
|
+
"/SASjsApi/drive/deploy",
|
|
6719
|
+
"/SASjsApi/drive/deploy/upload",
|
|
6720
|
+
"/SASjsApi/drive/file",
|
|
6721
|
+
"/SASjsApi/drive/folder",
|
|
6722
|
+
"/SASjsApi/drive/fileTree",
|
|
6723
|
+
"/SASjsApi/drive/rename"
|
|
6724
|
+
];
|
|
6725
|
+
var DEFAULT_GRANTABLE_ROUTES = [
|
|
6726
|
+
...TOP_LEVEL_ROUTES,
|
|
6727
|
+
...STATIC_AUTHORIZED_ROUTES
|
|
6728
|
+
];
|
|
6729
|
+
var topLevelRouteFor = (routePath) => TOP_LEVEL_ROUTES.find(
|
|
6730
|
+
(route) => routePath.toLowerCase().startsWith(route.toLowerCase())
|
|
6731
|
+
) ?? routePath;
|
|
6732
|
+
var settingOn = (rules, path) => rules.find((rule) => rule.path === path)?.setting;
|
|
6733
|
+
var GRANT = "Grant";
|
|
6734
|
+
var DENY = "Deny";
|
|
6735
|
+
var isRouteGranted = (rules, path, topLevelRoute = topLevelRouteFor(path)) => {
|
|
6736
|
+
const userSetting = settingOn(rules.user, path) ?? settingOn(rules.user, topLevelRoute);
|
|
6737
|
+
if (userSetting) return userSetting === GRANT;
|
|
6738
|
+
const onPath = rules.group.filter((rule) => rule.path === path);
|
|
6739
|
+
if (onPath.some((rule) => rule.setting === GRANT)) return true;
|
|
6740
|
+
if (onPath.some((rule) => rule.setting === DENY)) return false;
|
|
6741
|
+
return rules.group.some(
|
|
6742
|
+
(rule) => rule.path === topLevelRoute && rule.setting === GRANT
|
|
6743
|
+
);
|
|
6744
|
+
};
|
|
6745
|
+
|
|
6664
6746
|
// src/host/dispatch.ts
|
|
6665
6747
|
var SECONDS_IN_A_DAY = 86400;
|
|
6666
6748
|
var RUN_ROUTES = [
|
|
@@ -6670,11 +6752,12 @@ var SASjsApi = (() => {
|
|
|
6670
6752
|
"POST /SASjsApi/code/execute",
|
|
6671
6753
|
"POST /SASjsApi/code/trigger"
|
|
6672
6754
|
];
|
|
6673
|
-
var
|
|
6674
|
-
|
|
6675
|
-
|
|
6676
|
-
|
|
6677
|
-
|
|
6755
|
+
var GRANTED_ROUTES = DEFAULT_GRANTABLE_ROUTES.filter(
|
|
6756
|
+
(path) => !TOP_LEVEL_ROUTES.includes(path)
|
|
6757
|
+
);
|
|
6758
|
+
var grantPath = (path) => GRANTED_ROUTES.find(
|
|
6759
|
+
(candidate) => candidate.toLowerCase() === path.toLowerCase()
|
|
6760
|
+
);
|
|
6678
6761
|
var ADMIN_ROUTES = [
|
|
6679
6762
|
"GET /SASjsApi/admin/diagnostics",
|
|
6680
6763
|
"GET /SASjsApi/admin/logs",
|
|
@@ -6721,7 +6804,12 @@ var SASjsApi = (() => {
|
|
|
6721
6804
|
const identityScoped = ["User", "Group", "Permission", "Client"].includes(route.tag) || routeId === "PATCH /SASjsApi/auth/updatePassword";
|
|
6722
6805
|
const runtimeScoped = RUN_ROUTES.includes(routeId);
|
|
6723
6806
|
const adminScoped = ADMIN_ROUTES.includes(routeId) && Boolean(services.admin);
|
|
6724
|
-
const grantScoped =
|
|
6807
|
+
const grantScoped = grantPath(route.path);
|
|
6808
|
+
if (grantScoped && (identity || request.subject || request.token) && !records)
|
|
6809
|
+
throw new ApiError(
|
|
6810
|
+
501,
|
|
6811
|
+
`This host has no record service, so it cannot answer ${routeId}.`
|
|
6812
|
+
);
|
|
6725
6813
|
if (adminScoped && !records)
|
|
6726
6814
|
throw new ApiError(
|
|
6727
6815
|
501,
|
|
@@ -6736,22 +6824,28 @@ var SASjsApi = (() => {
|
|
|
6736
6824
|
}
|
|
6737
6825
|
return subject;
|
|
6738
6826
|
};
|
|
6739
|
-
if (identityScoped && records || runtimeScoped && services.runtime || adminScoped || grantScoped) {
|
|
6827
|
+
if (identityScoped && records || runtimeScoped && services.runtime || adminScoped || grantScoped && records) {
|
|
6740
6828
|
const callerSubject = await caller();
|
|
6829
|
+
let publicGrant = false;
|
|
6741
6830
|
if (!callerSubject) {
|
|
6742
|
-
|
|
6743
|
-
|
|
6744
|
-
|
|
6745
|
-
|
|
6746
|
-
)
|
|
6747
|
-
|
|
6831
|
+
publicGrant = Boolean(
|
|
6832
|
+
grantScoped && records && !identityScoped && !runtimeScoped && !adminScoped && await records.mayUseRoute(void 0, grantScoped)
|
|
6833
|
+
);
|
|
6834
|
+
if (!publicGrant) {
|
|
6835
|
+
if (!identity)
|
|
6836
|
+
throw new ApiError(
|
|
6837
|
+
501,
|
|
6838
|
+
`This host has no identity service, so it cannot answer ${routeId}.`
|
|
6839
|
+
);
|
|
6840
|
+
throw new ApiError(401, "Unauthorized");
|
|
6841
|
+
}
|
|
6748
6842
|
}
|
|
6749
6843
|
if (adminScoped && !await records.mayAdminister(callerSubject)) {
|
|
6750
6844
|
if (!await records.mayAct(callerSubject))
|
|
6751
6845
|
throw new ApiError(401, "Unauthorized");
|
|
6752
6846
|
throw new ApiError(401, "Admin account required");
|
|
6753
6847
|
}
|
|
6754
|
-
if (grantScoped && !await records.mayUseRoute(callerSubject,
|
|
6848
|
+
if (grantScoped && records && !publicGrant && !await records.mayUseRoute(callerSubject, grantScoped))
|
|
6755
6849
|
throw new ApiError(401, "Unauthorized");
|
|
6756
6850
|
}
|
|
6757
6851
|
validate(route, request);
|
|
@@ -7471,40 +7565,6 @@ var SASjsApi = (() => {
|
|
|
7471
7565
|
"PATCH /SASjsApi/auth/updatePassword"
|
|
7472
7566
|
];
|
|
7473
7567
|
|
|
7474
|
-
// src/identity/routeAccess.ts
|
|
7475
|
-
var TOP_LEVEL_ROUTES = ["/AppStream", "/SASjsApi"];
|
|
7476
|
-
var ALWAYS_VISIBLE_ROUTES = ["/AppStream"];
|
|
7477
|
-
var STATIC_AUTHORIZED_ROUTES = [
|
|
7478
|
-
"/SASjsApi/code/execute",
|
|
7479
|
-
"/SASjsApi/stp/execute",
|
|
7480
|
-
"/SASjsApi/drive/deploy",
|
|
7481
|
-
"/SASjsApi/drive/deploy/upload",
|
|
7482
|
-
"/SASjsApi/drive/file",
|
|
7483
|
-
"/SASjsApi/drive/folder",
|
|
7484
|
-
"/SASjsApi/drive/fileTree",
|
|
7485
|
-
"/SASjsApi/drive/rename"
|
|
7486
|
-
];
|
|
7487
|
-
var DEFAULT_GRANTABLE_ROUTES = [
|
|
7488
|
-
...TOP_LEVEL_ROUTES,
|
|
7489
|
-
...STATIC_AUTHORIZED_ROUTES
|
|
7490
|
-
];
|
|
7491
|
-
var topLevelRouteFor = (routePath) => TOP_LEVEL_ROUTES.find(
|
|
7492
|
-
(route) => routePath.toLowerCase().startsWith(route.toLowerCase())
|
|
7493
|
-
) ?? routePath;
|
|
7494
|
-
var settingOn = (rules, path) => rules.find((rule) => rule.path === path)?.setting;
|
|
7495
|
-
var GRANT = "Grant";
|
|
7496
|
-
var DENY = "Deny";
|
|
7497
|
-
var isRouteGranted = (rules, path, topLevelRoute = topLevelRouteFor(path)) => {
|
|
7498
|
-
const userSetting = settingOn(rules.user, path) ?? settingOn(rules.user, topLevelRoute);
|
|
7499
|
-
if (userSetting) return userSetting === GRANT;
|
|
7500
|
-
const onPath = rules.group.filter((rule) => rule.path === path);
|
|
7501
|
-
if (onPath.some((rule) => rule.setting === GRANT)) return true;
|
|
7502
|
-
if (onPath.some((rule) => rule.setting === DENY)) return false;
|
|
7503
|
-
return rules.group.some(
|
|
7504
|
-
(rule) => rule.path === topLevelRoute && rule.setting === GRANT
|
|
7505
|
-
);
|
|
7506
|
-
};
|
|
7507
|
-
|
|
7508
7568
|
// src/identity/service.ts
|
|
7509
7569
|
var unauthorized = () => new ApiError(401, "Unauthorized");
|
|
7510
7570
|
var liveSubject = async (store, subject) => {
|
|
@@ -7854,6 +7914,18 @@ var SASjsApi = (() => {
|
|
|
7854
7914
|
return Boolean(await readerOf(store, caller));
|
|
7855
7915
|
},
|
|
7856
7916
|
async mayUseRoute(caller, path) {
|
|
7917
|
+
if (!caller) {
|
|
7918
|
+
const rules = await store.permissions();
|
|
7919
|
+
if (!rules.some((rule) => rule.group !== void 0)) return false;
|
|
7920
|
+
const publicGroup = (await store.groups()).find(
|
|
7921
|
+
(group) => group.name === PUBLIC_GROUP
|
|
7922
|
+
);
|
|
7923
|
+
return Boolean(
|
|
7924
|
+
publicGroup && rules.some(
|
|
7925
|
+
(rule) => rule.group === publicGroup.uid && rule.path === path && rule.setting === "Grant"
|
|
7926
|
+
)
|
|
7927
|
+
);
|
|
7928
|
+
}
|
|
7857
7929
|
const reader = await readerOf(store, caller);
|
|
7858
7930
|
if (!reader) return false;
|
|
7859
7931
|
if (reader.isAdmin) return true;
|
|
@@ -9264,6 +9336,37 @@ var SASjsApi = (() => {
|
|
|
9264
9336
|
};
|
|
9265
9337
|
|
|
9266
9338
|
// src/corpus/drive.ts
|
|
9339
|
+
var ADMIN2 = { userId: "user-admin", clientId: "web_app" };
|
|
9340
|
+
var RESTRICTED2 = { userId: "user-restricted", clientId: "web_app" };
|
|
9341
|
+
var NO_DRIVE_GRANTS = {
|
|
9342
|
+
...DEFAULT_IDENTITY,
|
|
9343
|
+
permissions: DEFAULT_IDENTITY.permissions.filter(
|
|
9344
|
+
(rule) => rule.uid !== "rule-routes"
|
|
9345
|
+
)
|
|
9346
|
+
};
|
|
9347
|
+
var PUBLIC_FILE = {
|
|
9348
|
+
...DEFAULT_IDENTITY,
|
|
9349
|
+
groups: [
|
|
9350
|
+
...DEFAULT_IDENTITY.groups,
|
|
9351
|
+
{
|
|
9352
|
+
uid: "group-public",
|
|
9353
|
+
name: "public",
|
|
9354
|
+
description: "Everyone",
|
|
9355
|
+
isActive: true,
|
|
9356
|
+
users: []
|
|
9357
|
+
}
|
|
9358
|
+
],
|
|
9359
|
+
permissions: [
|
|
9360
|
+
...DEFAULT_IDENTITY.permissions,
|
|
9361
|
+
{
|
|
9362
|
+
uid: "rule-public-file",
|
|
9363
|
+
path: "/SASjsApi/drive/file",
|
|
9364
|
+
type: "Route",
|
|
9365
|
+
setting: "Grant",
|
|
9366
|
+
group: "group-public"
|
|
9367
|
+
}
|
|
9368
|
+
]
|
|
9369
|
+
};
|
|
9267
9370
|
var success2 = { status: "success" };
|
|
9268
9371
|
var bytes = (...values) => Uint8Array.from(values);
|
|
9269
9372
|
var manyMembers = (count) => Array.from({ length: count }, (_, at) => ({
|
|
@@ -9277,6 +9380,7 @@ var SASjsApi = (() => {
|
|
|
9277
9380
|
route: "POST /SASjsApi/drive/file",
|
|
9278
9381
|
description: "creates a file the drive did not have",
|
|
9279
9382
|
request: {
|
|
9383
|
+
subject: ADMIN2,
|
|
9280
9384
|
query: { _filePath: "/data/users.csv" },
|
|
9281
9385
|
file: { name: "users.csv", contents: "id,name\n1,Ann\n" }
|
|
9282
9386
|
},
|
|
@@ -9287,6 +9391,7 @@ var SASjsApi = (() => {
|
|
|
9287
9391
|
route: "POST /SASjsApi/drive/file",
|
|
9288
9392
|
description: "takes the destination from the form field when the query has none",
|
|
9289
9393
|
request: {
|
|
9394
|
+
subject: ADMIN2,
|
|
9290
9395
|
file: { name: "x.csv", contents: "x" },
|
|
9291
9396
|
body: { filePath: "/data/from-form.csv" }
|
|
9292
9397
|
},
|
|
@@ -9298,6 +9403,7 @@ var SASjsApi = (() => {
|
|
|
9298
9403
|
description: "refuses a create over a file that exists, as 409",
|
|
9299
9404
|
seed: { "/data/exists.csv": "a" },
|
|
9300
9405
|
request: {
|
|
9406
|
+
subject: ADMIN2,
|
|
9301
9407
|
query: { _filePath: "/data/exists.csv" },
|
|
9302
9408
|
file: { name: "x", contents: "b" }
|
|
9303
9409
|
},
|
|
@@ -9308,6 +9414,7 @@ var SASjsApi = (() => {
|
|
|
9308
9414
|
route: "POST /SASjsApi/drive/file",
|
|
9309
9415
|
description: "refuses a refused extension before touching the drive",
|
|
9310
9416
|
request: {
|
|
9417
|
+
subject: ADMIN2,
|
|
9311
9418
|
query: { _filePath: "/data/run.sh" },
|
|
9312
9419
|
file: { name: "run.sh", contents: "x" }
|
|
9313
9420
|
},
|
|
@@ -9318,6 +9425,7 @@ var SASjsApi = (() => {
|
|
|
9318
9425
|
route: "POST /SASjsApi/drive/file",
|
|
9319
9426
|
description: "refuses a path that climbs out of the drive",
|
|
9320
9427
|
request: {
|
|
9428
|
+
subject: ADMIN2,
|
|
9321
9429
|
query: { _filePath: "/../escape.csv" },
|
|
9322
9430
|
file: { name: "x", contents: "x" }
|
|
9323
9431
|
},
|
|
@@ -9327,14 +9435,20 @@ var SASjsApi = (() => {
|
|
|
9327
9435
|
id: "create-file-without-payload",
|
|
9328
9436
|
route: "POST /SASjsApi/drive/file",
|
|
9329
9437
|
description: "answers for a missing file with the server wording",
|
|
9330
|
-
request: {
|
|
9438
|
+
request: {
|
|
9439
|
+
subject: ADMIN2,
|
|
9440
|
+
query: { _filePath: "/data/x.csv" }
|
|
9441
|
+
},
|
|
9331
9442
|
expect: { status: 400, error: '"file" is not present.' }
|
|
9332
9443
|
},
|
|
9333
9444
|
{
|
|
9334
9445
|
id: "create-file-without-destination",
|
|
9335
9446
|
route: "POST /SASjsApi/drive/file",
|
|
9336
9447
|
description: "answers for a missing destination with the validation wording",
|
|
9337
|
-
request: {
|
|
9448
|
+
request: {
|
|
9449
|
+
subject: ADMIN2,
|
|
9450
|
+
file: { name: "x", contents: "x" }
|
|
9451
|
+
},
|
|
9338
9452
|
expect: { status: 400, error: '"_filePath" is required' }
|
|
9339
9453
|
},
|
|
9340
9454
|
{
|
|
@@ -9343,6 +9457,7 @@ var SASjsApi = (() => {
|
|
|
9343
9457
|
description: "replaces the contents of a file that exists",
|
|
9344
9458
|
seed: { "/data/keep.csv": "old" },
|
|
9345
9459
|
request: {
|
|
9460
|
+
subject: ADMIN2,
|
|
9346
9461
|
query: { _filePath: "/data/keep.csv" },
|
|
9347
9462
|
file: { name: "keep.csv", contents: "new" }
|
|
9348
9463
|
},
|
|
@@ -9353,6 +9468,7 @@ var SASjsApi = (() => {
|
|
|
9353
9468
|
route: "PATCH /SASjsApi/drive/file",
|
|
9354
9469
|
description: "refuses a replace of a file that is not there, as 404",
|
|
9355
9470
|
request: {
|
|
9471
|
+
subject: ADMIN2,
|
|
9356
9472
|
query: { _filePath: "/data/missing.csv" },
|
|
9357
9473
|
file: { name: "x", contents: "x" }
|
|
9358
9474
|
},
|
|
@@ -9363,6 +9479,7 @@ var SASjsApi = (() => {
|
|
|
9363
9479
|
route: "PATCH /SASjsApi/drive/file",
|
|
9364
9480
|
description: "refuses a replace of a path that climbs out of the drive",
|
|
9365
9481
|
request: {
|
|
9482
|
+
subject: ADMIN2,
|
|
9366
9483
|
query: { _filePath: "/../escape.csv" },
|
|
9367
9484
|
file: { name: "x", contents: "x" }
|
|
9368
9485
|
},
|
|
@@ -9373,21 +9490,30 @@ var SASjsApi = (() => {
|
|
|
9373
9490
|
route: "GET /SASjsApi/drive/file",
|
|
9374
9491
|
description: "answers with the file contents",
|
|
9375
9492
|
seed: { "/data/keep.csv": "a,b\n1,2\n" },
|
|
9376
|
-
request: {
|
|
9493
|
+
request: {
|
|
9494
|
+
subject: ADMIN2,
|
|
9495
|
+
query: { _filePath: "/data/keep.csv" }
|
|
9496
|
+
},
|
|
9377
9497
|
expect: { status: 200, contents: "a,b\n1,2\n" }
|
|
9378
9498
|
},
|
|
9379
9499
|
{
|
|
9380
9500
|
id: "read-file-missing",
|
|
9381
9501
|
route: "GET /SASjsApi/drive/file",
|
|
9382
9502
|
description: "refuses a read of a file that is not there",
|
|
9383
|
-
request: {
|
|
9503
|
+
request: {
|
|
9504
|
+
subject: ADMIN2,
|
|
9505
|
+
query: { _filePath: "/data/missing.csv" }
|
|
9506
|
+
},
|
|
9384
9507
|
expect: { status: 404, error: `File doesn't exist.` }
|
|
9385
9508
|
},
|
|
9386
9509
|
{
|
|
9387
9510
|
id: "read-file-outside-drive",
|
|
9388
9511
|
route: "GET /SASjsApi/drive/file",
|
|
9389
9512
|
description: "refuses a read of a path that climbs out of the drive",
|
|
9390
|
-
request: {
|
|
9513
|
+
request: {
|
|
9514
|
+
subject: ADMIN2,
|
|
9515
|
+
query: { _filePath: "/../escape.csv" }
|
|
9516
|
+
},
|
|
9391
9517
|
expect: { status: 400, error: "Can't get file outside drive." }
|
|
9392
9518
|
},
|
|
9393
9519
|
{
|
|
@@ -9396,6 +9522,7 @@ var SASjsApi = (() => {
|
|
|
9396
9522
|
description: "refuses a request that names the file twice, in two readings",
|
|
9397
9523
|
seed: { "/data/keep.csv": "a" },
|
|
9398
9524
|
request: {
|
|
9525
|
+
subject: ADMIN2,
|
|
9399
9526
|
query: { _filePath: "/data/keep.csv", _FILE: "/data/keep.csv" }
|
|
9400
9527
|
},
|
|
9401
9528
|
expect: {
|
|
@@ -9408,14 +9535,20 @@ var SASjsApi = (() => {
|
|
|
9408
9535
|
route: "GET /SASjsApi/drive/file",
|
|
9409
9536
|
description: "reads a deployment file by the name a streamed page links to",
|
|
9410
9537
|
seed: { "/Public/app/services/web/main.js": "console.log(1)" },
|
|
9411
|
-
request: {
|
|
9538
|
+
request: {
|
|
9539
|
+
subject: ADMIN2,
|
|
9540
|
+
query: { _FILE: "/Public/app/services/web/main.js" }
|
|
9541
|
+
},
|
|
9412
9542
|
expect: { status: 200, contents: "console.log(1)" }
|
|
9413
9543
|
},
|
|
9414
9544
|
{
|
|
9415
9545
|
id: "read-streamed-file-missing",
|
|
9416
9546
|
route: "GET /SASjsApi/drive/file",
|
|
9417
9547
|
description: "answers a missing deployment file the way the estate does, not as a 404",
|
|
9418
|
-
request: {
|
|
9548
|
+
request: {
|
|
9549
|
+
subject: ADMIN2,
|
|
9550
|
+
query: { _FILE: "/Public/app/services/web/gone.js" }
|
|
9551
|
+
},
|
|
9419
9552
|
expect: { status: 202, contents: DEPLOYMENT_FILE_ERROR }
|
|
9420
9553
|
},
|
|
9421
9554
|
{
|
|
@@ -9423,21 +9556,30 @@ var SASjsApi = (() => {
|
|
|
9423
9556
|
route: "DELETE /SASjsApi/drive/file",
|
|
9424
9557
|
description: "deletes a file that exists",
|
|
9425
9558
|
seed: { "/data/keep.csv": "a" },
|
|
9426
|
-
request: {
|
|
9559
|
+
request: {
|
|
9560
|
+
subject: ADMIN2,
|
|
9561
|
+
query: { _filePath: "/data/keep.csv" }
|
|
9562
|
+
},
|
|
9427
9563
|
expect: { status: 200, body: success2 }
|
|
9428
9564
|
},
|
|
9429
9565
|
{
|
|
9430
9566
|
id: "delete-file-missing",
|
|
9431
9567
|
route: "DELETE /SASjsApi/drive/file",
|
|
9432
9568
|
description: "refuses a delete of a file that is not there",
|
|
9433
|
-
request: {
|
|
9569
|
+
request: {
|
|
9570
|
+
subject: ADMIN2,
|
|
9571
|
+
query: { _filePath: "/data/missing.csv" }
|
|
9572
|
+
},
|
|
9434
9573
|
expect: { status: 404, error: `File doesn't exist.` }
|
|
9435
9574
|
},
|
|
9436
9575
|
{
|
|
9437
9576
|
id: "delete-file-outside-drive",
|
|
9438
9577
|
route: "DELETE /SASjsApi/drive/file",
|
|
9439
9578
|
description: "refuses a delete of a path that climbs out of the drive",
|
|
9440
|
-
request: {
|
|
9579
|
+
request: {
|
|
9580
|
+
subject: ADMIN2,
|
|
9581
|
+
query: { _filePath: "/../escape.csv" }
|
|
9582
|
+
},
|
|
9441
9583
|
expect: { status: 400, error: "Can't delete file outside drive." }
|
|
9442
9584
|
},
|
|
9443
9585
|
{
|
|
@@ -9445,42 +9587,59 @@ var SASjsApi = (() => {
|
|
|
9445
9587
|
route: "GET /SASjsApi/drive/folder",
|
|
9446
9588
|
description: "lists the files and folders of a folder",
|
|
9447
9589
|
seed: { "/data/a.csv": "a", "/data/reports/b.csv": "b" },
|
|
9448
|
-
request: {
|
|
9590
|
+
request: {
|
|
9591
|
+
subject: ADMIN2,
|
|
9592
|
+
query: { _folderPath: "/data" }
|
|
9593
|
+
},
|
|
9449
9594
|
expect: { status: 200, body: { files: ["a.csv"], folders: ["reports"] } }
|
|
9450
9595
|
},
|
|
9451
9596
|
{
|
|
9452
9597
|
id: "list-folder-missing",
|
|
9453
9598
|
route: "GET /SASjsApi/drive/folder",
|
|
9454
9599
|
description: "refuses a listing of a folder that is not there",
|
|
9455
|
-
request: {
|
|
9600
|
+
request: {
|
|
9601
|
+
subject: ADMIN2,
|
|
9602
|
+
query: { _folderPath: "/nope" }
|
|
9603
|
+
},
|
|
9456
9604
|
expect: { status: 404, error: `Folder doesn't exist.` }
|
|
9457
9605
|
},
|
|
9458
9606
|
{
|
|
9459
9607
|
id: "list-folder-outside-drive",
|
|
9460
9608
|
route: "GET /SASjsApi/drive/folder",
|
|
9461
9609
|
description: "refuses a listing of a path that climbs out of the drive",
|
|
9462
|
-
request: {
|
|
9610
|
+
request: {
|
|
9611
|
+
subject: ADMIN2,
|
|
9612
|
+
query: { _folderPath: "/../escape" }
|
|
9613
|
+
},
|
|
9463
9614
|
expect: { status: 400, error: "Can't get folder outside drive." }
|
|
9464
9615
|
},
|
|
9465
9616
|
{
|
|
9466
9617
|
id: "delete-folder-without-path",
|
|
9467
9618
|
route: "DELETE /SASjsApi/drive/folder",
|
|
9468
9619
|
description: "answers for a missing folder path, because the table marks it required",
|
|
9469
|
-
request: {
|
|
9620
|
+
request: {
|
|
9621
|
+
subject: ADMIN2
|
|
9622
|
+
},
|
|
9470
9623
|
expect: { status: 400, error: '"_folderPath" is required' }
|
|
9471
9624
|
},
|
|
9472
9625
|
{
|
|
9473
9626
|
id: "create-folder-without-path",
|
|
9474
9627
|
route: "POST /SASjsApi/drive/folder",
|
|
9475
9628
|
description: "answers for a missing folder path in the body",
|
|
9476
|
-
request: {
|
|
9629
|
+
request: {
|
|
9630
|
+
subject: ADMIN2,
|
|
9631
|
+
body: {}
|
|
9632
|
+
},
|
|
9477
9633
|
expect: { status: 400, error: '"folderPath" is required' }
|
|
9478
9634
|
},
|
|
9479
9635
|
{
|
|
9480
9636
|
id: "create-folder",
|
|
9481
9637
|
route: "POST /SASjsApi/drive/folder",
|
|
9482
9638
|
description: "creates a folder",
|
|
9483
|
-
request: {
|
|
9639
|
+
request: {
|
|
9640
|
+
subject: ADMIN2,
|
|
9641
|
+
body: { folderPath: "/data/reports" }
|
|
9642
|
+
},
|
|
9484
9643
|
expect: { status: 200, body: success2 }
|
|
9485
9644
|
},
|
|
9486
9645
|
{
|
|
@@ -9488,7 +9647,10 @@ var SASjsApi = (() => {
|
|
|
9488
9647
|
route: "POST /SASjsApi/drive/folder",
|
|
9489
9648
|
description: "refuses a folder that already exists, as 409",
|
|
9490
9649
|
seed: { "/data/reports/a.csv": "a" },
|
|
9491
|
-
request: {
|
|
9650
|
+
request: {
|
|
9651
|
+
subject: ADMIN2,
|
|
9652
|
+
body: { folderPath: "/data/reports" }
|
|
9653
|
+
},
|
|
9492
9654
|
expect: { status: 409, error: "Folder already exists." }
|
|
9493
9655
|
},
|
|
9494
9656
|
{
|
|
@@ -9496,14 +9658,20 @@ var SASjsApi = (() => {
|
|
|
9496
9658
|
route: "DELETE /SASjsApi/drive/folder",
|
|
9497
9659
|
description: "deletes a folder with everything under it",
|
|
9498
9660
|
seed: { "/data/reports/a.csv": "a", "/data/reports/nested/b.csv": "b" },
|
|
9499
|
-
request: {
|
|
9661
|
+
request: {
|
|
9662
|
+
subject: ADMIN2,
|
|
9663
|
+
query: { _folderPath: "/data/reports" }
|
|
9664
|
+
},
|
|
9500
9665
|
expect: { status: 200, body: success2 }
|
|
9501
9666
|
},
|
|
9502
9667
|
{
|
|
9503
9668
|
id: "delete-folder-missing",
|
|
9504
9669
|
route: "DELETE /SASjsApi/drive/folder",
|
|
9505
9670
|
description: "refuses a delete of a folder that is not there",
|
|
9506
|
-
request: {
|
|
9671
|
+
request: {
|
|
9672
|
+
subject: ADMIN2,
|
|
9673
|
+
query: { _folderPath: "/nope" }
|
|
9674
|
+
},
|
|
9507
9675
|
expect: { status: 404, error: `Folder doesn't exist.` }
|
|
9508
9676
|
},
|
|
9509
9677
|
{
|
|
@@ -9511,7 +9679,10 @@ var SASjsApi = (() => {
|
|
|
9511
9679
|
route: "POST /SASjsApi/drive/rename",
|
|
9512
9680
|
description: "moves a file to a new path",
|
|
9513
9681
|
seed: { "/data/old.csv": "r" },
|
|
9514
|
-
request: {
|
|
9682
|
+
request: {
|
|
9683
|
+
subject: ADMIN2,
|
|
9684
|
+
body: { oldPath: "/data/old.csv", newPath: "/data/new.csv" }
|
|
9685
|
+
},
|
|
9515
9686
|
expect: { status: 200, body: success2 }
|
|
9516
9687
|
},
|
|
9517
9688
|
{
|
|
@@ -9519,14 +9690,20 @@ var SASjsApi = (() => {
|
|
|
9519
9690
|
route: "POST /SASjsApi/drive/rename",
|
|
9520
9691
|
description: "refuses a move onto something that exists",
|
|
9521
9692
|
seed: { "/data/a.csv": "a", "/data/b.csv": "b" },
|
|
9522
|
-
request: {
|
|
9693
|
+
request: {
|
|
9694
|
+
subject: ADMIN2,
|
|
9695
|
+
body: { oldPath: "/data/a.csv", newPath: "/data/b.csv" }
|
|
9696
|
+
},
|
|
9523
9697
|
expect: { status: 409, error: "File with new name already exists." }
|
|
9524
9698
|
},
|
|
9525
9699
|
{
|
|
9526
9700
|
id: "rename-missing",
|
|
9527
9701
|
route: "POST /SASjsApi/drive/rename",
|
|
9528
9702
|
description: "refuses a move of something that is not there",
|
|
9529
|
-
request: {
|
|
9703
|
+
request: {
|
|
9704
|
+
subject: ADMIN2,
|
|
9705
|
+
body: { oldPath: "/data/nope.csv", newPath: "/data/x.csv" }
|
|
9706
|
+
},
|
|
9530
9707
|
expect: { status: 404, error: "No file/folder found for provided path." }
|
|
9531
9708
|
},
|
|
9532
9709
|
{
|
|
@@ -9535,6 +9712,7 @@ var SASjsApi = (() => {
|
|
|
9535
9712
|
description: "refuses a rename that would produce a name the file routes refuse",
|
|
9536
9713
|
seed: { "/data/report.csv": "a,b" },
|
|
9537
9714
|
request: {
|
|
9715
|
+
subject: ADMIN2,
|
|
9538
9716
|
body: { oldPath: "/data/report.csv", newPath: "/data/report.sh" }
|
|
9539
9717
|
},
|
|
9540
9718
|
expect: { status: 400, error: "Invalid file extension" }
|
|
@@ -9545,6 +9723,7 @@ var SASjsApi = (() => {
|
|
|
9545
9723
|
description: "renames a folder whose new name carries a blocked suffix",
|
|
9546
9724
|
seed: { "/data/reports/a.csv": "a" },
|
|
9547
9725
|
request: {
|
|
9726
|
+
subject: ADMIN2,
|
|
9548
9727
|
body: { oldPath: "/data/reports", newPath: "/data/reports.sh" }
|
|
9549
9728
|
},
|
|
9550
9729
|
expect: { status: 200, body: { status: "success" } }
|
|
@@ -9555,6 +9734,7 @@ var SASjsApi = (() => {
|
|
|
9555
9734
|
description: "refuses a folder moved inside itself, which the server loses at the filesystem",
|
|
9556
9735
|
seed: { "/data/reports/a.csv": "a" },
|
|
9557
9736
|
request: {
|
|
9737
|
+
subject: ADMIN2,
|
|
9558
9738
|
body: { oldPath: "/data/reports", newPath: "/data/reports/nested" }
|
|
9559
9739
|
},
|
|
9560
9740
|
expect: {
|
|
@@ -9567,7 +9747,10 @@ var SASjsApi = (() => {
|
|
|
9567
9747
|
route: "GET /SASjsApi/drive/filetree",
|
|
9568
9748
|
description: "answers with the drive tree",
|
|
9569
9749
|
seed: { "/data/a.csv": "a" },
|
|
9570
|
-
request: {
|
|
9750
|
+
request: {
|
|
9751
|
+
subject: ADMIN2,
|
|
9752
|
+
query: { _folderPath: "/data" }
|
|
9753
|
+
},
|
|
9571
9754
|
expect: {
|
|
9572
9755
|
status: 200,
|
|
9573
9756
|
// Partial, because a file's `created` and `modified` are the host's
|
|
@@ -9596,6 +9779,7 @@ var SASjsApi = (() => {
|
|
|
9596
9779
|
route: "POST /SASjsApi/drive/deploy",
|
|
9597
9780
|
description: "writes a whole tree under the appLoc it names",
|
|
9598
9781
|
request: {
|
|
9782
|
+
subject: ADMIN2,
|
|
9599
9783
|
body: {
|
|
9600
9784
|
appLoc: "/Public/apps/demo",
|
|
9601
9785
|
fileTree: {
|
|
@@ -9623,6 +9807,7 @@ var SASjsApi = (() => {
|
|
|
9623
9807
|
route: "POST /SASjsApi/drive/deploy",
|
|
9624
9808
|
description: "refuses a tree over the entry cap, naming the figure and the cap",
|
|
9625
9809
|
request: {
|
|
9810
|
+
subject: ADMIN2,
|
|
9626
9811
|
body: {
|
|
9627
9812
|
appLoc: "/Public/apps/many",
|
|
9628
9813
|
fileTree: { members: manyMembers(10001) }
|
|
@@ -9642,6 +9827,7 @@ var SASjsApi = (() => {
|
|
|
9642
9827
|
route: "POST /SASjsApi/drive/deploy",
|
|
9643
9828
|
description: "refuses a member name that would escape the deployment root",
|
|
9644
9829
|
request: {
|
|
9830
|
+
subject: ADMIN2,
|
|
9645
9831
|
body: {
|
|
9646
9832
|
appLoc: "/Public/apps/hostile",
|
|
9647
9833
|
fileTree: {
|
|
@@ -9662,7 +9848,10 @@ var SASjsApi = (() => {
|
|
|
9662
9848
|
id: "deploy-refused-by-shape",
|
|
9663
9849
|
route: "POST /SASjsApi/drive/deploy",
|
|
9664
9850
|
description: "refuses a fileTree that is not a tree, in the routes own envelope",
|
|
9665
|
-
request: {
|
|
9851
|
+
request: {
|
|
9852
|
+
subject: ADMIN2,
|
|
9853
|
+
body: { appLoc: "/Public/apps/bad", fileTree: { members: 1 } }
|
|
9854
|
+
},
|
|
9666
9855
|
expect: {
|
|
9667
9856
|
status: 400,
|
|
9668
9857
|
body: {
|
|
@@ -9678,6 +9867,7 @@ var SASjsApi = (() => {
|
|
|
9678
9867
|
description: "answers the routes 500 when the drive refuses the write",
|
|
9679
9868
|
unwritable: true,
|
|
9680
9869
|
request: {
|
|
9870
|
+
subject: ADMIN2,
|
|
9681
9871
|
body: {
|
|
9682
9872
|
appLoc: "/Public/apps/demo",
|
|
9683
9873
|
fileTree: {
|
|
@@ -9696,6 +9886,7 @@ var SASjsApi = (() => {
|
|
|
9696
9886
|
route: "POST /SASjsApi/drive/deploy",
|
|
9697
9887
|
description: "refuses an appLoc that resolves outside the drive",
|
|
9698
9888
|
request: {
|
|
9889
|
+
subject: ADMIN2,
|
|
9699
9890
|
body: { appLoc: "/../outside", fileTree: { members: [] } }
|
|
9700
9891
|
},
|
|
9701
9892
|
expect: {
|
|
@@ -9709,9 +9900,170 @@ var SASjsApi = (() => {
|
|
|
9709
9900
|
route: "GET /SASjsApi/drive/file",
|
|
9710
9901
|
description: "keeps a byte file as bytes",
|
|
9711
9902
|
seed: { "/data/pack.zip": bytes(80, 75, 3, 4) },
|
|
9712
|
-
request: {
|
|
9903
|
+
request: {
|
|
9904
|
+
subject: ADMIN2,
|
|
9905
|
+
query: { _filePath: "/data/pack.zip" }
|
|
9906
|
+
},
|
|
9713
9907
|
expect: { status: 200, contents: bytes(80, 75, 3, 4) }
|
|
9714
|
-
}
|
|
9908
|
+
},
|
|
9909
|
+
// --------------------------------------------------- the rule that decides
|
|
9910
|
+
{
|
|
9911
|
+
id: "read-file-anonymous-public-grant",
|
|
9912
|
+
route: "GET /SASjsApi/drive/file",
|
|
9913
|
+
description: "admits an anonymous caller through an exact public group grant",
|
|
9914
|
+
identity: PUBLIC_FILE,
|
|
9915
|
+
seed: { "/data/public.csv": "public contents" },
|
|
9916
|
+
request: { query: { _filePath: "/data/public.csv" } },
|
|
9917
|
+
expect: { status: 200, contents: "public contents" }
|
|
9918
|
+
},
|
|
9919
|
+
{
|
|
9920
|
+
id: "read-file-public-invalid-token",
|
|
9921
|
+
route: "GET /SASjsApi/drive/file",
|
|
9922
|
+
description: "treats an invalid token as anonymous on an exactly public route",
|
|
9923
|
+
identity: PUBLIC_FILE,
|
|
9924
|
+
seed: { "/data/public.csv": "public contents" },
|
|
9925
|
+
request: {
|
|
9926
|
+
token: "invalid-token",
|
|
9927
|
+
query: { _filePath: "/data/public.csv" }
|
|
9928
|
+
},
|
|
9929
|
+
expect: { status: 200, contents: "public contents" }
|
|
9930
|
+
},
|
|
9931
|
+
{
|
|
9932
|
+
id: "read-file-public-inactive-token",
|
|
9933
|
+
route: "GET /SASjsApi/drive/file",
|
|
9934
|
+
description: "treats a deactivated token as anonymous on an exactly public route",
|
|
9935
|
+
identity: {
|
|
9936
|
+
...PUBLIC_FILE,
|
|
9937
|
+
users: PUBLIC_FILE.users.map(
|
|
9938
|
+
(user3) => user3.uid === "user-restricted" ? { ...user3, isActive: false } : user3
|
|
9939
|
+
),
|
|
9940
|
+
tokens: [
|
|
9941
|
+
{
|
|
9942
|
+
username: "sasjsuser",
|
|
9943
|
+
clientId: "web_app",
|
|
9944
|
+
accessToken: "inactive-access",
|
|
9945
|
+
refreshToken: "inactive-refresh"
|
|
9946
|
+
}
|
|
9947
|
+
]
|
|
9948
|
+
},
|
|
9949
|
+
seed: { "/data/public.csv": "public contents" },
|
|
9950
|
+
request: {
|
|
9951
|
+
token: "inactive-access",
|
|
9952
|
+
query: { _filePath: "/data/public.csv" }
|
|
9953
|
+
},
|
|
9954
|
+
expect: { status: 200, contents: "public contents" }
|
|
9955
|
+
},
|
|
9956
|
+
{
|
|
9957
|
+
id: "create-file-anonymous-public-grant",
|
|
9958
|
+
route: "POST /SASjsApi/drive/file",
|
|
9959
|
+
description: "admits public writes when the exact route is granted",
|
|
9960
|
+
identity: PUBLIC_FILE,
|
|
9961
|
+
request: {
|
|
9962
|
+
query: { _filePath: "/data/new.csv" },
|
|
9963
|
+
file: { name: "new.csv", contents: "new" }
|
|
9964
|
+
},
|
|
9965
|
+
expect: { status: 200, body: success2 },
|
|
9966
|
+
expectDrive: { present: ["/data/new.csv"] }
|
|
9967
|
+
},
|
|
9968
|
+
{
|
|
9969
|
+
id: "read-folder-anonymous-other-public-grant",
|
|
9970
|
+
route: "GET /SASjsApi/drive/folder",
|
|
9971
|
+
description: "refuses an anonymous caller when a different path is public",
|
|
9972
|
+
identity: PUBLIC_FILE,
|
|
9973
|
+
request: { query: { _folderPath: "/data" } },
|
|
9974
|
+
expect: { status: 401, error: "Unauthorized" }
|
|
9975
|
+
},
|
|
9976
|
+
{
|
|
9977
|
+
id: "read-file-anonymous-public-parent-grant",
|
|
9978
|
+
route: "GET /SASjsApi/drive/file",
|
|
9979
|
+
description: "does not inherit public authentication from a parent grant",
|
|
9980
|
+
identity: {
|
|
9981
|
+
...PUBLIC_FILE,
|
|
9982
|
+
permissions: PUBLIC_FILE.permissions.map(
|
|
9983
|
+
(rule) => rule.uid === "rule-public-file" ? { ...rule, path: "/SASjsApi" } : rule
|
|
9984
|
+
)
|
|
9985
|
+
},
|
|
9986
|
+
seed: { "/data/public.csv": "public contents" },
|
|
9987
|
+
request: { query: { _filePath: "/data/public.csv" } },
|
|
9988
|
+
expect: { status: 401, error: "Unauthorized" }
|
|
9989
|
+
},
|
|
9990
|
+
{
|
|
9991
|
+
id: "read-file-anonymous-public-deny",
|
|
9992
|
+
route: "GET /SASjsApi/drive/file",
|
|
9993
|
+
description: "does not authenticate an anonymous caller through a public deny",
|
|
9994
|
+
identity: {
|
|
9995
|
+
...PUBLIC_FILE,
|
|
9996
|
+
permissions: PUBLIC_FILE.permissions.map(
|
|
9997
|
+
(rule) => rule.uid === "rule-public-file" ? { ...rule, setting: "Deny" } : rule
|
|
9998
|
+
)
|
|
9999
|
+
},
|
|
10000
|
+
request: { query: { _filePath: "/data/public.csv" } },
|
|
10001
|
+
expect: { status: 401, error: "Unauthorized" }
|
|
10002
|
+
},
|
|
10003
|
+
{
|
|
10004
|
+
id: "read-file-public-user-deny",
|
|
10005
|
+
route: "GET /SASjsApi/drive/file",
|
|
10006
|
+
description: "admits an authenticated caller despite an explicit user deny on a public route",
|
|
10007
|
+
identity: {
|
|
10008
|
+
...PUBLIC_FILE,
|
|
10009
|
+
permissions: [
|
|
10010
|
+
...PUBLIC_FILE.permissions,
|
|
10011
|
+
{
|
|
10012
|
+
uid: "user-file-deny",
|
|
10013
|
+
path: "/SASjsApi/drive/file",
|
|
10014
|
+
type: "Route",
|
|
10015
|
+
setting: "Deny",
|
|
10016
|
+
user: "user-restricted"
|
|
10017
|
+
}
|
|
10018
|
+
]
|
|
10019
|
+
},
|
|
10020
|
+
seed: { "/data/public.csv": "public contents" },
|
|
10021
|
+
request: { subject: RESTRICTED2, query: { _filePath: "/data/public.csv" } },
|
|
10022
|
+
expect: { status: 200, contents: "public contents" }
|
|
10023
|
+
},
|
|
10024
|
+
{
|
|
10025
|
+
id: "read-file-granted-by-a-group-rule",
|
|
10026
|
+
route: "GET /SASjsApi/drive/file",
|
|
10027
|
+
description: "admits a restricted account the fixture grants this route, so the refusal beside it is the rule",
|
|
10028
|
+
seed: { "/data/keep.csv": "a,b\n1,2\n" },
|
|
10029
|
+
request: { subject: RESTRICTED2, query: { _filePath: "/data/keep.csv" } },
|
|
10030
|
+
expect: { status: 200, contents: "a,b\n1,2\n" }
|
|
10031
|
+
},
|
|
10032
|
+
{
|
|
10033
|
+
id: "rename-file-denied-to-a-restricted-account",
|
|
10034
|
+
route: "POST /SASjsApi/drive/rename",
|
|
10035
|
+
description: "refuses a drive route the rules do not grant, with the 401 a missing token earns",
|
|
10036
|
+
seed: { "/data/old.csv": "r" },
|
|
10037
|
+
request: {
|
|
10038
|
+
subject: RESTRICTED2,
|
|
10039
|
+
body: { oldPath: "/data/old.csv", newPath: "/data/new.csv" }
|
|
10040
|
+
},
|
|
10041
|
+
expect: { status: 401, error: "Unauthorized" }
|
|
10042
|
+
},
|
|
10043
|
+
// The permission gate refuses a caller the rules do not grant, on every route
|
|
10044
|
+
// the inventory addresses. Each of these is the same account and the same
|
|
10045
|
+
// refusal - the gate runs before the payload is read, which is why a bare
|
|
10046
|
+
// request answers 401 rather than the 400 a missing parameter would earn.
|
|
10047
|
+
...[
|
|
10048
|
+
"GET /SASjsApi/drive/file",
|
|
10049
|
+
"GET /SASjsApi/drive/folder",
|
|
10050
|
+
"GET /SASjsApi/drive/filetree",
|
|
10051
|
+
"POST /SASjsApi/drive/file",
|
|
10052
|
+
"PATCH /SASjsApi/drive/file",
|
|
10053
|
+
"DELETE /SASjsApi/drive/file",
|
|
10054
|
+
"POST /SASjsApi/drive/folder",
|
|
10055
|
+
"DELETE /SASjsApi/drive/folder",
|
|
10056
|
+
"POST /SASjsApi/drive/deploy",
|
|
10057
|
+
"DELETE /SASjsApi/drive/deploy",
|
|
10058
|
+
"POST /SASjsApi/drive/deploy/upload"
|
|
10059
|
+
].map((route) => ({
|
|
10060
|
+
id: `${route.toLowerCase().replace(/[^a-z0-9]+/g, "-")}-denied-to-a-restricted-account`,
|
|
10061
|
+
route,
|
|
10062
|
+
description: "refuses a drive route the rules do not grant, before it reads the payload",
|
|
10063
|
+
identity: NO_DRIVE_GRANTS,
|
|
10064
|
+
request: { subject: RESTRICTED2 },
|
|
10065
|
+
expect: { status: 401, error: "Unauthorized" }
|
|
10066
|
+
}))
|
|
9715
10067
|
];
|
|
9716
10068
|
|
|
9717
10069
|
// src/corpus/identity.ts
|
|
@@ -10941,8 +11293,8 @@ var SASjsApi = (() => {
|
|
|
10941
11293
|
];
|
|
10942
11294
|
|
|
10943
11295
|
// src/corpus/session.ts
|
|
10944
|
-
var
|
|
10945
|
-
var
|
|
11296
|
+
var ADMIN3 = { userId: "user-admin", clientId: "web_app" };
|
|
11297
|
+
var RESTRICTED3 = { userId: "user-restricted", clientId: "web_app" };
|
|
10946
11298
|
var notFound2 = (id) => `Session with ID '${id}' was not found.`;
|
|
10947
11299
|
var UNAUTHORIZED = "Unauthorized";
|
|
10948
11300
|
var SESSION_CORPUS = [
|
|
@@ -10951,7 +11303,7 @@ var SASjsApi = (() => {
|
|
|
10951
11303
|
id: "session-summary-own",
|
|
10952
11304
|
route: "GET /SASjsApi/session/{sessionId}",
|
|
10953
11305
|
description: "answers the owner the summary of their own session",
|
|
10954
|
-
request: { subject:
|
|
11306
|
+
request: { subject: ADMIN3, params: { sessionId: "sess-admin" } },
|
|
10955
11307
|
expect: {
|
|
10956
11308
|
status: 200,
|
|
10957
11309
|
body: {
|
|
@@ -10968,7 +11320,7 @@ var SASjsApi = (() => {
|
|
|
10968
11320
|
id: "session-summary-as-admin",
|
|
10969
11321
|
route: "GET /SASjsApi/session/{sessionId}",
|
|
10970
11322
|
description: "answers an administrator another account's session",
|
|
10971
|
-
request: { subject:
|
|
11323
|
+
request: { subject: ADMIN3, params: { sessionId: "sess-restricted" } },
|
|
10972
11324
|
// both stamps: the document requires them, and this host stamps a session's
|
|
10973
11325
|
// death time at creation rather than at completion - a running session
|
|
10974
11326
|
// answers with the moment it is due to be destroyed
|
|
@@ -10994,14 +11346,14 @@ var SASjsApi = (() => {
|
|
|
10994
11346
|
id: "session-summary-foreign",
|
|
10995
11347
|
route: "GET /SASjsApi/session/{sessionId}",
|
|
10996
11348
|
description: "answers 404 for another account's session, not 403",
|
|
10997
|
-
request: { subject:
|
|
11349
|
+
request: { subject: RESTRICTED3, params: { sessionId: "sess-admin" } },
|
|
10998
11350
|
expect: { status: 404, error: notFound2("sess-admin") }
|
|
10999
11351
|
},
|
|
11000
11352
|
{
|
|
11001
11353
|
id: "session-summary-unknown",
|
|
11002
11354
|
route: "GET /SASjsApi/session/{sessionId}",
|
|
11003
11355
|
description: "answers the same 404 for a session that does not exist",
|
|
11004
|
-
request: { subject:
|
|
11356
|
+
request: { subject: ADMIN3, params: { sessionId: "sess-nope" } },
|
|
11005
11357
|
expect: { status: 404, error: notFound2("sess-nope") }
|
|
11006
11358
|
},
|
|
11007
11359
|
// -------------------------------------------------------------------- log
|
|
@@ -11009,7 +11361,7 @@ var SASjsApi = (() => {
|
|
|
11009
11361
|
id: "session-log-own",
|
|
11010
11362
|
route: "GET /SASjsApi/session/{sessionId}/log",
|
|
11011
11363
|
description: "answers the log this session wrote",
|
|
11012
|
-
request: { subject:
|
|
11364
|
+
request: { subject: ADMIN3, params: { sessionId: "sess-admin" } },
|
|
11013
11365
|
expect: {
|
|
11014
11366
|
status: 200,
|
|
11015
11367
|
contents: "NOTE: session started\nNOTE: session completed\n"
|
|
@@ -11019,7 +11371,7 @@ var SASjsApi = (() => {
|
|
|
11019
11371
|
id: "session-log-nothing-written",
|
|
11020
11372
|
route: "GET /SASjsApi/session/{sessionId}/log",
|
|
11021
11373
|
description: "answers an empty body for a session that has written nothing",
|
|
11022
|
-
request: { subject:
|
|
11374
|
+
request: { subject: ADMIN3, params: { sessionId: "sess-silent" } },
|
|
11023
11375
|
expect: { status: 200, contents: "" }
|
|
11024
11376
|
},
|
|
11025
11377
|
{
|
|
@@ -11033,7 +11385,7 @@ var SASjsApi = (() => {
|
|
|
11033
11385
|
id: "session-log-foreign",
|
|
11034
11386
|
route: "GET /SASjsApi/session/{sessionId}/log",
|
|
11035
11387
|
description: "will not read another account's log",
|
|
11036
|
-
request: { subject:
|
|
11388
|
+
request: { subject: RESTRICTED3, params: { sessionId: "sess-admin" } },
|
|
11037
11389
|
expect: { status: 404, error: notFound2("sess-admin") }
|
|
11038
11390
|
},
|
|
11039
11391
|
// ----------------------------------------------------------------- output
|
|
@@ -11041,7 +11393,7 @@ var SASjsApi = (() => {
|
|
|
11041
11393
|
id: "session-output-own",
|
|
11042
11394
|
route: "GET /SASjsApi/session/{sessionId}/output",
|
|
11043
11395
|
description: "answers the webout this session produced",
|
|
11044
|
-
request: { subject:
|
|
11396
|
+
request: { subject: ADMIN3, params: { sessionId: "sess-admin" } },
|
|
11045
11397
|
expect: { status: 200, contents: "<html><body>42</body></html>" }
|
|
11046
11398
|
},
|
|
11047
11399
|
{
|
|
@@ -11055,7 +11407,7 @@ var SASjsApi = (() => {
|
|
|
11055
11407
|
id: "session-output-foreign",
|
|
11056
11408
|
route: "GET /SASjsApi/session/{sessionId}/output",
|
|
11057
11409
|
description: "will not read another account's webout",
|
|
11058
|
-
request: { subject:
|
|
11410
|
+
request: { subject: RESTRICTED3, params: { sessionId: "sess-admin" } },
|
|
11059
11411
|
expect: { status: 404, error: notFound2("sess-admin") }
|
|
11060
11412
|
},
|
|
11061
11413
|
// ------------------------------------------------------------------ state
|
|
@@ -11063,7 +11415,7 @@ var SASjsApi = (() => {
|
|
|
11063
11415
|
id: "session-state-own",
|
|
11064
11416
|
route: "GET /SASjsApi/session/{sessionId}/state",
|
|
11065
11417
|
description: "answers the run time's state for this session",
|
|
11066
|
-
request: { subject:
|
|
11418
|
+
request: { subject: RESTRICTED3, params: { sessionId: "sess-restricted" } },
|
|
11067
11419
|
// the state alone: the document's SessionStateResponse permits no other
|
|
11068
11420
|
// property, and `sasjs/server` answers exactly this object
|
|
11069
11421
|
expect: { status: 200, body: { state: "running" } }
|
|
@@ -11079,14 +11431,14 @@ var SASjsApi = (() => {
|
|
|
11079
11431
|
id: "session-state-foreign",
|
|
11080
11432
|
route: "GET /SASjsApi/session/{sessionId}/state",
|
|
11081
11433
|
description: "will not report another account's session state",
|
|
11082
|
-
request: { subject:
|
|
11434
|
+
request: { subject: RESTRICTED3, params: { sessionId: "sess-admin" } },
|
|
11083
11435
|
expect: { status: 404, error: notFound2("sess-admin") }
|
|
11084
11436
|
}
|
|
11085
11437
|
];
|
|
11086
11438
|
|
|
11087
11439
|
// src/corpus/runtime.ts
|
|
11088
|
-
var
|
|
11089
|
-
var
|
|
11440
|
+
var ADMIN4 = { userId: "user-admin", clientId: "web_app" };
|
|
11441
|
+
var RESTRICTED4 = { userId: "user-restricted", clientId: "web_app" };
|
|
11090
11442
|
var PROGRAM = "/Public/apps/demo/run.sas";
|
|
11091
11443
|
var CODE = 'data _null_;\n put "hello";\nrun;';
|
|
11092
11444
|
var UNAUTHORIZED2 = "Unauthorized";
|
|
@@ -11098,7 +11450,7 @@ var SASjsApi = (() => {
|
|
|
11098
11450
|
id: "stp-execute-get-answers-output",
|
|
11099
11451
|
route: "GET /SASjsApi/stp/execute",
|
|
11100
11452
|
description: "answers the output the program produced",
|
|
11101
|
-
request: { subject:
|
|
11453
|
+
request: { subject: ADMIN4, query: { _program: PROGRAM } },
|
|
11102
11454
|
runOutput: { contents: "hello from the program" },
|
|
11103
11455
|
expect: { status: 200, contents: "hello from the program" }
|
|
11104
11456
|
},
|
|
@@ -11106,7 +11458,7 @@ var SASjsApi = (() => {
|
|
|
11106
11458
|
id: "stp-execute-get-answers-bytes",
|
|
11107
11459
|
route: "GET /SASjsApi/stp/execute",
|
|
11108
11460
|
description: "answers an output that is bytes as bytes",
|
|
11109
|
-
request: { subject:
|
|
11461
|
+
request: { subject: ADMIN4, query: { _program: PROGRAM } },
|
|
11110
11462
|
runOutput: { contents: bytes2(1, 2, 3) },
|
|
11111
11463
|
expect: { status: 200, contents: bytes2(1, 2, 3) }
|
|
11112
11464
|
},
|
|
@@ -11114,14 +11466,14 @@ var SASjsApi = (() => {
|
|
|
11114
11466
|
id: "stp-execute-get-missing-program",
|
|
11115
11467
|
route: "GET /SASjsApi/stp/execute",
|
|
11116
11468
|
description: "refuses a request that names no program",
|
|
11117
|
-
request: { subject:
|
|
11469
|
+
request: { subject: ADMIN4, query: {} },
|
|
11118
11470
|
expect: { status: 400, error: '"_program" is required' }
|
|
11119
11471
|
},
|
|
11120
11472
|
{
|
|
11121
11473
|
id: "stp-execute-get-failed-run",
|
|
11122
11474
|
route: "GET /SASjsApi/stp/execute",
|
|
11123
11475
|
description: "answers 400 when the program could not be run",
|
|
11124
|
-
request: { subject:
|
|
11476
|
+
request: { subject: ADMIN4, query: { _program: PROGRAM } },
|
|
11125
11477
|
failingRun: true,
|
|
11126
11478
|
expect: { status: 400, error: FAILED }
|
|
11127
11479
|
},
|
|
@@ -11137,7 +11489,7 @@ var SASjsApi = (() => {
|
|
|
11137
11489
|
id: "stp-execute-post-body-program",
|
|
11138
11490
|
route: "POST /SASjsApi/stp/execute",
|
|
11139
11491
|
description: "runs the program the body names",
|
|
11140
|
-
request: { subject:
|
|
11492
|
+
request: { subject: ADMIN4, body: { _program: PROGRAM } },
|
|
11141
11493
|
runOutput: { contents: "hello from the body" },
|
|
11142
11494
|
expect: { status: 200, contents: "hello from the body" }
|
|
11143
11495
|
},
|
|
@@ -11145,7 +11497,7 @@ var SASjsApi = (() => {
|
|
|
11145
11497
|
id: "stp-execute-post-query-program",
|
|
11146
11498
|
route: "POST /SASjsApi/stp/execute",
|
|
11147
11499
|
description: "runs the program the query names, with no body",
|
|
11148
|
-
request: { subject:
|
|
11500
|
+
request: { subject: ADMIN4, query: { _program: PROGRAM }, body: {} },
|
|
11149
11501
|
runOutput: { contents: "hello from the query" },
|
|
11150
11502
|
expect: { status: 200, contents: "hello from the query" }
|
|
11151
11503
|
},
|
|
@@ -11153,14 +11505,14 @@ var SASjsApi = (() => {
|
|
|
11153
11505
|
id: "stp-execute-post-no-program",
|
|
11154
11506
|
route: "POST /SASjsApi/stp/execute",
|
|
11155
11507
|
description: "refuses a request with no program in the query or the body",
|
|
11156
|
-
request: { subject:
|
|
11508
|
+
request: { subject: ADMIN4, body: {} },
|
|
11157
11509
|
expect: { status: 400, error: '"_program" is required' }
|
|
11158
11510
|
},
|
|
11159
11511
|
{
|
|
11160
11512
|
id: "stp-execute-post-failed-run",
|
|
11161
11513
|
route: "POST /SASjsApi/stp/execute",
|
|
11162
11514
|
description: "answers 400 when the program could not be run",
|
|
11163
|
-
request: { subject:
|
|
11515
|
+
request: { subject: ADMIN4, body: { _program: PROGRAM } },
|
|
11164
11516
|
failingRun: true,
|
|
11165
11517
|
expect: { status: 400, error: FAILED }
|
|
11166
11518
|
},
|
|
@@ -11176,7 +11528,7 @@ var SASjsApi = (() => {
|
|
|
11176
11528
|
id: "stp-trigger-answers-session",
|
|
11177
11529
|
route: "POST /SASjsApi/stp/trigger",
|
|
11178
11530
|
description: "answers the session a caller polls, and no pid from a mock",
|
|
11179
|
-
request: { subject:
|
|
11531
|
+
request: { subject: ADMIN4, query: { _program: PROGRAM } },
|
|
11180
11532
|
expect: { status: 200, keys: ["sessionId"] }
|
|
11181
11533
|
},
|
|
11182
11534
|
{
|
|
@@ -11184,7 +11536,7 @@ var SASjsApi = (() => {
|
|
|
11184
11536
|
route: "POST /SASjsApi/stp/trigger",
|
|
11185
11537
|
description: "accepts a retention in minutes, as the query carries it",
|
|
11186
11538
|
request: {
|
|
11187
|
-
subject:
|
|
11539
|
+
subject: ADMIN4,
|
|
11188
11540
|
query: { _program: PROGRAM, expiresAfterMins: "15" }
|
|
11189
11541
|
},
|
|
11190
11542
|
expect: { status: 200, keys: ["sessionId"] }
|
|
@@ -11194,7 +11546,7 @@ var SASjsApi = (() => {
|
|
|
11194
11546
|
route: "POST /SASjsApi/stp/trigger",
|
|
11195
11547
|
description: "refuses a retention that is not a positive number of minutes",
|
|
11196
11548
|
request: {
|
|
11197
|
-
subject:
|
|
11549
|
+
subject: ADMIN4,
|
|
11198
11550
|
query: { _program: PROGRAM, expiresAfterMins: "0" }
|
|
11199
11551
|
},
|
|
11200
11552
|
expect: { status: 400, error: '"expiresAfterMins" must be greater than 0' }
|
|
@@ -11203,14 +11555,14 @@ var SASjsApi = (() => {
|
|
|
11203
11555
|
id: "stp-trigger-missing-program",
|
|
11204
11556
|
route: "POST /SASjsApi/stp/trigger",
|
|
11205
11557
|
description: "refuses a request that names no program",
|
|
11206
|
-
request: { subject:
|
|
11558
|
+
request: { subject: ADMIN4, query: {} },
|
|
11207
11559
|
expect: { status: 400, error: '"_program" is required' }
|
|
11208
11560
|
},
|
|
11209
11561
|
{
|
|
11210
11562
|
id: "stp-trigger-failed-run",
|
|
11211
11563
|
route: "POST /SASjsApi/stp/trigger",
|
|
11212
11564
|
description: "answers 400 when the program could not be started",
|
|
11213
|
-
request: { subject:
|
|
11565
|
+
request: { subject: ADMIN4, query: { _program: PROGRAM } },
|
|
11214
11566
|
failingRun: true,
|
|
11215
11567
|
expect: { status: 400, error: FAILED }
|
|
11216
11568
|
},
|
|
@@ -11226,7 +11578,7 @@ var SASjsApi = (() => {
|
|
|
11226
11578
|
id: "code-execute-answers-output",
|
|
11227
11579
|
route: "POST /SASjsApi/code/execute",
|
|
11228
11580
|
description: "runs the code in the body and answers its output",
|
|
11229
|
-
request: { subject:
|
|
11581
|
+
request: { subject: ADMIN4, body: { code: CODE, runTime: "sas" } },
|
|
11230
11582
|
runOutput: { contents: "NOTE: mock run" },
|
|
11231
11583
|
expect: { status: 200, contents: "NOTE: mock run" }
|
|
11232
11584
|
},
|
|
@@ -11240,35 +11592,35 @@ var SASjsApi = (() => {
|
|
|
11240
11592
|
id: "code-execute-unknown-runtime",
|
|
11241
11593
|
route: "POST /SASjsApi/code/execute",
|
|
11242
11594
|
description: "refuses a run time the document does not name",
|
|
11243
|
-
request: { subject:
|
|
11595
|
+
request: { subject: ADMIN4, body: { code: CODE, runTime: "cobol" } },
|
|
11244
11596
|
expect: { status: 400 }
|
|
11245
11597
|
},
|
|
11246
11598
|
{
|
|
11247
11599
|
id: "code-execute-missing-code",
|
|
11248
11600
|
route: "POST /SASjsApi/code/execute",
|
|
11249
11601
|
description: "refuses a payload with no code",
|
|
11250
|
-
request: { subject:
|
|
11602
|
+
request: { subject: ADMIN4, body: { runTime: "sas" } },
|
|
11251
11603
|
expect: { status: 400, error: '"code" is required' }
|
|
11252
11604
|
},
|
|
11253
11605
|
{
|
|
11254
11606
|
id: "code-execute-empty-code",
|
|
11255
11607
|
route: "POST /SASjsApi/code/execute",
|
|
11256
11608
|
description: "refuses code that is present but empty",
|
|
11257
|
-
request: { subject:
|
|
11609
|
+
request: { subject: ADMIN4, body: { code: "", runTime: "sas" } },
|
|
11258
11610
|
expect: { status: 400, error: '"code" is not allowed to be empty' }
|
|
11259
11611
|
},
|
|
11260
11612
|
{
|
|
11261
11613
|
id: "code-execute-non-string-code",
|
|
11262
11614
|
route: "POST /SASjsApi/code/execute",
|
|
11263
11615
|
description: "refuses code that is not a string rather than running its text",
|
|
11264
|
-
request: { subject:
|
|
11616
|
+
request: { subject: ADMIN4, body: { code: 123, runTime: "sas" } },
|
|
11265
11617
|
expect: { status: 400, error: '"code" must be a string' }
|
|
11266
11618
|
},
|
|
11267
11619
|
{
|
|
11268
11620
|
id: "code-execute-failed-run",
|
|
11269
11621
|
route: "POST /SASjsApi/code/execute",
|
|
11270
11622
|
description: "answers 400 when the code could not be run",
|
|
11271
|
-
request: { subject:
|
|
11623
|
+
request: { subject: ADMIN4, body: { code: CODE, runTime: "sas" } },
|
|
11272
11624
|
failingRun: true,
|
|
11273
11625
|
expect: { status: 400, error: FAILED }
|
|
11274
11626
|
},
|
|
@@ -11287,7 +11639,7 @@ var SASjsApi = (() => {
|
|
|
11287
11639
|
id: "code-execute-denied-by-a-rule",
|
|
11288
11640
|
route: "POST /SASjsApi/code/execute",
|
|
11289
11641
|
description: "refuses a caller the rules do not grant, with the 401 a missing token earns",
|
|
11290
|
-
request: { subject:
|
|
11642
|
+
request: { subject: RESTRICTED4, body: { code: CODE, runTime: "sas" } },
|
|
11291
11643
|
expect: { status: 401, error: UNAUTHORIZED2 }
|
|
11292
11644
|
},
|
|
11293
11645
|
{
|
|
@@ -11297,7 +11649,7 @@ var SASjsApi = (() => {
|
|
|
11297
11649
|
id: "stp-execute-granted-by-a-group-rule",
|
|
11298
11650
|
route: "POST /SASjsApi/stp/execute",
|
|
11299
11651
|
description: "admits a restricted account the rules grant",
|
|
11300
|
-
request: { subject:
|
|
11652
|
+
request: { subject: RESTRICTED4, body: { _program: PROGRAM } },
|
|
11301
11653
|
runOutput: { contents: "granted run" },
|
|
11302
11654
|
expect: { status: 200, contents: "granted run" }
|
|
11303
11655
|
},
|
|
@@ -11306,14 +11658,14 @@ var SASjsApi = (() => {
|
|
|
11306
11658
|
id: "code-trigger-answers-session",
|
|
11307
11659
|
route: "POST /SASjsApi/code/trigger",
|
|
11308
11660
|
description: "answers the session a caller polls, and no pid from a mock",
|
|
11309
|
-
request: { subject:
|
|
11661
|
+
request: { subject: ADMIN4, body: { code: CODE, runTime: "sas" } },
|
|
11310
11662
|
expect: { status: 200, keys: ["sessionId"] }
|
|
11311
11663
|
},
|
|
11312
11664
|
{
|
|
11313
11665
|
id: "code-trigger-missing-runtime",
|
|
11314
11666
|
route: "POST /SASjsApi/code/trigger",
|
|
11315
11667
|
description: "refuses a payload with no run time, which the document requires",
|
|
11316
|
-
request: { subject:
|
|
11668
|
+
request: { subject: ADMIN4, body: { code: CODE } },
|
|
11317
11669
|
expect: { status: 400, error: '"runTime" is required' }
|
|
11318
11670
|
},
|
|
11319
11671
|
{
|
|
@@ -11321,7 +11673,7 @@ var SASjsApi = (() => {
|
|
|
11321
11673
|
route: "POST /SASjsApi/code/trigger",
|
|
11322
11674
|
description: "refuses a retention that is not a positive number of minutes",
|
|
11323
11675
|
request: {
|
|
11324
|
-
subject:
|
|
11676
|
+
subject: ADMIN4,
|
|
11325
11677
|
body: { code: CODE, runTime: "sas", expiresAfterMins: 0 }
|
|
11326
11678
|
},
|
|
11327
11679
|
expect: { status: 400, error: '"expiresAfterMins" must be greater than 0' }
|
|
@@ -11330,7 +11682,7 @@ var SASjsApi = (() => {
|
|
|
11330
11682
|
id: "code-trigger-failed-run",
|
|
11331
11683
|
route: "POST /SASjsApi/code/trigger",
|
|
11332
11684
|
description: "answers 400 when the code could not be started",
|
|
11333
|
-
request: { subject:
|
|
11685
|
+
request: { subject: ADMIN4, body: { code: CODE, runTime: "sas" } },
|
|
11334
11686
|
failingRun: true,
|
|
11335
11687
|
expect: { status: 400, error: FAILED }
|
|
11336
11688
|
},
|
|
@@ -11405,8 +11757,8 @@ var SASjsApi = (() => {
|
|
|
11405
11757
|
}
|
|
11406
11758
|
]
|
|
11407
11759
|
};
|
|
11408
|
-
var
|
|
11409
|
-
var
|
|
11760
|
+
var ADMIN5 = "admin-access";
|
|
11761
|
+
var RESTRICTED5 = "user-access";
|
|
11410
11762
|
var RESTRICTED_UID = "user-restricted";
|
|
11411
11763
|
var ADMIN_UID = "user-admin";
|
|
11412
11764
|
var RECORD_CORPUS = [
|
|
@@ -11416,7 +11768,7 @@ var SASjsApi = (() => {
|
|
|
11416
11768
|
route: "GET /SASjsApi/user",
|
|
11417
11769
|
description: "lists the accounts any signed-in caller may see",
|
|
11418
11770
|
identity: ADMIN_SIGNED_IN,
|
|
11419
|
-
request: { token:
|
|
11771
|
+
request: { token: ADMIN5 },
|
|
11420
11772
|
expect: {
|
|
11421
11773
|
status: 200,
|
|
11422
11774
|
body: [
|
|
@@ -11440,7 +11792,7 @@ var SASjsApi = (() => {
|
|
|
11440
11792
|
route: "GET /SASjsApi/user/{uid}",
|
|
11441
11793
|
description: "returns the caller their own details, with the auto-exec code",
|
|
11442
11794
|
identity: ADMIN_SIGNED_IN,
|
|
11443
|
-
request: { token:
|
|
11795
|
+
request: { token: RESTRICTED5, params: { uid: RESTRICTED_UID } },
|
|
11444
11796
|
expect: {
|
|
11445
11797
|
status: 200,
|
|
11446
11798
|
partial: {
|
|
@@ -11465,7 +11817,7 @@ var SASjsApi = (() => {
|
|
|
11465
11817
|
route: "GET /SASjsApi/user/{uid}",
|
|
11466
11818
|
description: "answers 404 for an identifier no account has",
|
|
11467
11819
|
identity: ADMIN_SIGNED_IN,
|
|
11468
|
-
request: { token:
|
|
11820
|
+
request: { token: ADMIN5, params: { uid: "user-none" } },
|
|
11469
11821
|
expect: { status: 404, error: "User is not found." }
|
|
11470
11822
|
},
|
|
11471
11823
|
{
|
|
@@ -11473,7 +11825,7 @@ var SASjsApi = (() => {
|
|
|
11473
11825
|
route: "GET /SASjsApi/user/by/username/{username}",
|
|
11474
11826
|
description: "finds an account by username",
|
|
11475
11827
|
identity: ADMIN_SIGNED_IN,
|
|
11476
|
-
request: { token:
|
|
11828
|
+
request: { token: ADMIN5, params: { username: "sasjsuser" } },
|
|
11477
11829
|
expect: {
|
|
11478
11830
|
status: 200,
|
|
11479
11831
|
partial: { uid: RESTRICTED_UID, username: "sasjsuser", isAdmin: false }
|
|
@@ -11492,7 +11844,7 @@ var SASjsApi = (() => {
|
|
|
11492
11844
|
route: "GET /SASjsApi/user/by/username/{username}",
|
|
11493
11845
|
description: "answers 404 for a username no account has",
|
|
11494
11846
|
identity: ADMIN_SIGNED_IN,
|
|
11495
|
-
request: { token:
|
|
11847
|
+
request: { token: ADMIN5, params: { username: "nobody" } },
|
|
11496
11848
|
expect: { status: 404, error: "User is not found." }
|
|
11497
11849
|
},
|
|
11498
11850
|
{
|
|
@@ -11501,7 +11853,7 @@ var SASjsApi = (() => {
|
|
|
11501
11853
|
description: "creates an account, sanitised, and reports it",
|
|
11502
11854
|
identity: ADMIN_SIGNED_IN,
|
|
11503
11855
|
request: {
|
|
11504
|
-
token:
|
|
11856
|
+
token: ADMIN5,
|
|
11505
11857
|
body: {
|
|
11506
11858
|
username: "newuser",
|
|
11507
11859
|
displayName: " New User ",
|
|
@@ -11526,7 +11878,7 @@ var SASjsApi = (() => {
|
|
|
11526
11878
|
description: "refuses a creation by a caller who is not an administrator",
|
|
11527
11879
|
identity: ADMIN_SIGNED_IN,
|
|
11528
11880
|
request: {
|
|
11529
|
-
token:
|
|
11881
|
+
token: RESTRICTED5,
|
|
11530
11882
|
body: {
|
|
11531
11883
|
username: "newuser",
|
|
11532
11884
|
displayName: "New User",
|
|
@@ -11549,7 +11901,7 @@ var SASjsApi = (() => {
|
|
|
11549
11901
|
description: "refuses a username that is taken",
|
|
11550
11902
|
identity: ADMIN_SIGNED_IN,
|
|
11551
11903
|
request: {
|
|
11552
|
-
token:
|
|
11904
|
+
token: ADMIN5,
|
|
11553
11905
|
body: {
|
|
11554
11906
|
username: "sasjsuser",
|
|
11555
11907
|
displayName: "Another",
|
|
@@ -11564,7 +11916,7 @@ var SASjsApi = (() => {
|
|
|
11564
11916
|
description: "changes an account's display name",
|
|
11565
11917
|
identity: ADMIN_SIGNED_IN,
|
|
11566
11918
|
request: {
|
|
11567
|
-
token:
|
|
11919
|
+
token: ADMIN5,
|
|
11568
11920
|
params: { uid: RESTRICTED_UID },
|
|
11569
11921
|
body: {
|
|
11570
11922
|
displayName: "Renamed User",
|
|
@@ -11583,7 +11935,7 @@ var SASjsApi = (() => {
|
|
|
11583
11935
|
description: "refuses a change to somebody else's account",
|
|
11584
11936
|
identity: ADMIN_SIGNED_IN,
|
|
11585
11937
|
request: {
|
|
11586
|
-
token:
|
|
11938
|
+
token: RESTRICTED5,
|
|
11587
11939
|
params: { uid: ADMIN_UID },
|
|
11588
11940
|
body: {
|
|
11589
11941
|
displayName: "Hijacked",
|
|
@@ -11599,7 +11951,7 @@ var SASjsApi = (() => {
|
|
|
11599
11951
|
description: "answers 404 with the identifier it looked up",
|
|
11600
11952
|
identity: ADMIN_SIGNED_IN,
|
|
11601
11953
|
request: {
|
|
11602
|
-
token:
|
|
11954
|
+
token: ADMIN5,
|
|
11603
11955
|
params: { uid: "user-none" },
|
|
11604
11956
|
body: { displayName: "Nobody", username: "nobody", password: "none123" }
|
|
11605
11957
|
},
|
|
@@ -11611,7 +11963,7 @@ var SASjsApi = (() => {
|
|
|
11611
11963
|
description: "refuses a username change on a provider-managed account",
|
|
11612
11964
|
identity: PROVIDER_MANAGED,
|
|
11613
11965
|
request: {
|
|
11614
|
-
token:
|
|
11966
|
+
token: ADMIN5,
|
|
11615
11967
|
params: { uid: "user-directory" },
|
|
11616
11968
|
body: {
|
|
11617
11969
|
username: "renamed",
|
|
@@ -11630,7 +11982,7 @@ var SASjsApi = (() => {
|
|
|
11630
11982
|
description: "refuses a username another account already has",
|
|
11631
11983
|
identity: ADMIN_SIGNED_IN,
|
|
11632
11984
|
request: {
|
|
11633
|
-
token:
|
|
11985
|
+
token: ADMIN5,
|
|
11634
11986
|
params: { uid: RESTRICTED_UID },
|
|
11635
11987
|
body: {
|
|
11636
11988
|
username: "sasjsadmin",
|
|
@@ -11646,7 +11998,7 @@ var SASjsApi = (() => {
|
|
|
11646
11998
|
description: "changes an account looked up by username",
|
|
11647
11999
|
identity: ADMIN_SIGNED_IN,
|
|
11648
12000
|
request: {
|
|
11649
|
-
token:
|
|
12001
|
+
token: ADMIN5,
|
|
11650
12002
|
params: { username: "sasjsuser" },
|
|
11651
12003
|
body: {
|
|
11652
12004
|
isActive: false,
|
|
@@ -11663,7 +12015,7 @@ var SASjsApi = (() => {
|
|
|
11663
12015
|
description: "refuses a change to another account by username",
|
|
11664
12016
|
identity: ADMIN_SIGNED_IN,
|
|
11665
12017
|
request: {
|
|
11666
|
-
token:
|
|
12018
|
+
token: RESTRICTED5,
|
|
11667
12019
|
params: { username: "sasjsadmin" },
|
|
11668
12020
|
body: {
|
|
11669
12021
|
displayName: "Hijacked",
|
|
@@ -11679,7 +12031,7 @@ var SASjsApi = (() => {
|
|
|
11679
12031
|
description: "answers 404 with the username it looked up",
|
|
11680
12032
|
identity: ADMIN_SIGNED_IN,
|
|
11681
12033
|
request: {
|
|
11682
|
-
token:
|
|
12034
|
+
token: ADMIN5,
|
|
11683
12035
|
params: { username: "nobody" },
|
|
11684
12036
|
body: { displayName: "Nobody", username: "nobody", password: "none123" }
|
|
11685
12037
|
},
|
|
@@ -11691,7 +12043,7 @@ var SASjsApi = (() => {
|
|
|
11691
12043
|
description: "refuses a display-name change on a provider-managed account",
|
|
11692
12044
|
identity: PROVIDER_MANAGED,
|
|
11693
12045
|
request: {
|
|
11694
|
-
token:
|
|
12046
|
+
token: ADMIN5,
|
|
11695
12047
|
params: { username: "diruser" },
|
|
11696
12048
|
body: { displayName: "Renamed", username: "diruser", password: "dir123" }
|
|
11697
12049
|
},
|
|
@@ -11706,7 +12058,7 @@ var SASjsApi = (() => {
|
|
|
11706
12058
|
description: "refuses a username another account already has",
|
|
11707
12059
|
identity: ADMIN_SIGNED_IN,
|
|
11708
12060
|
request: {
|
|
11709
|
-
token:
|
|
12061
|
+
token: ADMIN5,
|
|
11710
12062
|
params: { username: "sasjsuser" },
|
|
11711
12063
|
body: {
|
|
11712
12064
|
username: "sasjsadmin",
|
|
@@ -11721,7 +12073,7 @@ var SASjsApi = (() => {
|
|
|
11721
12073
|
route: "DELETE /SASjsApi/user/{uid}",
|
|
11722
12074
|
description: "deletes an account as an administrator, without a password",
|
|
11723
12075
|
identity: ADMIN_SIGNED_IN,
|
|
11724
|
-
request: { token:
|
|
12076
|
+
request: { token: ADMIN5, params: { uid: RESTRICTED_UID }, body: {} },
|
|
11725
12077
|
expect: { status: 200, body: "Account Deleted!" }
|
|
11726
12078
|
},
|
|
11727
12079
|
{
|
|
@@ -11729,7 +12081,7 @@ var SASjsApi = (() => {
|
|
|
11729
12081
|
route: "DELETE /SASjsApi/user/{uid}",
|
|
11730
12082
|
description: "refuses a deletion of somebody else's account",
|
|
11731
12083
|
identity: ADMIN_SIGNED_IN,
|
|
11732
|
-
request: { token:
|
|
12084
|
+
request: { token: RESTRICTED5, params: { uid: ADMIN_UID }, body: {} },
|
|
11733
12085
|
expect: { status: 401, error: "Admin account required" }
|
|
11734
12086
|
},
|
|
11735
12087
|
{
|
|
@@ -11737,7 +12089,7 @@ var SASjsApi = (() => {
|
|
|
11737
12089
|
route: "DELETE /SASjsApi/user/{uid}",
|
|
11738
12090
|
description: "answers 404 for an identifier no account has",
|
|
11739
12091
|
identity: ADMIN_SIGNED_IN,
|
|
11740
|
-
request: { token:
|
|
12092
|
+
request: { token: ADMIN5, params: { uid: "user-none" }, body: {} },
|
|
11741
12093
|
expect: { status: 404, error: "User is not found." }
|
|
11742
12094
|
},
|
|
11743
12095
|
{
|
|
@@ -11746,7 +12098,7 @@ var SASjsApi = (() => {
|
|
|
11746
12098
|
description: "deletes an account looked up by username",
|
|
11747
12099
|
identity: ADMIN_SIGNED_IN,
|
|
11748
12100
|
request: {
|
|
11749
|
-
token:
|
|
12101
|
+
token: ADMIN5,
|
|
11750
12102
|
params: { username: "sasjsuser" },
|
|
11751
12103
|
body: {}
|
|
11752
12104
|
},
|
|
@@ -11758,7 +12110,7 @@ var SASjsApi = (() => {
|
|
|
11758
12110
|
description: "refuses a self-deletion whose password is wrong",
|
|
11759
12111
|
identity: ADMIN_SIGNED_IN,
|
|
11760
12112
|
request: {
|
|
11761
|
-
token:
|
|
12113
|
+
token: RESTRICTED5,
|
|
11762
12114
|
params: { username: "sasjsuser" },
|
|
11763
12115
|
body: { password: "wrong123" }
|
|
11764
12116
|
},
|
|
@@ -11769,7 +12121,7 @@ var SASjsApi = (() => {
|
|
|
11769
12121
|
route: "DELETE /SASjsApi/user/by/username/{username}",
|
|
11770
12122
|
description: "answers 404 for a username no account has",
|
|
11771
12123
|
identity: ADMIN_SIGNED_IN,
|
|
11772
|
-
request: { token:
|
|
12124
|
+
request: { token: ADMIN5, params: { username: "nobody" }, body: {} },
|
|
11773
12125
|
expect: { status: 404, error: "User is not found." }
|
|
11774
12126
|
},
|
|
11775
12127
|
// ----------------------------------------------------------------- groups
|
|
@@ -11778,7 +12130,7 @@ var SASjsApi = (() => {
|
|
|
11778
12130
|
route: "GET /SASjsApi/group",
|
|
11779
12131
|
description: "lists the groups",
|
|
11780
12132
|
identity: ADMIN_SIGNED_IN,
|
|
11781
|
-
request: { token:
|
|
12133
|
+
request: { token: RESTRICTED5 },
|
|
11782
12134
|
expect: {
|
|
11783
12135
|
status: 200,
|
|
11784
12136
|
body: [
|
|
@@ -11800,7 +12152,7 @@ var SASjsApi = (() => {
|
|
|
11800
12152
|
route: "GET /SASjsApi/group/{uid}",
|
|
11801
12153
|
description: "returns a group and its members",
|
|
11802
12154
|
identity: ADMIN_SIGNED_IN,
|
|
11803
|
-
request: { token:
|
|
12155
|
+
request: { token: RESTRICTED5, params: { uid: "group-admins" } },
|
|
11804
12156
|
expect: {
|
|
11805
12157
|
status: 200,
|
|
11806
12158
|
partial: {
|
|
@@ -11823,7 +12175,7 @@ var SASjsApi = (() => {
|
|
|
11823
12175
|
route: "GET /SASjsApi/group/{uid}",
|
|
11824
12176
|
description: "answers 404 for an identifier no group has",
|
|
11825
12177
|
identity: ADMIN_SIGNED_IN,
|
|
11826
|
-
request: { token:
|
|
12178
|
+
request: { token: ADMIN5, params: { uid: "group-none" } },
|
|
11827
12179
|
expect: { status: 404, error: "Group not found." }
|
|
11828
12180
|
},
|
|
11829
12181
|
{
|
|
@@ -11831,7 +12183,7 @@ var SASjsApi = (() => {
|
|
|
11831
12183
|
route: "GET /SASjsApi/group/by/groupname/{name}",
|
|
11832
12184
|
description: "finds a group by name",
|
|
11833
12185
|
identity: ADMIN_SIGNED_IN,
|
|
11834
|
-
request: { token:
|
|
12186
|
+
request: { token: ADMIN5, params: { name: "DCGroup" } },
|
|
11835
12187
|
expect: {
|
|
11836
12188
|
status: 200,
|
|
11837
12189
|
partial: { uid: "group-data-controller", name: "DCGroup" }
|
|
@@ -11842,7 +12194,7 @@ var SASjsApi = (() => {
|
|
|
11842
12194
|
route: "GET /SASjsApi/group/by/groupname/{name}",
|
|
11843
12195
|
description: "answers 404 for a name no group has",
|
|
11844
12196
|
identity: ADMIN_SIGNED_IN,
|
|
11845
|
-
request: { token:
|
|
12197
|
+
request: { token: ADMIN5, params: { name: "nope" } },
|
|
11846
12198
|
expect: { status: 404, error: "Group not found." }
|
|
11847
12199
|
},
|
|
11848
12200
|
{
|
|
@@ -11851,7 +12203,7 @@ var SASjsApi = (() => {
|
|
|
11851
12203
|
description: "creates a group with no members",
|
|
11852
12204
|
identity: ADMIN_SIGNED_IN,
|
|
11853
12205
|
request: {
|
|
11854
|
-
token:
|
|
12206
|
+
token: ADMIN5,
|
|
11855
12207
|
body: { name: "NewGroup", description: "A new group", isActive: true }
|
|
11856
12208
|
},
|
|
11857
12209
|
expect: {
|
|
@@ -11870,7 +12222,7 @@ var SASjsApi = (() => {
|
|
|
11870
12222
|
description: "refuses a creation by a caller who is not an administrator",
|
|
11871
12223
|
identity: ADMIN_SIGNED_IN,
|
|
11872
12224
|
request: {
|
|
11873
|
-
token:
|
|
12225
|
+
token: RESTRICTED5,
|
|
11874
12226
|
body: { name: "NewGroup", description: "x" }
|
|
11875
12227
|
},
|
|
11876
12228
|
expect: { status: 401, error: "Admin account required" }
|
|
@@ -11880,7 +12232,7 @@ var SASjsApi = (() => {
|
|
|
11880
12232
|
route: "POST /SASjsApi/group",
|
|
11881
12233
|
description: "refuses a name that is taken",
|
|
11882
12234
|
identity: ADMIN_SIGNED_IN,
|
|
11883
|
-
request: { token:
|
|
12235
|
+
request: { token: ADMIN5, body: { name: "DCGroup", description: "again" } },
|
|
11884
12236
|
expect: { status: 409, error: "Group name already exists." }
|
|
11885
12237
|
},
|
|
11886
12238
|
{
|
|
@@ -11889,7 +12241,7 @@ var SASjsApi = (() => {
|
|
|
11889
12241
|
description: "adds a member and returns the group",
|
|
11890
12242
|
identity: ADMIN_SIGNED_IN,
|
|
11891
12243
|
request: {
|
|
11892
|
-
token:
|
|
12244
|
+
token: ADMIN5,
|
|
11893
12245
|
params: { groupUid: "group-admins", userUid: RESTRICTED_UID }
|
|
11894
12246
|
},
|
|
11895
12247
|
expect: {
|
|
@@ -11903,7 +12255,7 @@ var SASjsApi = (() => {
|
|
|
11903
12255
|
description: "refuses a change to the reserved public group",
|
|
11904
12256
|
identity: PROVIDER_MANAGED,
|
|
11905
12257
|
request: {
|
|
11906
|
-
token:
|
|
12258
|
+
token: ADMIN5,
|
|
11907
12259
|
params: { groupUid: "group-public", userUid: RESTRICTED_UID }
|
|
11908
12260
|
},
|
|
11909
12261
|
expect: { status: 400, error: "Can't add/remove user to 'public' group." }
|
|
@@ -11914,7 +12266,7 @@ var SASjsApi = (() => {
|
|
|
11914
12266
|
description: "refuses a membership change by a non-administrator",
|
|
11915
12267
|
identity: ADMIN_SIGNED_IN,
|
|
11916
12268
|
request: {
|
|
11917
|
-
token:
|
|
12269
|
+
token: RESTRICTED5,
|
|
11918
12270
|
params: { groupUid: "group-admins", userUid: RESTRICTED_UID }
|
|
11919
12271
|
},
|
|
11920
12272
|
expect: { status: 401, error: "Admin account required" }
|
|
@@ -11925,7 +12277,7 @@ var SASjsApi = (() => {
|
|
|
11925
12277
|
description: "answers 404 for a group that does not exist",
|
|
11926
12278
|
identity: ADMIN_SIGNED_IN,
|
|
11927
12279
|
request: {
|
|
11928
|
-
token:
|
|
12280
|
+
token: ADMIN5,
|
|
11929
12281
|
params: { groupUid: "group-none", userUid: RESTRICTED_UID }
|
|
11930
12282
|
},
|
|
11931
12283
|
expect: { status: 404, error: "Group not found." }
|
|
@@ -11936,7 +12288,7 @@ var SASjsApi = (() => {
|
|
|
11936
12288
|
description: "refuses a membership change on a provider-managed group",
|
|
11937
12289
|
identity: PROVIDER_MANAGED,
|
|
11938
12290
|
request: {
|
|
11939
|
-
token:
|
|
12291
|
+
token: ADMIN5,
|
|
11940
12292
|
params: { groupUid: "group-directory", userUid: RESTRICTED_UID }
|
|
11941
12293
|
},
|
|
11942
12294
|
expect: {
|
|
@@ -11950,7 +12302,7 @@ var SASjsApi = (() => {
|
|
|
11950
12302
|
description: "removes a member and returns the group",
|
|
11951
12303
|
identity: ADMIN_SIGNED_IN,
|
|
11952
12304
|
request: {
|
|
11953
|
-
token:
|
|
12305
|
+
token: ADMIN5,
|
|
11954
12306
|
params: { groupUid: "group-data-controller", userUid: RESTRICTED_UID }
|
|
11955
12307
|
},
|
|
11956
12308
|
expect: {
|
|
@@ -11964,7 +12316,7 @@ var SASjsApi = (() => {
|
|
|
11964
12316
|
description: "refuses a membership change for a provider-managed user",
|
|
11965
12317
|
identity: PROVIDER_MANAGED,
|
|
11966
12318
|
request: {
|
|
11967
|
-
token:
|
|
12319
|
+
token: ADMIN5,
|
|
11968
12320
|
params: { groupUid: "group-admins", userUid: "user-directory" }
|
|
11969
12321
|
},
|
|
11970
12322
|
expect: {
|
|
@@ -11978,7 +12330,7 @@ var SASjsApi = (() => {
|
|
|
11978
12330
|
description: "refuses a membership change for a provider-managed user",
|
|
11979
12331
|
identity: PROVIDER_MANAGED,
|
|
11980
12332
|
request: {
|
|
11981
|
-
token:
|
|
12333
|
+
token: ADMIN5,
|
|
11982
12334
|
params: { groupUid: "group-admins", userUid: "user-directory" }
|
|
11983
12335
|
},
|
|
11984
12336
|
expect: {
|
|
@@ -11992,7 +12344,7 @@ var SASjsApi = (() => {
|
|
|
11992
12344
|
description: "refuses a change to the reserved public group",
|
|
11993
12345
|
identity: PROVIDER_MANAGED,
|
|
11994
12346
|
request: {
|
|
11995
|
-
token:
|
|
12347
|
+
token: ADMIN5,
|
|
11996
12348
|
params: { groupUid: "group-public", userUid: RESTRICTED_UID }
|
|
11997
12349
|
},
|
|
11998
12350
|
expect: { status: 400, error: "Can't add/remove user to 'public' group." }
|
|
@@ -12003,7 +12355,7 @@ var SASjsApi = (() => {
|
|
|
12003
12355
|
description: "refuses a membership change by a non-administrator",
|
|
12004
12356
|
identity: ADMIN_SIGNED_IN,
|
|
12005
12357
|
request: {
|
|
12006
|
-
token:
|
|
12358
|
+
token: RESTRICTED5,
|
|
12007
12359
|
params: { groupUid: "group-data-controller", userUid: RESTRICTED_UID }
|
|
12008
12360
|
},
|
|
12009
12361
|
expect: { status: 401, error: "Admin account required" }
|
|
@@ -12014,7 +12366,7 @@ var SASjsApi = (() => {
|
|
|
12014
12366
|
description: "answers 404 for a member that does not exist",
|
|
12015
12367
|
identity: ADMIN_SIGNED_IN,
|
|
12016
12368
|
request: {
|
|
12017
|
-
token:
|
|
12369
|
+
token: ADMIN5,
|
|
12018
12370
|
params: { groupUid: "group-admins", userUid: "user-none" }
|
|
12019
12371
|
},
|
|
12020
12372
|
expect: { status: 404, error: "User not found." }
|
|
@@ -12025,7 +12377,7 @@ var SASjsApi = (() => {
|
|
|
12025
12377
|
description: "refuses a membership change on a provider-managed group",
|
|
12026
12378
|
identity: PROVIDER_MANAGED,
|
|
12027
12379
|
request: {
|
|
12028
|
-
token:
|
|
12380
|
+
token: ADMIN5,
|
|
12029
12381
|
params: { groupUid: "group-directory", userUid: RESTRICTED_UID }
|
|
12030
12382
|
},
|
|
12031
12383
|
expect: {
|
|
@@ -12038,7 +12390,7 @@ var SASjsApi = (() => {
|
|
|
12038
12390
|
route: "DELETE /SASjsApi/group/{uid}",
|
|
12039
12391
|
description: "deletes a group",
|
|
12040
12392
|
identity: ADMIN_SIGNED_IN,
|
|
12041
|
-
request: { token:
|
|
12393
|
+
request: { token: ADMIN5, params: { uid: "group-data-controller" } },
|
|
12042
12394
|
expect: { status: 200 }
|
|
12043
12395
|
},
|
|
12044
12396
|
{
|
|
@@ -12046,7 +12398,7 @@ var SASjsApi = (() => {
|
|
|
12046
12398
|
route: "DELETE /SASjsApi/group/{uid}",
|
|
12047
12399
|
description: "refuses a deletion by a caller who is not an administrator",
|
|
12048
12400
|
identity: ADMIN_SIGNED_IN,
|
|
12049
|
-
request: { token:
|
|
12401
|
+
request: { token: RESTRICTED5, params: { uid: "group-admins" } },
|
|
12050
12402
|
expect: { status: 401, error: "Admin account required" }
|
|
12051
12403
|
},
|
|
12052
12404
|
{
|
|
@@ -12054,7 +12406,7 @@ var SASjsApi = (() => {
|
|
|
12054
12406
|
route: "DELETE /SASjsApi/group/{uid}",
|
|
12055
12407
|
description: "answers 404 for an identifier no group has",
|
|
12056
12408
|
identity: ADMIN_SIGNED_IN,
|
|
12057
|
-
request: { token:
|
|
12409
|
+
request: { token: ADMIN5, params: { uid: "group-none" } },
|
|
12058
12410
|
expect: { status: 404, error: "Group not found." }
|
|
12059
12411
|
},
|
|
12060
12412
|
// ------------------------------------------------------------ permissions
|
|
@@ -12063,7 +12415,7 @@ var SASjsApi = (() => {
|
|
|
12063
12415
|
route: "GET /SASjsApi/info/authorizedRoutes",
|
|
12064
12416
|
description: "answers the route inventory to an administrator",
|
|
12065
12417
|
identity: ADMIN_SIGNED_IN,
|
|
12066
|
-
request: { token:
|
|
12418
|
+
request: { token: ADMIN5 },
|
|
12067
12419
|
expect: {
|
|
12068
12420
|
status: 200,
|
|
12069
12421
|
body: {
|
|
@@ -12087,7 +12439,7 @@ var SASjsApi = (() => {
|
|
|
12087
12439
|
route: "GET /SASjsApi/info/authorizedRoutes",
|
|
12088
12440
|
description: "refuses the inventory to a caller who is not an administrator",
|
|
12089
12441
|
identity: ADMIN_SIGNED_IN,
|
|
12090
|
-
request: { token:
|
|
12442
|
+
request: { token: RESTRICTED5 },
|
|
12091
12443
|
expect: { status: 401, error: "Admin account required" }
|
|
12092
12444
|
},
|
|
12093
12445
|
{
|
|
@@ -12095,7 +12447,7 @@ var SASjsApi = (() => {
|
|
|
12095
12447
|
route: "GET /SASjsApi/info/myAuthorizedRoutes",
|
|
12096
12448
|
description: "answers every route to an administrator",
|
|
12097
12449
|
identity: ADMIN_SIGNED_IN,
|
|
12098
|
-
request: { token:
|
|
12450
|
+
request: { token: ADMIN5 },
|
|
12099
12451
|
expect: {
|
|
12100
12452
|
status: 200,
|
|
12101
12453
|
body: {
|
|
@@ -12119,7 +12471,7 @@ var SASjsApi = (() => {
|
|
|
12119
12471
|
route: "GET /SASjsApi/info/myAuthorizedRoutes",
|
|
12120
12472
|
description: "answers a caller only the routes its rules grant",
|
|
12121
12473
|
identity: ADMIN_SIGNED_IN,
|
|
12122
|
-
request: { token:
|
|
12474
|
+
request: { token: RESTRICTED5 },
|
|
12123
12475
|
expect: {
|
|
12124
12476
|
status: 200,
|
|
12125
12477
|
// /AppStream is visible whatever the rules say; the two grants come from
|
|
@@ -12135,7 +12487,7 @@ var SASjsApi = (() => {
|
|
|
12135
12487
|
route: "GET /SASjsApi/permission",
|
|
12136
12488
|
description: "returns every rule to an administrator",
|
|
12137
12489
|
identity: ADMIN_SIGNED_IN,
|
|
12138
|
-
request: { token:
|
|
12490
|
+
request: { token: ADMIN5 },
|
|
12139
12491
|
expect: {
|
|
12140
12492
|
status: 200,
|
|
12141
12493
|
body: [
|
|
@@ -12168,7 +12520,7 @@ var SASjsApi = (() => {
|
|
|
12168
12520
|
route: "GET /SASjsApi/permission",
|
|
12169
12521
|
description: "returns a caller only their own rules and their groups'",
|
|
12170
12522
|
identity: ADMIN_SIGNED_IN,
|
|
12171
|
-
request: { token:
|
|
12523
|
+
request: { token: RESTRICTED5 },
|
|
12172
12524
|
expect: {
|
|
12173
12525
|
status: 200,
|
|
12174
12526
|
body: [
|
|
@@ -12210,7 +12562,7 @@ var SASjsApi = (() => {
|
|
|
12210
12562
|
description: "creates a rule for a user",
|
|
12211
12563
|
identity: ADMIN_SIGNED_IN,
|
|
12212
12564
|
request: {
|
|
12213
|
-
token:
|
|
12565
|
+
token: ADMIN5,
|
|
12214
12566
|
body: {
|
|
12215
12567
|
path: "/SASjsApi/drive/folder",
|
|
12216
12568
|
type: "Route",
|
|
@@ -12230,7 +12582,7 @@ var SASjsApi = (() => {
|
|
|
12230
12582
|
description: "creates a rule for a group",
|
|
12231
12583
|
identity: ADMIN_SIGNED_IN,
|
|
12232
12584
|
request: {
|
|
12233
|
-
token:
|
|
12585
|
+
token: ADMIN5,
|
|
12234
12586
|
body: {
|
|
12235
12587
|
path: "/SASjsApi/drive/rename",
|
|
12236
12588
|
type: "Route",
|
|
@@ -12254,7 +12606,7 @@ var SASjsApi = (() => {
|
|
|
12254
12606
|
description: "refuses a principal type that is neither a user nor a group",
|
|
12255
12607
|
identity: ADMIN_SIGNED_IN,
|
|
12256
12608
|
request: {
|
|
12257
|
-
token:
|
|
12609
|
+
token: ADMIN5,
|
|
12258
12610
|
body: {
|
|
12259
12611
|
path: "/SASjsApi/drive/deploy",
|
|
12260
12612
|
type: "Route",
|
|
@@ -12274,7 +12626,7 @@ var SASjsApi = (() => {
|
|
|
12274
12626
|
description: "refuses a rule assigned to an administrator",
|
|
12275
12627
|
identity: ADMIN_SIGNED_IN,
|
|
12276
12628
|
request: {
|
|
12277
|
-
token:
|
|
12629
|
+
token: ADMIN5,
|
|
12278
12630
|
body: {
|
|
12279
12631
|
path: "/SASjsApi/drive/folder",
|
|
12280
12632
|
type: "Route",
|
|
@@ -12294,7 +12646,7 @@ var SASjsApi = (() => {
|
|
|
12294
12646
|
description: "refuses a creation by a non-administrator",
|
|
12295
12647
|
identity: ADMIN_SIGNED_IN,
|
|
12296
12648
|
request: {
|
|
12297
|
-
token:
|
|
12649
|
+
token: RESTRICTED5,
|
|
12298
12650
|
body: {
|
|
12299
12651
|
path: "/SASjsApi/drive/folder",
|
|
12300
12652
|
type: "Route",
|
|
@@ -12311,7 +12663,7 @@ var SASjsApi = (() => {
|
|
|
12311
12663
|
description: "answers 404 for a principal that does not exist",
|
|
12312
12664
|
identity: ADMIN_SIGNED_IN,
|
|
12313
12665
|
request: {
|
|
12314
|
-
token:
|
|
12666
|
+
token: ADMIN5,
|
|
12315
12667
|
body: {
|
|
12316
12668
|
path: "/SASjsApi/drive/rename",
|
|
12317
12669
|
type: "Route",
|
|
@@ -12328,7 +12680,7 @@ var SASjsApi = (() => {
|
|
|
12328
12680
|
description: "refuses a group rule that already exists",
|
|
12329
12681
|
identity: ADMIN_SIGNED_IN,
|
|
12330
12682
|
request: {
|
|
12331
|
-
token:
|
|
12683
|
+
token: ADMIN5,
|
|
12332
12684
|
body: {
|
|
12333
12685
|
path: "/SASjsApi/drive/file",
|
|
12334
12686
|
type: "Route",
|
|
@@ -12348,7 +12700,7 @@ var SASjsApi = (() => {
|
|
|
12348
12700
|
description: "refuses a rule that already exists",
|
|
12349
12701
|
identity: ADMIN_SIGNED_IN,
|
|
12350
12702
|
request: {
|
|
12351
|
-
token:
|
|
12703
|
+
token: ADMIN5,
|
|
12352
12704
|
body: {
|
|
12353
12705
|
path: "/SASjsApi/code/execute",
|
|
12354
12706
|
type: "Route",
|
|
@@ -12368,7 +12720,7 @@ var SASjsApi = (() => {
|
|
|
12368
12720
|
description: "flips a rule from Deny to Grant",
|
|
12369
12721
|
identity: ADMIN_SIGNED_IN,
|
|
12370
12722
|
request: {
|
|
12371
|
-
token:
|
|
12723
|
+
token: ADMIN5,
|
|
12372
12724
|
params: { uid: "rule-code" },
|
|
12373
12725
|
body: { setting: "Grant" }
|
|
12374
12726
|
},
|
|
@@ -12380,7 +12732,7 @@ var SASjsApi = (() => {
|
|
|
12380
12732
|
description: "refuses a change by a non-administrator",
|
|
12381
12733
|
identity: ADMIN_SIGNED_IN,
|
|
12382
12734
|
request: {
|
|
12383
|
-
token:
|
|
12735
|
+
token: RESTRICTED5,
|
|
12384
12736
|
params: { uid: "rule-code" },
|
|
12385
12737
|
body: { setting: "Grant" }
|
|
12386
12738
|
},
|
|
@@ -12392,7 +12744,7 @@ var SASjsApi = (() => {
|
|
|
12392
12744
|
description: "answers 404 for a rule that does not exist",
|
|
12393
12745
|
identity: ADMIN_SIGNED_IN,
|
|
12394
12746
|
request: {
|
|
12395
|
-
token:
|
|
12747
|
+
token: ADMIN5,
|
|
12396
12748
|
params: { uid: "rule-none" },
|
|
12397
12749
|
body: { setting: "Grant" }
|
|
12398
12750
|
},
|
|
@@ -12403,7 +12755,7 @@ var SASjsApi = (() => {
|
|
|
12403
12755
|
route: "DELETE /SASjsApi/permission/{uid}",
|
|
12404
12756
|
description: "deletes a rule",
|
|
12405
12757
|
identity: ADMIN_SIGNED_IN,
|
|
12406
|
-
request: { token:
|
|
12758
|
+
request: { token: ADMIN5, params: { uid: "rule-code" } },
|
|
12407
12759
|
expect: { status: 200, body: "Permission Deleted!" }
|
|
12408
12760
|
},
|
|
12409
12761
|
{
|
|
@@ -12411,7 +12763,7 @@ var SASjsApi = (() => {
|
|
|
12411
12763
|
route: "DELETE /SASjsApi/permission/{uid}",
|
|
12412
12764
|
description: "refuses a deletion by a non-administrator",
|
|
12413
12765
|
identity: ADMIN_SIGNED_IN,
|
|
12414
|
-
request: { token:
|
|
12766
|
+
request: { token: RESTRICTED5, params: { uid: "rule-code" } },
|
|
12415
12767
|
expect: { status: 401, error: "Admin account required" }
|
|
12416
12768
|
},
|
|
12417
12769
|
{
|
|
@@ -12419,7 +12771,7 @@ var SASjsApi = (() => {
|
|
|
12419
12771
|
route: "DELETE /SASjsApi/permission/{uid}",
|
|
12420
12772
|
description: "answers 404 for a rule that does not exist",
|
|
12421
12773
|
identity: ADMIN_SIGNED_IN,
|
|
12422
|
-
request: { token:
|
|
12774
|
+
request: { token: ADMIN5, params: { uid: "rule-none" } },
|
|
12423
12775
|
expect: { status: 404, error: "Permission not found." }
|
|
12424
12776
|
},
|
|
12425
12777
|
// --------------------------------------------------------------- clients
|
|
@@ -12428,7 +12780,7 @@ var SASjsApi = (() => {
|
|
|
12428
12780
|
route: "GET /SASjsApi/client",
|
|
12429
12781
|
description: "lists the registered clients",
|
|
12430
12782
|
identity: ADMIN_SIGNED_IN,
|
|
12431
|
-
request: { token:
|
|
12783
|
+
request: { token: ADMIN5 },
|
|
12432
12784
|
expect: {
|
|
12433
12785
|
status: 200,
|
|
12434
12786
|
body: [
|
|
@@ -12452,7 +12804,7 @@ var SASjsApi = (() => {
|
|
|
12452
12804
|
route: "GET /SASjsApi/client",
|
|
12453
12805
|
description: "refuses the list to a caller who is not an administrator",
|
|
12454
12806
|
identity: ADMIN_SIGNED_IN,
|
|
12455
|
-
request: { token:
|
|
12807
|
+
request: { token: RESTRICTED5 },
|
|
12456
12808
|
expect: { status: 401, error: "Admin account required" }
|
|
12457
12809
|
},
|
|
12458
12810
|
{
|
|
@@ -12461,7 +12813,7 @@ var SASjsApi = (() => {
|
|
|
12461
12813
|
description: "registers a client",
|
|
12462
12814
|
identity: ADMIN_SIGNED_IN,
|
|
12463
12815
|
request: {
|
|
12464
|
-
token:
|
|
12816
|
+
token: ADMIN5,
|
|
12465
12817
|
body: {
|
|
12466
12818
|
clientId: "new_app",
|
|
12467
12819
|
clientSecret: "new_secret",
|
|
@@ -12485,7 +12837,7 @@ var SASjsApi = (() => {
|
|
|
12485
12837
|
description: "applies the schema defaults when the lifetimes are omitted",
|
|
12486
12838
|
identity: ADMIN_SIGNED_IN,
|
|
12487
12839
|
request: {
|
|
12488
|
-
token:
|
|
12840
|
+
token: ADMIN5,
|
|
12489
12841
|
body: { clientId: "default_app", clientSecret: "default_secret" }
|
|
12490
12842
|
},
|
|
12491
12843
|
expect: {
|
|
@@ -12504,7 +12856,7 @@ var SASjsApi = (() => {
|
|
|
12504
12856
|
description: "refuses a registration by a non-administrator",
|
|
12505
12857
|
identity: ADMIN_SIGNED_IN,
|
|
12506
12858
|
request: {
|
|
12507
|
-
token:
|
|
12859
|
+
token: RESTRICTED5,
|
|
12508
12860
|
body: {
|
|
12509
12861
|
clientId: "new_app",
|
|
12510
12862
|
clientSecret: "new_secret",
|
|
@@ -12520,7 +12872,7 @@ var SASjsApi = (() => {
|
|
|
12520
12872
|
description: "refuses a client id that is registered, with the 403 the server sends",
|
|
12521
12873
|
identity: ADMIN_SIGNED_IN,
|
|
12522
12874
|
request: {
|
|
12523
|
-
token:
|
|
12875
|
+
token: ADMIN5,
|
|
12524
12876
|
body: {
|
|
12525
12877
|
clientId: "web_app",
|
|
12526
12878
|
clientSecret: "other",
|
|
@@ -12537,7 +12889,7 @@ var SASjsApi = (() => {
|
|
|
12537
12889
|
description: "changes the caller’s own password",
|
|
12538
12890
|
identity: ADMIN_SIGNED_IN,
|
|
12539
12891
|
request: {
|
|
12540
|
-
token:
|
|
12892
|
+
token: RESTRICTED5,
|
|
12541
12893
|
body: { currentPassword: "Orion123", newPassword: "changed123" }
|
|
12542
12894
|
},
|
|
12543
12895
|
expect: { status: 204 }
|
|
@@ -12547,7 +12899,7 @@ var SASjsApi = (() => {
|
|
|
12547
12899
|
route: "PATCH /SASjsApi/auth/updatePassword",
|
|
12548
12900
|
description: "refuses a body without the current password",
|
|
12549
12901
|
identity: ADMIN_SIGNED_IN,
|
|
12550
|
-
request: { token:
|
|
12902
|
+
request: { token: RESTRICTED5, body: { newPassword: "changed123" } },
|
|
12551
12903
|
expect: { status: 400, error: '"currentPassword" is required' }
|
|
12552
12904
|
},
|
|
12553
12905
|
{
|
|
@@ -12566,7 +12918,7 @@ var SASjsApi = (() => {
|
|
|
12566
12918
|
description: "refuses a change whose current password is wrong",
|
|
12567
12919
|
identity: ADMIN_SIGNED_IN,
|
|
12568
12920
|
request: {
|
|
12569
|
-
token:
|
|
12921
|
+
token: RESTRICTED5,
|
|
12570
12922
|
body: { currentPassword: "wrong", newPassword: "changed123" }
|
|
12571
12923
|
},
|
|
12572
12924
|
expect: { status: 403, error: "Invalid current password!" }
|