From 127b2a2ee9af59bebeb1a9bd75112c98ac12c39e Mon Sep 17 00:00:00 2001 From: furkanakinci Date: Fri, 6 Dec 2024 22:45:43 +0300 Subject: [PATCH] =?UTF-8?q?Dosyalar=C4=B1=20"/"=20dizinine=20y=C3=BCkle?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- AccessControl.class | Bin 0 -> 747 bytes AccessControlTest.class | Bin 0 -> 6113 bytes AccessControlTest.java | 263 ++++++++++++++++++++++++++++++++++++++++ Main.class | Bin 0 -> 1299 bytes explanations.md | 65 ++++++++++ 5 files changed, 328 insertions(+) create mode 100644 AccessControl.class create mode 100644 AccessControlTest.class create mode 100644 AccessControlTest.java create mode 100644 Main.class create mode 100644 explanations.md diff --git a/AccessControl.class b/AccessControl.class new file mode 100644 index 0000000000000000000000000000000000000000..9890ee92289799b119191a01eb469c4760695445 GIT binary patch literal 747 zcmZ`#%Wl&^6g`tTaqQ+D+*10GDmHBwL=*|B0wF?qMGABg)Jjn{6K6`MaqP-=sQM|% z4zXa<4J#xTd;s5s5XVj`l?98rbIyI9dw>1;@e{xcY@5gktWBi$o9FVAY_?oiMbS~< z$6?@^Fa)Zp-;@5w=JDWMxv@b0srGgJOdz|vcOqaM1w&;c3#*76@&c8P_SO68WT3(i za^NX}dM9wDcOpZb@TJp;M>-N%@BC-{6L!+kLQ%`}f=e|NDD3uny>@S}Ct&O7)#Snp zt`sK-I?5v%buW~wrPrFqBLR!$)1i)oka!eK!{f7;@`}mrGy@Y zO|m9`!9TbE9ffac*rrXwV8IG)ago5kM8<7Vp=GhCv00MccZ{m_8D)OeFEEX-FtU&H z8#C0L{0v1WH@|V3bgpd9ZfIdE2{UI|V>#v=6{j$V?O1c6AQ76hID$yWHj?l*)b}>@4N?(rb4c3VA?0mo(HSTxF l-s?mKPHEsCk;Td2v+B>qZ!|<=OQ|iVww~N_lPMW&{RJi+jtl?* literal 0 HcmV?d00001 diff --git a/AccessControlTest.class b/AccessContro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DHO0B+#^?~E(|v_TRXSqy0IKMJOL5BP>kLiDIU2#O0k=AF(ZRP`e8(*fZ55u9 z_+oLaBst8On5CC9WjG(Gms|N1=n7@w0zeeMK@K%RY+PFd0T64gc`k(#Q=VX9k>o<-3Y zXjW}>8h?fAi4N0QQ;yR7u^~^9rb!&}b4jClG>PWpg4KjN-7FCr@dmC(5u$V^Ev9oY z1&t0I(H+D*@OB!1fS;D+2-|g5wo{Z3RHz5_bUbd;oR=a18+00&raj!1myP zRZ;&QJg+2R7XZ5fxE_E#0Nen;i$ege3I-U7L~B%ls|$d>J$NYqF9YD^0K5W#n*gYX z0PF}3sM>?)7XW=r%mKIsfPDb$2cQAKfe?V5!2qL3lJSZqUQ+<{MbHAE4ZvXlZUvwN zKsN;7+F*d94#pKpvaSH=i{LH*?gro<0PY3gJ^=0y0eC?$Kv4%(fEN}3eGxnWz*m@DKp+4*_^lK)@19+*K0rVE{e?z()c27yus!;1eMLyMqCWEUr=P!Sy8pp9J7j z0DKyN&j9dQ06rH2uqQa6DvLK10DXJ#MF748z?T7d7=T9rcr*my#lZl@9#jEtED88J z0N()Mn*e+ZfNulvoe+S%!2wmbnM(?Qz9e}UfbRkDeE@y{zz+fVQ3$|Gg9Fwm%FJaY z0Y3)dCjk5ufS&>Ia{zu30`T(SfU3*F6$L=w9{du3UjguI0Dc3&ZvpsS2*6Fj07Vw7 z_Ml!8@OuFM0Kgvs_!9ts2H-Ct05=B*R9zM_1wh{({1t$|0q}PK{sF*00r*!4z-%x; zaTZr9>L4!#$ndWtD16)} + * - isWeekend: {weekend, weekday} + * + * Choose representative combinations: + * 1) Not employee, not auditor, during working hours, weekday -> expected false + * 2) Employee, no special auth, not auditor, during working hours, weekday -> expected true + * 3) Employee, special auth, any hour, weekend -> expected true (special auth overrides) + * 4) Auditor, during working hours, weekend -> expected true (no weekend restriction) + * 5) Auditor, before working hours, weekday -> expected false + */ + + @Test + public void testEquivalence1() { + // Not employee, not auditor, working hours (10), weekday + long start = System.nanoTime(); + boolean result = ac.isAccessAllowed(false, false, false, 10, false); + long end = System.nanoTime(); + System.out.println("testEquivalence1 duration (ns): " + (end - start)); + assertFalse(result); + } + + @Test + public void testEquivalence2() { + // Employee, no special auth, not auditor, working hours (10), weekday + long start = System.nanoTime(); + boolean result = ac.isAccessAllowed(true, false, false, 10, false); + long end = System.nanoTime(); + System.out.println("testEquivalence2 duration (ns): " + (end - start)); + assertTrue(result); + } + + @Test + public void testEquivalence3() { + // Employee, special auth, after hours (17), weekend + long start = System.nanoTime(); + boolean result = ac.isAccessAllowed(true, true, false, 17, true); + long end = System.nanoTime(); + System.out.println("testEquivalence3 duration (ns): " + (end - start)); + assertTrue(result); + } + + @Test + public void testEquivalence4() { + // Auditor, during working hours (16), weekend + long start = System.nanoTime(); + boolean result = ac.isAccessAllowed(false, false, true, 16, true); + long end = System.nanoTime(); + System.out.println("testEquivalence4 duration (ns): " + (end - start)); + assertTrue(result); + } + + @Test + public void testEquivalence5() { + // Auditor, before working hours (8), weekday + long start = System.nanoTime(); + boolean result = ac.isAccessAllowed(false, false, true, 8, false); + long end = System.nanoTime(); + System.out.println("testEquivalence5 duration (ns): " + (end - start)); + assertFalse(result); + } + + /** + * --------------------------- + * BOUNDARY VALUE TESTS + * --------------------------- + * Boundary values around working hours: 8 (just before), 9 (start), 16 (end), 17 (just after) + * Test with employee, auditor, and special auth where appropriate. + */ + + @Test + public void testBoundaryBeforeWorkHoursEmployee() { + // Employee, no special auth, hour=8 (before start), weekday + long start = System.nanoTime(); + boolean result = ac.isAccessAllowed(true, false, false, 8, false); + long end = System.nanoTime(); + System.out.println("testBoundaryBeforeWorkHoursEmployee duration (ns): " + (end - start)); + assertFalse(result); + } + + @Test + public void testBoundaryStartWorkHoursEmployee() { + // Employee, no special auth, hour=9 (start), weekday + long start = System.nanoTime(); + boolean result = ac.isAccessAllowed(true, false, false, 9, false); + long end = System.nanoTime(); + System.out.println("testBoundaryStartWorkHoursEmployee duration (ns): " + (end - start)); + assertTrue(result); + } + + @Test + public void testBoundaryEndWorkHoursEmployee() { + // Employee, no special auth, hour=16 (end), weekday + long start = System.nanoTime(); + boolean result = ac.isAccessAllowed(true, false, false, 16, false); + long end = System.nanoTime(); + System.out.println("testBoundaryEndWorkHoursEmployee duration (ns): " + (end - start)); + assertTrue(result); + } + + @Test + public void testBoundaryAfterWorkHoursEmployee() { + // Employee, no special auth, hour=17 (after end), weekday + long start = System.nanoTime(); + boolean result = ac.isAccessAllowed(true, false, false, 17, false); + long end = System.nanoTime(); + System.out.println("testBoundaryAfterWorkHoursEmployee duration (ns): " + (end - start)); + assertFalse(result); + } + + @Test + public void testBoundaryAuditorBeforeHours() { + // Auditor, hour=8, weekend/weekday doesn't matter, let's pick weekday + long start = System.nanoTime(); + boolean result = ac.isAccessAllowed(false, false, true, 8, false); + long end = System.nanoTime(); + System.out.println("testBoundaryAuditorBeforeHours duration (ns): " + (end - start)); + assertFalse(result); + } + + @Test + public void testBoundaryAuditorStartHours() { + // Auditor, hour=9, weekend true + long start = System.nanoTime(); + boolean result = ac.isAccessAllowed(false, false, true, 9, true); + long end = System.nanoTime(); + System.out.println("testBoundaryAuditorStartHours duration (ns): " + (end - start)); + assertTrue(result); + } + + @Test + public void testBoundarySpecialAuthAnyTime() { + // Employee with special auth, hour=8, weekend=true + long start = System.nanoTime(); + boolean result = ac.isAccessAllowed(true, true, false, 8, true); + long end = System.nanoTime(); + System.out.println("testBoundarySpecialAuthAnyTime duration (ns): " + (end - start)); + assertTrue(result); + } +} \ No newline at end of file diff --git a/Main.class b/Main.class new file mode 100644 index 0000000000000000000000000000000000000000..846f3b765c599cb639ca83f0223794107547e9a6 GIT binary patch literal 1299 zcmaJ=T~8B16g@*rw_R5Ou_%g)Qn3}Je%6mF2vs9VQDY6p`ZR1uy0G1CcBh*D6aR)j zXrhS^KKi4KXLpITf%veq_s-lo_nvd_{QmR(CxA6PHZUS^tRo$-ydyuz@&+vfX@T+B zb)~mmezCQqY%P#^;CPN+7DyFKn*!;Y-%=)0$XOUgMqsS&c(bg8FdQDiNa{fvMuV`hNC?4jga0TG}))A#ig4(yDE%Fs%8W4t&?d zIC9Z)!a^QXEXE0wfK}J^KdP2Mw%BYo*PEqg4ySP1!1NHwMnBZ5W8n;DNYL+*Z$7EQ z@yjn+f@UE~cB;oI+&K&9F&kI2t5|_8^&3aGX@y#Pn(Xq$X6Yaa6Bki1Fefk>6C8%N za0&AQMmNglQiy!Mx-q;Js|FoPE^@+!Y7@s>-QBqB${l0TZWCU zvK{HJ_H8 zEk!h`^P2DLPzSQRp>*4Cg(mLco`Jgph5b%D-UokIm6L`isy>xAtLR5^-xv5asK;J( z0{BdNEmwtwy6^Ayy48cS4eShEeBJM=L&67@O~$`E*v>tOnsnWUqg8b*gGv?;1tt=) zXL%3}-O8*Gu+}|K1vOWOp$ZK=61a4L^I