@@ -443,6 +443,125 @@ func TestDescribeAccessPoint(t *testing.T) {
443
443
}
444
444
}
445
445
446
+ func TestListAccessPoints (t * testing.T ) {
447
+ var (
448
+ fsId = "fs-abcd1234"
449
+ accessPointId = "ap-abc123"
450
+ Gid int64 = 1000
451
+ Uid int64 = 1000
452
+ )
453
+ testCases := []struct {
454
+ name string
455
+ testFunc func (t * testing.T )
456
+ }{
457
+ {
458
+ name : "Success" ,
459
+ testFunc : func (t * testing.T ) {
460
+ mockctl := gomock .NewController (t )
461
+ mockEfs := mocks .NewMockEfs (mockctl )
462
+ c := & cloud {efs : mockEfs }
463
+
464
+ output := & efs.DescribeAccessPointsOutput {
465
+ AccessPoints : []* efs.AccessPointDescription {
466
+ {
467
+ AccessPointId : aws .String (accessPointId ),
468
+ FileSystemId : aws .String (fsId ),
469
+ PosixUser : & efs.PosixUser {
470
+ Gid : aws .Int64 (Gid ),
471
+ Uid : aws .Int64 (Uid ),
472
+ },
473
+ },
474
+ },
475
+ NextToken : nil ,
476
+ }
477
+
478
+ ctx := context .Background ()
479
+ mockEfs .EXPECT ().DescribeAccessPointsWithContext (gomock .Eq (ctx ), gomock .Any ()).Return (output , nil )
480
+ res , err := c .ListAccessPoints (ctx , fsId )
481
+ if err != nil {
482
+ t .Fatalf ("List Access Points failed: %v" , err )
483
+ }
484
+
485
+ if res == nil {
486
+ t .Fatal ("Result is nil" )
487
+ }
488
+
489
+ if len (res ) != 1 {
490
+ t .Fatalf ("Expected only one AccessPoint in response but got: %v" , res )
491
+ }
492
+
493
+ mockctl .Finish ()
494
+ },
495
+ },
496
+ {
497
+ name : "Success - multiple access points" ,
498
+ testFunc : func (t * testing.T ) {
499
+ mockctl := gomock .NewController (t )
500
+ mockEfs := mocks .NewMockEfs (mockctl )
501
+ c := & cloud {efs : mockEfs }
502
+
503
+ output := & efs.DescribeAccessPointsOutput {
504
+ AccessPoints : []* efs.AccessPointDescription {
505
+ {
506
+ AccessPointId : aws .String (accessPointId ),
507
+ FileSystemId : aws .String (fsId ),
508
+ PosixUser : & efs.PosixUser {
509
+ Gid : aws .Int64 (Gid ),
510
+ Uid : aws .Int64 (Uid ),
511
+ },
512
+ },
513
+ {
514
+ AccessPointId : aws .String (accessPointId ),
515
+ FileSystemId : aws .String (fsId ),
516
+ PosixUser : & efs.PosixUser {
517
+ Gid : aws .Int64 (1001 ),
518
+ Uid : aws .Int64 (1001 ),
519
+ },
520
+ },
521
+ },
522
+ NextToken : nil ,
523
+ }
524
+
525
+ ctx := context .Background ()
526
+ mockEfs .EXPECT ().DescribeAccessPointsWithContext (gomock .Eq (ctx ), gomock .Any ()).Return (output , nil )
527
+ res , err := c .ListAccessPoints (ctx , fsId )
528
+ if err != nil {
529
+ t .Fatalf ("List Access Points failed: %v" , err )
530
+ }
531
+
532
+ if res == nil {
533
+ t .Fatal ("Result is nil" )
534
+ }
535
+
536
+ if len (res ) != 2 {
537
+ t .Fatalf ("Expected two AccessPoints in response but got: %v" , res )
538
+ }
539
+
540
+ mockctl .Finish ()
541
+ },
542
+ },
543
+ {
544
+ name : "Fail - Access Denied" ,
545
+ testFunc : func (t * testing.T ) {
546
+ mockctl := gomock .NewController (t )
547
+ mockEfs := mocks .NewMockEfs (mockctl )
548
+ c := & cloud {efs : mockEfs }
549
+ ctx := context .Background ()
550
+ mockEfs .EXPECT ().DescribeAccessPointsWithContext (gomock .Eq (ctx ), gomock .Any ()).Return (nil , awserr .New (AccessDeniedException , "Access Denied" , errors .New ("Access Denied" )))
551
+ _ , err := c .ListAccessPoints (ctx , fsId )
552
+ if err == nil {
553
+ t .Fatalf ("List Access Points should have failed: %v" , err )
554
+ }
555
+
556
+ mockctl .Finish ()
557
+ },
558
+ },
559
+ }
560
+ for _ , tc := range testCases {
561
+ t .Run (tc .name , tc .testFunc )
562
+ }
563
+ }
564
+
446
565
func TestDescribeFileSystem (t * testing.T ) {
447
566
var (
448
567
fsId = "fs-abcd1234"
0 commit comments