diff --git a/packages/user-access-policy/src/rule/storage/mongooseRulesStorage.ts b/packages/user-access-policy/src/rule/storage/mongooseRulesStorage.ts index f2a17e14a..f6a702882 100644 --- a/packages/user-access-policy/src/rule/storage/mongooseRulesStorage.ts +++ b/packages/user-access-policy/src/rule/storage/mongooseRulesStorage.ts @@ -22,18 +22,21 @@ import type SearchRuleFilters from "./search/searchRuleFilters.js"; import type SearchRuleFilterSettings from "./search/searchRuleFilterSettings.js"; class MongooseRulesStorage implements RulesStorage { - private model: Model | null; - - constructor(model: Model | null) { - this.model = model; + constructor( + private readingModel: Model | null, + private writingModel: Model | null = null, + ) { + if (null === this.writingModel) { + this.writingModel = this.readingModel; + } } public async insert(record: Rule): Promise { - if (!this.model) { + if (!this.writingModel) { throw new Error("Model is not set"); } - const document = await this.model.create(record); + const document = await this.writingModel.create(record); const ruleRecord = this.convertMongooseRecordToRuleRecord( document.toObject(), @@ -43,11 +46,11 @@ class MongooseRulesStorage implements RulesStorage { } public async insertMany(records: Rule[]): Promise { - if (!this.model) { + if (!this.writingModel) { throw new Error("Model is not set"); } - const documents = await this.model.insertMany(records); + const documents = await this.writingModel.insertMany(records); const objectDocuments = documents.map((document) => document.toObject()); const ruleRecords = @@ -60,13 +63,13 @@ class MongooseRulesStorage implements RulesStorage { filters: SearchRuleFilters, filterSettings?: SearchRuleFilterSettings, ): Promise { - if (!this.model) { + if (!this.readingModel) { throw new Error("Model is not set"); } const query = this.createQuery(filters, filterSettings); - const mongooseRecords = await this.model.find(query).lean().exec(); + const mongooseRecords = await this.readingModel.find(query).lean().exec(); const ruleRecords = this.convertMongooseRecordsToRuleRecords(mongooseRecords); @@ -75,17 +78,25 @@ class MongooseRulesStorage implements RulesStorage { } public async deleteMany(recordFilters: SearchRuleFilters[]): Promise { - if (!this.model) { + if (!this.writingModel) { throw new Error("Model is not set"); } for (const recordFilter of recordFilters) { - await this.model.deleteOne(recordFilter).exec(); + await this.writingModel.deleteOne(recordFilter).exec(); + } + } + + public setReadingModel(readingModel: Model): void { + this.readingModel = readingModel; + + if (null === this.writingModel) { + this.setWritingModel(readingModel); } } - public setModel(model: Model): void { - this.model = model; + public setWritingModel(writingModel: Model): void { + this.writingModel = writingModel; } protected createQuery( diff --git a/packages/user-access-policy/src/rule/storage/search/tests/byIp/v6Short/testFindRuleByIpV6Short.ts b/packages/user-access-policy/src/rule/storage/search/tests/byIp/v6Short/testFindRuleByIpV6Short.ts deleted file mode 100644 index fe4f0e897..000000000 --- a/packages/user-access-policy/src/rule/storage/search/tests/byIp/v6Short/testFindRuleByIpV6Short.ts +++ /dev/null @@ -1,8 +0,0 @@ -import TestFindByIpV6 from "../v6/testFindByIpV6.js"; - -class TestFindRuleByIpV6Short extends TestFindByIpV6 { - protected override readonly userIp: string = "::1"; - protected override readonly anotherUserIp: string = "::2"; -} - -export default TestFindRuleByIpV6Short; diff --git a/packages/user-access-policy/src/rule/storage/search/tests/testFindRule.ts b/packages/user-access-policy/src/rule/storage/search/tests/generic/testFindRule.ts similarity index 95% rename from packages/user-access-policy/src/rule/storage/search/tests/testFindRule.ts rename to packages/user-access-policy/src/rule/storage/search/tests/generic/testFindRule.ts index dc7ebcfa9..ae9b927b4 100644 --- a/packages/user-access-policy/src/rule/storage/search/tests/testFindRule.ts +++ b/packages/user-access-policy/src/rule/storage/search/tests/generic/testFindRule.ts @@ -1,8 +1,8 @@ import { Address4 } from "ip-address"; import { expect } from "vitest"; -import TestFindRuleBase from "./testFindRuleBase.js"; -import type Rule from "../../../rule.js"; -import type SearchRuleFilters from "../searchRuleFilters.js"; +import TestFindRuleBase from "../testFindRuleBase.js"; +import type Rule from "../../../../rule.js"; +import type SearchRuleFilters from "../../searchRuleFilters.js"; class TestFindRule extends TestFindRuleBase { private readonly userIp: Address4 = new Address4("192.168.1.1"); diff --git a/packages/user-access-policy/src/rule/storage/search/tests/testFindRuleByUserId.ts b/packages/user-access-policy/src/rule/storage/search/tests/generic/testFindRuleByUserId.ts similarity index 96% rename from packages/user-access-policy/src/rule/storage/search/tests/testFindRuleByUserId.ts rename to packages/user-access-policy/src/rule/storage/search/tests/generic/testFindRuleByUserId.ts index 390807752..686111f41 100644 --- a/packages/user-access-policy/src/rule/storage/search/tests/testFindRuleByUserId.ts +++ b/packages/user-access-policy/src/rule/storage/search/tests/generic/testFindRuleByUserId.ts @@ -15,7 +15,7 @@ import type { SearchRuleFilters, UserAccessRule, } from "@prosopo/types-database"; -import TestFindRuleBase from "./testFindRuleBase.js"; +import TestFindRuleBase from "../testFindRuleBase.js"; class TestFindRuleByUserId extends TestFindRuleBase { private readonly userId: string = "userId"; diff --git a/packages/user-access-policy/src/rule/storage/search/tests/generic/testMongooseFindRule.spec.ts b/packages/user-access-policy/src/rule/storage/search/tests/generic/testMongooseFindRule.spec.ts new file mode 100644 index 000000000..09c3ca1c6 --- /dev/null +++ b/packages/user-access-policy/src/rule/storage/search/tests/generic/testMongooseFindRule.spec.ts @@ -0,0 +1,12 @@ +import {describe} from "vitest"; +import testMongooseRuleModel from "../../../test/testMongooseRuleModel.js"; +import MongooseRulesStorage from "../../../mongooseRulesStorage.js"; +import TestFindRule from "./testFindRule.js"; + +describe("MongooseFindRule", async () => { + const testModel = await testMongooseRuleModel(); + const storage = new MongooseRulesStorage(testModel); + const tests = new TestFindRule(storage); + + tests.runAll(); +}); diff --git a/packages/user-access-policy/src/rule/storage/search/tests/generic/testMongooseFindRuleByUserId.spec.ts b/packages/user-access-policy/src/rule/storage/search/tests/generic/testMongooseFindRuleByUserId.spec.ts new file mode 100644 index 000000000..374b54c11 --- /dev/null +++ b/packages/user-access-policy/src/rule/storage/search/tests/generic/testMongooseFindRuleByUserId.spec.ts @@ -0,0 +1,12 @@ +import {describe} from "vitest"; +import testMongooseRuleModel from "../../../test/testMongooseRuleModel.js"; +import MongooseRulesStorage from "../../../mongooseRulesStorage.js"; +import TestFindRuleByUserId from "./testFindRuleByUserId.js"; + +describe("MongooseFindRuleByUserId", async () => { + const testModel = await testMongooseRuleModel(); + const storage = new MongooseRulesStorage(testModel); + const tests = new TestFindRuleByUserId(storage); + + tests.runAll(); +}); \ No newline at end of file diff --git a/packages/user-access-policy/src/rule/storage/search/tests/byIp/testFindByIpBase.ts b/packages/user-access-policy/src/rule/storage/search/tests/ip/testFindByIpBase.ts similarity index 100% rename from packages/user-access-policy/src/rule/storage/search/tests/byIp/testFindByIpBase.ts rename to packages/user-access-policy/src/rule/storage/search/tests/ip/testFindByIpBase.ts diff --git a/packages/user-access-policy/src/rule/storage/search/tests/byIp/v4/maskRange/testFindByMaskV4RangeMax.ts b/packages/user-access-policy/src/rule/storage/search/tests/ip/v4/mask/maskRange/max/testFindByMaskV4RangeMax.ts similarity index 87% rename from packages/user-access-policy/src/rule/storage/search/tests/byIp/v4/maskRange/testFindByMaskV4RangeMax.ts rename to packages/user-access-policy/src/rule/storage/search/tests/ip/v4/mask/maskRange/max/testFindByMaskV4RangeMax.ts index 27bcd8233..623a15af8 100644 --- a/packages/user-access-policy/src/rule/storage/search/tests/byIp/v4/maskRange/testFindByMaskV4RangeMax.ts +++ b/packages/user-access-policy/src/rule/storage/search/tests/ip/v4/mask/maskRange/max/testFindByMaskV4RangeMax.ts @@ -1,4 +1,4 @@ -import TestFindByMaskV4 from "../testFindByMaskV4.js"; +import TestFindByMaskV4 from "../../testFindByMaskV4.js"; class TestFindByMaskV4RangeMax extends TestFindByMaskV4 { protected override baseIpAsString = "192.168.0.0"; diff --git a/packages/user-access-policy/src/rule/storage/search/tests/ip/v4/mask/maskRange/max/testMongooseFindByMaskV4RangeMax.spec.ts b/packages/user-access-policy/src/rule/storage/search/tests/ip/v4/mask/maskRange/max/testMongooseFindByMaskV4RangeMax.spec.ts new file mode 100644 index 000000000..a2a9b7570 --- /dev/null +++ b/packages/user-access-policy/src/rule/storage/search/tests/ip/v4/mask/maskRange/max/testMongooseFindByMaskV4RangeMax.spec.ts @@ -0,0 +1,12 @@ +import {describe} from "vitest"; +import testMongooseRuleModel from "../../../../../../../test/testMongooseRuleModel.js"; +import MongooseRulesStorage from "../../../../../../../mongooseRulesStorage.js"; +import TestFindByMaskV4RangeMax from "./testFindByMaskV4RangeMax.js"; + +describe("MongooseFindByMaskV4RangeMax", async () => { + const testModel = await testMongooseRuleModel(); + const storage = new MongooseRulesStorage(testModel); + const tests = new TestFindByMaskV4RangeMax(storage); + + tests.runAll(); +}); \ No newline at end of file diff --git a/packages/user-access-policy/src/rule/storage/search/tests/byIp/v4/maskRange/testFindByMaskV4RangeMin.ts b/packages/user-access-policy/src/rule/storage/search/tests/ip/v4/mask/maskRange/min/testFindByMaskV4RangeMin.ts similarity index 87% rename from packages/user-access-policy/src/rule/storage/search/tests/byIp/v4/maskRange/testFindByMaskV4RangeMin.ts rename to packages/user-access-policy/src/rule/storage/search/tests/ip/v4/mask/maskRange/min/testFindByMaskV4RangeMin.ts index 01fbb88cd..322e0aacf 100644 --- a/packages/user-access-policy/src/rule/storage/search/tests/byIp/v4/maskRange/testFindByMaskV4RangeMin.ts +++ b/packages/user-access-policy/src/rule/storage/search/tests/ip/v4/mask/maskRange/min/testFindByMaskV4RangeMin.ts @@ -1,4 +1,4 @@ -import TestFindByMaskV4 from "../testFindByMaskV4.js"; +import TestFindByMaskV4 from "../../testFindByMaskV4.js"; class TestFindByMaskV4RangeMin extends TestFindByMaskV4 { protected override baseIpAsString = "192.168.1.0"; diff --git a/packages/user-access-policy/src/rule/storage/search/tests/ip/v4/mask/maskRange/min/testMongooseFindByMaskV4RangeMin.spec.ts b/packages/user-access-policy/src/rule/storage/search/tests/ip/v4/mask/maskRange/min/testMongooseFindByMaskV4RangeMin.spec.ts new file mode 100644 index 000000000..10d261ddc --- /dev/null +++ b/packages/user-access-policy/src/rule/storage/search/tests/ip/v4/mask/maskRange/min/testMongooseFindByMaskV4RangeMin.spec.ts @@ -0,0 +1,12 @@ +import {describe} from "vitest"; +import testMongooseRuleModel from "../../../../../../../test/testMongooseRuleModel.js"; +import MongooseRulesStorage from "../../../../../../../mongooseRulesStorage.js"; +import TestFindByMaskV4RangeMin from "./testFindByMaskV4RangeMin.js"; + +describe("MongooseFindByMaskV4RangeMin", async () => { + const testModel = await testMongooseRuleModel(); + const storage = new MongooseRulesStorage(testModel); + const tests = new TestFindByMaskV4RangeMin(storage); + + tests.runAll(); +}); \ No newline at end of file diff --git a/packages/user-access-policy/src/rule/storage/search/tests/byIp/v4/testFindByMaskV4.ts b/packages/user-access-policy/src/rule/storage/search/tests/ip/v4/mask/testFindByMaskV4.ts similarity index 97% rename from packages/user-access-policy/src/rule/storage/search/tests/byIp/v4/testFindByMaskV4.ts rename to packages/user-access-policy/src/rule/storage/search/tests/ip/v4/mask/testFindByMaskV4.ts index e8b9bfa49..b8d20b92c 100644 --- a/packages/user-access-policy/src/rule/storage/search/tests/byIp/v4/testFindByMaskV4.ts +++ b/packages/user-access-policy/src/rule/storage/search/tests/ip/v4/mask/testFindByMaskV4.ts @@ -13,7 +13,7 @@ // limitations under the License. import type { UserIp } from "@prosopo/types-database"; import { Address4 } from "ip-address"; -import TestFindByIpV4 from "./testFindByIpV4.js"; +import TestFindByIpV4 from "../testFindByIpV4.js"; class TestFindByMaskV4 extends TestFindByIpV4 { protected baseIpAsString = "192.168.0.0"; diff --git a/packages/user-access-policy/src/rule/storage/search/tests/ip/v4/mask/testMongooseFindByMaskV4.spec.ts b/packages/user-access-policy/src/rule/storage/search/tests/ip/v4/mask/testMongooseFindByMaskV4.spec.ts new file mode 100644 index 000000000..e69731c3e --- /dev/null +++ b/packages/user-access-policy/src/rule/storage/search/tests/ip/v4/mask/testMongooseFindByMaskV4.spec.ts @@ -0,0 +1,12 @@ +import {describe} from "vitest"; +import testMongooseRuleModel from "../../../../../test/testMongooseRuleModel.js"; +import MongooseRulesStorage from "../../../../../mongooseRulesStorage.js"; +import TestFindByMaskV4 from "./testFindByMaskV4.js"; + +describe("MongooseFindByMaskV4", async () => { + const testModel = await testMongooseRuleModel(); + const storage = new MongooseRulesStorage(testModel); + const tests = new TestFindByMaskV4(storage); + + tests.runAll(); +}); \ No newline at end of file diff --git a/packages/user-access-policy/src/rule/storage/search/tests/byIp/v4/testFindByIpV4.ts b/packages/user-access-policy/src/rule/storage/search/tests/ip/v4/testFindByIpV4.ts similarity index 100% rename from packages/user-access-policy/src/rule/storage/search/tests/byIp/v4/testFindByIpV4.ts rename to packages/user-access-policy/src/rule/storage/search/tests/ip/v4/testFindByIpV4.ts diff --git a/packages/user-access-policy/src/rule/storage/search/tests/ip/v4/testMongooseFindByIpV4.spec.ts b/packages/user-access-policy/src/rule/storage/search/tests/ip/v4/testMongooseFindByIpV4.spec.ts new file mode 100644 index 000000000..ff9550331 --- /dev/null +++ b/packages/user-access-policy/src/rule/storage/search/tests/ip/v4/testMongooseFindByIpV4.spec.ts @@ -0,0 +1,12 @@ +import {describe} from "vitest"; +import testMongooseRuleModel from "../../../../test/testMongooseRuleModel.js"; +import MongooseRulesStorage from "../../../../mongooseRulesStorage.js"; +import TestFindByIpV4 from "./testFindByIpV4.js"; + +describe("MongooseFindByIpV4", async () => { + const testModel = await testMongooseRuleModel(); + const storage = new MongooseRulesStorage(testModel); + const tests = new TestFindByIpV4(storage); + + tests.runAll(); +}); \ No newline at end of file diff --git a/packages/user-access-policy/src/rule/storage/search/tests/byIp/v6/maskRange/testFindByIpMaskV6RangeMax.ts b/packages/user-access-policy/src/rule/storage/search/tests/ip/v6/mask/maskRange/max/testFindByIpMaskV6RangeMax.ts similarity index 89% rename from packages/user-access-policy/src/rule/storage/search/tests/byIp/v6/maskRange/testFindByIpMaskV6RangeMax.ts rename to packages/user-access-policy/src/rule/storage/search/tests/ip/v6/mask/maskRange/max/testFindByIpMaskV6RangeMax.ts index 92e53a5cc..366e77262 100644 --- a/packages/user-access-policy/src/rule/storage/search/tests/byIp/v6/maskRange/testFindByIpMaskV6RangeMax.ts +++ b/packages/user-access-policy/src/rule/storage/search/tests/ip/v6/mask/maskRange/max/testFindByIpMaskV6RangeMax.ts @@ -1,4 +1,4 @@ -import TestFindByIpMaskV6 from "../testFindByIpMaskV6.js"; +import TestFindByIpMaskV6 from "../../testFindByIpMaskV6.js"; class TestFindByIpMaskV6RangeMax extends TestFindByIpMaskV6 { protected override baseIpAsString = "2001:db8:3333:4444:5555:6666:7777:8888"; diff --git a/packages/user-access-policy/src/rule/storage/search/tests/ip/v6/mask/maskRange/max/testMongooseFindByIpMaskV6RangeMax.spec.ts b/packages/user-access-policy/src/rule/storage/search/tests/ip/v6/mask/maskRange/max/testMongooseFindByIpMaskV6RangeMax.spec.ts new file mode 100644 index 000000000..e5e0fea23 --- /dev/null +++ b/packages/user-access-policy/src/rule/storage/search/tests/ip/v6/mask/maskRange/max/testMongooseFindByIpMaskV6RangeMax.spec.ts @@ -0,0 +1,12 @@ +import {describe} from "vitest"; +import testMongooseRuleModel from "../../../../../../../test/testMongooseRuleModel.js"; +import MongooseRulesStorage from "../../../../../../../mongooseRulesStorage.js"; +import TestFindByIpMaskV6RangeMax from "./testFindByIpMaskV6RangeMax.js"; + +describe("MongooseFindByIpMaskV6RangeMax", async () => { + const testModel = await testMongooseRuleModel(); + const storage = new MongooseRulesStorage(testModel); + const tests = new TestFindByIpMaskV6RangeMax(storage); + + tests.runAll(); +}); \ No newline at end of file diff --git a/packages/user-access-policy/src/rule/storage/search/tests/byIp/v6/maskRange/testFindByIpMaskV6RangeMin.ts b/packages/user-access-policy/src/rule/storage/search/tests/ip/v6/mask/maskRange/min/testFindByIpMaskV6RangeMin.ts similarity index 89% rename from packages/user-access-policy/src/rule/storage/search/tests/byIp/v6/maskRange/testFindByIpMaskV6RangeMin.ts rename to packages/user-access-policy/src/rule/storage/search/tests/ip/v6/mask/maskRange/min/testFindByIpMaskV6RangeMin.ts index f994f8d1c..f03ad395f 100644 --- a/packages/user-access-policy/src/rule/storage/search/tests/byIp/v6/maskRange/testFindByIpMaskV6RangeMin.ts +++ b/packages/user-access-policy/src/rule/storage/search/tests/ip/v6/mask/maskRange/min/testFindByIpMaskV6RangeMin.ts @@ -1,4 +1,4 @@ -import TestFindByIpMaskV6 from "../testFindByIpMaskV6.js"; +import TestFindByIpMaskV6 from "../../testFindByIpMaskV6.js"; class TestFindByIpMaskV6RangeMin extends TestFindByIpMaskV6 { protected override baseIpAsString = "2001:db8:3333:4444:5555:6666:7777:8888"; diff --git a/packages/user-access-policy/src/rule/storage/search/tests/ip/v6/mask/maskRange/min/testMongooseFindByIpMaskV6RangeMin.spec.ts b/packages/user-access-policy/src/rule/storage/search/tests/ip/v6/mask/maskRange/min/testMongooseFindByIpMaskV6RangeMin.spec.ts new file mode 100644 index 000000000..29686bc3c --- /dev/null +++ b/packages/user-access-policy/src/rule/storage/search/tests/ip/v6/mask/maskRange/min/testMongooseFindByIpMaskV6RangeMin.spec.ts @@ -0,0 +1,12 @@ +import { describe } from "vitest"; +import testMongooseRuleModel from "../../../../../../../test/testMongooseRuleModel.js"; +import MongooseRulesStorage from "../../../../../../../mongooseRulesStorage.js"; +import TestFindByIpMaskV6RangeMin from "./testFindByIpMaskV6RangeMin.js"; + +describe("MongooseFindByIpMaskV6RangeMin", async () => { + const testModel = await testMongooseRuleModel(); + const storage = new MongooseRulesStorage(testModel); + const tests = new TestFindByIpMaskV6RangeMin(storage); + + tests.runAll(); +}); diff --git a/packages/user-access-policy/src/rule/storage/search/tests/byIp/v6/testFindByIpMaskV6.ts b/packages/user-access-policy/src/rule/storage/search/tests/ip/v6/mask/testFindByIpMaskV6.ts similarity index 92% rename from packages/user-access-policy/src/rule/storage/search/tests/byIp/v6/testFindByIpMaskV6.ts rename to packages/user-access-policy/src/rule/storage/search/tests/ip/v6/mask/testFindByIpMaskV6.ts index dcadd48c6..578fb0fb8 100644 --- a/packages/user-access-policy/src/rule/storage/search/tests/byIp/v6/testFindByIpMaskV6.ts +++ b/packages/user-access-policy/src/rule/storage/search/tests/ip/v6/mask/testFindByIpMaskV6.ts @@ -1,6 +1,6 @@ import { Address6 } from "ip-address"; -import TestFindByIpV6 from "./testFindByIpV6.js"; -import type Ip from "../../../../../../ip/ip.js"; +import type Ip from "../../../../../../../ip/ip.js"; +import TestFindByIpV6 from "../testFindByIpV6.js"; class TestFindByIpMaskV6 extends TestFindByIpV6 { protected baseIpAsString = "2001:db8:3333:4444:5555:6666:7777:8888"; diff --git a/packages/user-access-policy/src/rule/storage/search/tests/ip/v6/mask/testMongooseFindByIpMaskV6.spec.ts b/packages/user-access-policy/src/rule/storage/search/tests/ip/v6/mask/testMongooseFindByIpMaskV6.spec.ts new file mode 100644 index 000000000..61e8a2280 --- /dev/null +++ b/packages/user-access-policy/src/rule/storage/search/tests/ip/v6/mask/testMongooseFindByIpMaskV6.spec.ts @@ -0,0 +1,12 @@ +import {describe} from "vitest"; +import testMongooseRuleModel from "../../../../../test/testMongooseRuleModel.js"; +import MongooseRulesStorage from "../../../../../mongooseRulesStorage.js"; +import TestFindByIpMaskV6 from "./testFindByIpMaskV6.js"; + +describe("MongooseFindByIpMaskV6", async () => { + const testModel = await testMongooseRuleModel(); + const storage = new MongooseRulesStorage(testModel); + const tests = new TestFindByIpMaskV6(storage); + + tests.runAll(); +}); \ No newline at end of file diff --git a/packages/user-access-policy/src/rule/storage/search/tests/byIp/v6Short/maskRange/testFindByIpMaskV6ShortRangeMax.ts b/packages/user-access-policy/src/rule/storage/search/tests/ip/v6/short/mask/maskRange/max/testFindByIpMaskV6ShortRangeMax.ts similarity index 92% rename from packages/user-access-policy/src/rule/storage/search/tests/byIp/v6Short/maskRange/testFindByIpMaskV6ShortRangeMax.ts rename to packages/user-access-policy/src/rule/storage/search/tests/ip/v6/short/mask/maskRange/max/testFindByIpMaskV6ShortRangeMax.ts index 1efbc2295..52eb3a739 100644 --- a/packages/user-access-policy/src/rule/storage/search/tests/byIp/v6Short/maskRange/testFindByIpMaskV6ShortRangeMax.ts +++ b/packages/user-access-policy/src/rule/storage/search/tests/ip/v6/short/mask/maskRange/max/testFindByIpMaskV6ShortRangeMax.ts @@ -11,7 +11,7 @@ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. -import TestFindByIpMaskV6 from "../../v6/testFindByIpMaskV6.js"; +import TestFindByIpMaskV6 from "../../../../mask/testFindByIpMaskV6.js"; class TestFindByIpMaskV6ShortRangeMax extends TestFindByIpMaskV6 { protected override baseIpAsString = "::1"; diff --git a/packages/user-access-policy/src/rule/storage/search/tests/ip/v6/short/mask/maskRange/max/testMongooseFindByIpMaskV6ShortRangeMax.spec.ts b/packages/user-access-policy/src/rule/storage/search/tests/ip/v6/short/mask/maskRange/max/testMongooseFindByIpMaskV6ShortRangeMax.spec.ts new file mode 100644 index 000000000..a361c5ffb --- /dev/null +++ b/packages/user-access-policy/src/rule/storage/search/tests/ip/v6/short/mask/maskRange/max/testMongooseFindByIpMaskV6ShortRangeMax.spec.ts @@ -0,0 +1,12 @@ +import {describe} from "vitest"; +import testMongooseRuleModel from "../../../../../../../../test/testMongooseRuleModel.js"; +import MongooseRulesStorage from "../../../../../../../../mongooseRulesStorage.js"; +import {TestFindByIpMaskV6ShortRangeMax} from "./testFindByIpMaskV6ShortRangeMax.js"; + +describe("MongooseFindByIpV6MaskV6ShortRangeMax", async () => { + const testModel = await testMongooseRuleModel(); + const storage = new MongooseRulesStorage(testModel); + const tests = new TestFindByIpMaskV6ShortRangeMax(storage); + + tests.runAll(); +}); \ No newline at end of file diff --git a/packages/user-access-policy/src/rule/storage/search/tests/byIp/v6Short/maskRange/testFindRuleByIpMaskV6ShortRangeMin.ts b/packages/user-access-policy/src/rule/storage/search/tests/ip/v6/short/mask/maskRange/min/testFindByIpMaskV6ShortRangeMin.ts similarity index 81% rename from packages/user-access-policy/src/rule/storage/search/tests/byIp/v6Short/maskRange/testFindRuleByIpMaskV6ShortRangeMin.ts rename to packages/user-access-policy/src/rule/storage/search/tests/ip/v6/short/mask/maskRange/min/testFindByIpMaskV6ShortRangeMin.ts index 1233a5935..7da1d8f66 100644 --- a/packages/user-access-policy/src/rule/storage/search/tests/byIp/v6Short/maskRange/testFindRuleByIpMaskV6ShortRangeMin.ts +++ b/packages/user-access-policy/src/rule/storage/search/tests/ip/v6/short/mask/maskRange/min/testFindByIpMaskV6ShortRangeMin.ts @@ -11,9 +11,9 @@ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. -import TestFindByIpMaskV6 from "../../v6/testFindByIpMaskV6.js"; +import TestFindByIpMaskV6 from "../../../../mask/testFindByIpMaskV6.js"; -class TestFindRuleByIpMaskV6ShortRangeMin extends TestFindByIpMaskV6 { +class TestFindByIpMaskV6ShortRangeMin extends TestFindByIpMaskV6 { protected override baseIpAsString = "::2"; protected override rangeMinIpAsString = "::2"; protected override rangeMaxIpAsString = "::4"; @@ -22,4 +22,4 @@ class TestFindRuleByIpMaskV6ShortRangeMin extends TestFindByIpMaskV6 { protected override readonly anotherUserIp: string = "::1"; } -export default TestFindRuleByIpMaskV6ShortRangeMin; +export default TestFindByIpMaskV6ShortRangeMin; diff --git a/packages/user-access-policy/src/rule/storage/search/tests/ip/v6/short/mask/maskRange/min/testMongooseFindByIpMaskV6ShortRangeMix.spec.ts b/packages/user-access-policy/src/rule/storage/search/tests/ip/v6/short/mask/maskRange/min/testMongooseFindByIpMaskV6ShortRangeMix.spec.ts new file mode 100644 index 000000000..8de53e490 --- /dev/null +++ b/packages/user-access-policy/src/rule/storage/search/tests/ip/v6/short/mask/maskRange/min/testMongooseFindByIpMaskV6ShortRangeMix.spec.ts @@ -0,0 +1,12 @@ +import {describe} from "vitest"; +import testMongooseRuleModel from "../../../../../../../../test/testMongooseRuleModel.js"; +import MongooseRulesStorage from "../../../../../../../../mongooseRulesStorage.js"; +import TestFindByIpMaskV6ShortRangeMin from "./testFindByIpMaskV6ShortRangeMin.js"; + +describe("MongooseFindByIpMaskV6ShortRangeMin", async () => { + const testModel = await testMongooseRuleModel(); + const storage = new MongooseRulesStorage(testModel); + const tests = new TestFindByIpMaskV6ShortRangeMin(storage); + + tests.runAll(); +}); \ No newline at end of file diff --git a/packages/user-access-policy/src/rule/storage/search/tests/byIp/v6Short/testFindByIpMaskV6Short.ts b/packages/user-access-policy/src/rule/storage/search/tests/ip/v6/short/mask/testFindByIpMaskV6Short.ts similarity index 93% rename from packages/user-access-policy/src/rule/storage/search/tests/byIp/v6Short/testFindByIpMaskV6Short.ts rename to packages/user-access-policy/src/rule/storage/search/tests/ip/v6/short/mask/testFindByIpMaskV6Short.ts index df75a9bf5..7a86baf7b 100644 --- a/packages/user-access-policy/src/rule/storage/search/tests/byIp/v6Short/testFindByIpMaskV6Short.ts +++ b/packages/user-access-policy/src/rule/storage/search/tests/ip/v6/short/mask/testFindByIpMaskV6Short.ts @@ -11,7 +11,7 @@ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. -import TestFindByIpMaskV6 from "../v6/testFindByIpMaskV6.js"; +import TestFindByIpMaskV6 from "../../mask/testFindByIpMaskV6.js"; class TestFindByIpMaskV6Short extends TestFindByIpMaskV6 { protected override baseIpAsString = "::1"; diff --git a/packages/user-access-policy/src/rule/storage/search/tests/ip/v6/short/mask/testMongooseFindByIpMaskV6Short.spec.ts b/packages/user-access-policy/src/rule/storage/search/tests/ip/v6/short/mask/testMongooseFindByIpMaskV6Short.spec.ts new file mode 100644 index 000000000..864f2e5ac --- /dev/null +++ b/packages/user-access-policy/src/rule/storage/search/tests/ip/v6/short/mask/testMongooseFindByIpMaskV6Short.spec.ts @@ -0,0 +1,12 @@ +import {describe} from "vitest"; +import testMongooseRuleModel from "../../../../../../test/testMongooseRuleModel.js"; +import MongooseRulesStorage from "../../../../../../mongooseRulesStorage.js"; +import TestFindByIpMaskV6Short from "./testFindByIpMaskV6Short.js"; + +describe("MongooseFindByIpMaskV6Short", async () => { + const testModel = await testMongooseRuleModel(); + const storage = new MongooseRulesStorage(testModel); + const tests = new TestFindByIpMaskV6Short(storage); + + tests.runAll(); +}); \ No newline at end of file diff --git a/packages/user-access-policy/src/rule/storage/search/tests/ip/v6/short/testFindByIpV6Short.ts b/packages/user-access-policy/src/rule/storage/search/tests/ip/v6/short/testFindByIpV6Short.ts new file mode 100644 index 000000000..b52cf5658 --- /dev/null +++ b/packages/user-access-policy/src/rule/storage/search/tests/ip/v6/short/testFindByIpV6Short.ts @@ -0,0 +1,8 @@ +import TestFindByIpV6 from "../testFindByIpV6.js"; + +class TestFindByIpV6Short extends TestFindByIpV6 { + protected override readonly userIp: string = "::1"; + protected override readonly anotherUserIp: string = "::2"; +} + +export default TestFindByIpV6Short; diff --git a/packages/user-access-policy/src/rule/storage/search/tests/ip/v6/short/testMongooseFindByIpV6Short.spec.ts b/packages/user-access-policy/src/rule/storage/search/tests/ip/v6/short/testMongooseFindByIpV6Short.spec.ts new file mode 100644 index 000000000..82e0387cc --- /dev/null +++ b/packages/user-access-policy/src/rule/storage/search/tests/ip/v6/short/testMongooseFindByIpV6Short.spec.ts @@ -0,0 +1,12 @@ +import {describe} from "vitest"; +import TestFindByIpV6Short from "./testFindByIpV6Short.js"; +import testMongooseRuleModel from "../../../../../test/testMongooseRuleModel.js"; +import MongooseRulesStorage from "../../../../../mongooseRulesStorage.js"; + +describe("MongooseFindByIpV6Short", async () => { + const testModel = await testMongooseRuleModel(); + const storage = new MongooseRulesStorage(testModel); + const tests = new TestFindByIpV6Short(storage); + + tests.runAll(); +}); \ No newline at end of file diff --git a/packages/user-access-policy/src/rule/storage/search/tests/byIp/v6/testFindByIpV6.ts b/packages/user-access-policy/src/rule/storage/search/tests/ip/v6/testFindByIpV6.ts similarity index 100% rename from packages/user-access-policy/src/rule/storage/search/tests/byIp/v6/testFindByIpV6.ts rename to packages/user-access-policy/src/rule/storage/search/tests/ip/v6/testFindByIpV6.ts diff --git a/packages/user-access-policy/src/rule/storage/search/tests/ip/v6/testMongooseFindByIpV6.spec.ts b/packages/user-access-policy/src/rule/storage/search/tests/ip/v6/testMongooseFindByIpV6.spec.ts new file mode 100644 index 000000000..66d217005 --- /dev/null +++ b/packages/user-access-policy/src/rule/storage/search/tests/ip/v6/testMongooseFindByIpV6.spec.ts @@ -0,0 +1,12 @@ +import {describe} from "vitest"; +import testMongooseRuleModel from "../../../../test/testMongooseRuleModel.js"; +import MongooseRulesStorage from "../../../../mongooseRulesStorage.js"; +import TestFindByIpV6 from "./testFindByIpV6.js"; + +describe("MongooseFindByIpV6", async () => { + const testModel = await testMongooseRuleModel(); + const storage = new MongooseRulesStorage(testModel); + const tests = new TestFindByIpV6(storage); + + tests.runAll(); +}); \ No newline at end of file