This commit is contained in:
		
							parent
							
								
									0bad68f9f0
								
							
						
					
					
						commit
						0e6922a4a4
					
				| @ -215,11 +215,19 @@ class CloudTrailBackend(BaseBackend): | |||||||
|     def get_trail_status(self, name): |     def get_trail_status(self, name): | ||||||
|         if len(name) < 3: |         if len(name) < 3: | ||||||
|             raise TrailNameTooShort(actual_length=len(name)) |             raise TrailNameTooShort(actual_length=len(name)) | ||||||
|         if name not in self.trails: |         trail_name = next( | ||||||
|  |             ( | ||||||
|  |                 trail.trail_name | ||||||
|  |                 for trail in self.trails.values() | ||||||
|  |                 if trail.trail_name == name or trail.arn == name | ||||||
|  |             ), | ||||||
|  |             None, | ||||||
|  |         ) | ||||||
|  |         if not trail_name: | ||||||
|             # This particular method returns the ARN as part of the error message |             # This particular method returns the ARN as part of the error message | ||||||
|             arn = f"arn:aws:cloudtrail:{self.region_name}:{ACCOUNT_ID}:trail/{name}" |             arn = f"arn:aws:cloudtrail:{self.region_name}:{ACCOUNT_ID}:trail/{name}" | ||||||
|             raise TrailNotFoundException(name=arn) |             raise TrailNotFoundException(name=arn) | ||||||
|         trail = self.trails[name] |         trail = self.trails[trail_name] | ||||||
|         return trail.status |         return trail.status | ||||||
| 
 | 
 | ||||||
|     def describe_trails(self, include_shadow_trails): |     def describe_trails(self, include_shadow_trails): | ||||||
|  | |||||||
| @ -251,6 +251,22 @@ def test_get_trail_status_inactive(): | |||||||
|     status.shouldnt.have.key("StartLoggingTime") |     status.shouldnt.have.key("StartLoggingTime") | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
|  | @mock_cloudtrail | ||||||
|  | @mock_s3 | ||||||
|  | def test_get_trail_status_arn_inactive(): | ||||||
|  |     client = boto3.client("cloudtrail", region_name="us-east-1") | ||||||
|  |     _, resp, _ = create_trail_simple() | ||||||
|  |     status = client.get_trail_status(Name=resp["TrailARN"]) | ||||||
|  |     status.should.have.key("IsLogging").equal(False) | ||||||
|  |     status.should.have.key("LatestDeliveryAttemptTime").equal("") | ||||||
|  |     status.should.have.key("LatestNotificationAttemptTime").equal("") | ||||||
|  |     status.should.have.key("LatestNotificationAttemptSucceeded").equal("") | ||||||
|  |     status.should.have.key("LatestDeliveryAttemptSucceeded").equal("") | ||||||
|  |     status.should.have.key("TimeLoggingStarted").equal("") | ||||||
|  |     status.should.have.key("TimeLoggingStopped").equal("") | ||||||
|  |     status.shouldnt.have.key("StartLoggingTime") | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
| @mock_cloudtrail | @mock_cloudtrail | ||||||
| @mock_s3 | @mock_s3 | ||||||
| def test_get_trail_status_after_starting(): | def test_get_trail_status_after_starting(): | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user