|
1 | 1 | import * as t from "tap";
|
2 |
| -import { Endpoints } from "./Endpoints"; |
3 | 2 | import { ServiceConfig } from "./ServiceConfig";
|
4 | 3 |
|
5 | 4 | t.test("it returns false if empty rules", async () => {
|
6 | 5 | const config = new ServiceConfig([], 0, [], []);
|
7 | 6 | t.same(config.getLastUpdatedAt(), 0);
|
8 | 7 | t.same(config.isUserBlocked("id"), false);
|
9 | 8 | t.same(config.isAllowedIP("1.2.3.4"), false);
|
10 |
| - t.same(config.getEndpoints(), new Endpoints([])); |
| 9 | + t.same( |
| 10 | + config.getEndpoint({ url: undefined, method: undefined, route: undefined }), |
| 11 | + undefined |
| 12 | + ); |
11 | 13 | });
|
12 | 14 |
|
13 | 15 | t.test("it works", async () => {
|
@@ -51,53 +53,25 @@ t.test("it works", async () => {
|
51 | 53 |
|
52 | 54 | t.same(config.isUserBlocked("123"), true);
|
53 | 55 | t.same(config.isUserBlocked("567"), false);
|
54 |
| -}); |
55 |
| - |
56 |
| -t.test("it returns endpoints", async () => { |
57 |
| - const config = new ServiceConfig( |
58 |
| - [ |
59 |
| - { |
60 |
| - method: "GET", |
61 |
| - route: "/foo", |
62 |
| - forceProtectionOff: false, |
63 |
| - rateLimiting: { enabled: true, maxRequests: 10, windowSizeInMS: 1000 }, |
64 |
| - }, |
65 |
| - { |
66 |
| - method: "POST", |
67 |
| - route: "/foo", |
68 |
| - forceProtectionOff: true, |
69 |
| - rateLimiting: { |
70 |
| - enabled: false, |
71 |
| - maxRequests: 0, |
72 |
| - windowSizeInMS: 0, |
73 |
| - }, |
74 |
| - }, |
75 |
| - ], |
76 |
| - 0, |
77 |
| - [], |
78 |
| - [] |
79 |
| - ); |
80 |
| - |
81 | 56 | t.same(
|
82 |
| - config.getEndpoints(), |
83 |
| - new Endpoints([ |
84 |
| - { |
| 57 | + config.getEndpoint({ |
| 58 | + url: undefined, |
| 59 | + method: "GET", |
| 60 | + route: "/foo", |
| 61 | + }), |
| 62 | + { |
| 63 | + endpoint: { |
85 | 64 | method: "GET",
|
86 | 65 | route: "/foo",
|
87 | 66 | forceProtectionOff: false,
|
88 |
| - rateLimiting: { enabled: true, maxRequests: 10, windowSizeInMS: 1000 }, |
89 |
| - }, |
90 |
| - { |
91 |
| - method: "POST", |
92 |
| - route: "/foo", |
93 |
| - forceProtectionOff: true, |
94 | 67 | rateLimiting: {
|
95 | 68 | enabled: false,
|
96 | 69 | maxRequests: 0,
|
97 | 70 | windowSizeInMS: 0,
|
98 | 71 | },
|
99 | 72 | },
|
100 |
| - ]) |
| 73 | + route: "/foo", |
| 74 | + } |
101 | 75 | );
|
102 | 76 | });
|
103 | 77 |
|
|
0 commit comments