Azure / Azurite

A lightweight server clone of Azure Storage that simulates most of the commands supported by it with minimal dependencies
MIT License
1.82k stars 322 forks source link

Service_SetProperties: Should report error when try to set more than 5 cors rules #345

Open blueww opened 4 years ago

blueww commented 4 years ago

Which service(blob, file, queue, table) does this issue concern?

blob

Which version of the Azurite was used?

3.3.0-preview

Where do you get Azurite? (npm, DockerHub, NuGet, Visual Studio Code Extension)

VS code

What's the Node.js version?

v10.15.3

What problem was encountered?

Service_SetProperties: Azurite don't report error when try to set more than 5 cors rules, this is not aligned with server. HttpStatusCode: BadRequest Error Code: InvalidXmlDocument

Steps to reproduce the issue?

try to set more than 5 cors rules, and Azurite will success

Have you found a mitigation/solution?

No

Test Case:

Test Name:  CloudQueueTestValidCorsRules
Test FullName:  Microsoft.Azure.Storage.Queue.QueueAnalyticsUnitTests.CloudQueueTestValidCorsRules
Test Source:    C:\code\azure-storage-net\Test\ClassLibraryCommon\Queue\QueueAnalyticsUnitTests.cs : line 479
Test Outcome:   Failed
Test Duration:  0:00:00.2870787

Result StackTrace:  
at Microsoft.Azure.Storage.TestHelper.ExpectedException(Action operation, String operationDescription, HttpStatusCode expectedStatusCode, String requestErrorCode) in C:\code\azure-storage-net\Test\ClassLibraryCommon\TestHelper.cs:line 55
   at Microsoft.Azure.Storage.Queue.QueueAnalyticsUnitTests.CloudQueueTestValidCorsRules() in C:\code\azure-storage-net\Test\ClassLibraryCommon\Queue\QueueAnalyticsUnitTests.cs:line 599
Result Message: Assert.Fail failed. No Storage exception received while expecting BadRequest: Services are limited to a maximum of five CORS rules.

Debug Log:

2019-12-20T02:11:17.990Z fb8fc6c7-2037-4984-bd04-ebbc4e9cf638 info: QueueStorageContextMiddleware: RequestMethod=PUT RequestURL=http://127.0.0.1/devstoreaccount1?restype=service&comp=properties RequestHeaders:{"x-ms-client-request-id":"7d72fd2e-1e12-45a4-b14f-70dc28de0251","user-agent":"Azure-Storage/11.1.1 (.NET Core; Win32NT 6.2.9200.0)","x-ms-version":"2019-02-02","x-ms-date":"Fri, 20 Dec 2019 02:11:17 GMT","authorization":"SharedKey devstoreaccount1:/zCoJS9j4EJTcLwqBC8YnhXonpeqRh3ECu+A7bZF5xA=","content-length":"1763","host":"127.0.0.1:10001"} ClientIP=127.0.0.1 Protocol=http HTTPVersion=1.1
2019-12-20T02:11:17.991Z fb8fc6c7-2037-4984-bd04-ebbc4e9cf638 info: QueueStorageContextMiddleware: Account=devstoreaccount1 Queue=undefined Message=undefined MessageId=undefined
2019-12-20T02:11:17.991Z fb8fc6c7-2037-4984-bd04-ebbc4e9cf638 verbose: DispatchMiddleware: Dispatching request...
2019-12-20T02:11:17.991Z fb8fc6c7-2037-4984-bd04-ebbc4e9cf638 info: DispatchMiddleware: Operation=Service_SetProperties
2019-12-20T02:11:17.991Z fb8fc6c7-2037-4984-bd04-ebbc4e9cf638 verbose: AuthenticationMiddlewareFactory:createAuthenticationMiddleware() Validating authentications.
2019-12-20T02:11:17.992Z fb8fc6c7-2037-4984-bd04-ebbc4e9cf638 info: QueueSharedKeyAuthenticator:validate() Start validation against account shared key authentication.
2019-12-20T02:11:17.992Z fb8fc6c7-2037-4984-bd04-ebbc4e9cf638 info: QueueSharedKeyAuthenticator:validate() [STRING TO SIGN]:"PUT\n\n\n1763\n\n\n\n\n\n\n\n\nx-ms-client-request-id:7d72fd2e-1e12-45a4-b14f-70dc28de0251\nx-ms-date:Fri, 20 Dec 2019 02:11:17 GMT\nx-ms-version:2019-02-02\n/devstoreaccount1/devstoreaccount1\ncomp:properties\nrestype:service"
2019-12-20T02:11:17.992Z fb8fc6c7-2037-4984-bd04-ebbc4e9cf638 info: QueueSharedKeyAuthenticator:validate() Calculated authentication header based on key1: devstoreaccount1:/zCoJS9j4EJTcLwqBC8YnhXonpeqRh3ECu+A7bZF5xA=
2019-12-20T02:11:17.992Z fb8fc6c7-2037-4984-bd04-ebbc4e9cf638 info: QueueSharedKeyAuthenticator:validate() Signature 1 matched.
2019-12-20T02:11:17.993Z fb8fc6c7-2037-4984-bd04-ebbc4e9cf638 verbose: DeserializerMiddleware: Start deserializing...
2019-12-20T02:11:17.993Z fb8fc6c7-2037-4984-bd04-ebbc4e9cf638 debug: deserialize(): Raw request body string is <?xml version="1.0" encoding="utf-8"?><StorageServiceProperties><Logging><Version>1.0</Version><Delete>false</Delete><Read>false</Read><Write>false</Write><RetentionPolicy><Enabled>false</Enabled></RetentionPolicy></Logging><HourMetrics><Version>1.0</Version><Enabled>false</Enabled><RetentionPolicy><Enabled>false</Enabled></RetentionPolicy></HourMetrics><MinuteMetrics><Version>1.0</Version><Enabled>false</Enabled><RetentionPolicy><Enabled>false</Enabled></RetentionPolicy></MinuteMetrics><Cors><CorsRule><AllowedOrigins>www.ab.com,www.bc.com</AllowedOrigins><AllowedMethods>GET,PUT</AllowedMethods><ExposedHeaders>x-ms-meta-data*,x-ms-meta-source*,x-ms-meta-abc,x-ms-meta-bcd</ExposedHeaders><AllowedHeaders>x-ms-meta-data*,x-ms-meta-target*,x-ms-meta-xyz,x-ms-meta-foo</AllowedHeaders><MaxAgeInSeconds>500</MaxAgeInSeconds></CorsRule><CorsRule><AllowedOrigins>www.xyz.com</AllowedOrigins><AllowedMethods>GET</AllowedMethods><ExposedHeaders></ExposedHeaders><AllowedHeaders></AllowedHeaders><MaxAgeInSeconds>0</MaxAgeInSeconds></CorsRule><CorsRule><AllowedOrigins>www.xyz.com</AllowedOrigins><AllowedMethods>GET,HEAD,POST,PUT,DELETE,TRACE,OPTIONS,CONNECT,MERGE</AllowedMethods><ExposedHeaders></ExposedHeaders><AllowedHeaders></AllowedHeaders><MaxAgeInSeconds>0</MaxAgeInSeconds></CorsRule><CorsRule><AllowedOrigins>www.ab.com</AllowedOrigins><AllowedMethods>GET</AllowedMethods><ExposedHeaders>x-ms-meta-bcd</ExposedHeaders><AllowedHeaders></AllowedHeaders><MaxAgeInSeconds>0</MaxAgeInSeconds></CorsRule><CorsRule><AllowedOrigins>www.ab.com</AllowedOrigins><AllowedMethods>GET</AllowedMethods><ExposedHeaders>x-ms-meta-data*</ExposedHeaders><AllowedHeaders></AllowedHeaders><MaxAgeInSeconds>0</MaxAgeInSeconds></CorsRule></Cors></StorageServiceProperties>
2019-12-20T02:11:17.994Z fb8fc6c7-2037-4984-bd04-ebbc4e9cf638 info: HandlerMiddleware: DeserializedParameters={"options":{"requestId":"7d72fd2e-1e12-45a4-b14f-70dc28de0251"},"restype":"service","comp":"properties","version":"2019-02-02","storageServiceProperties":{"logging":{"version":"1.0","deleteProperty":false,"read":false,"write":false,"retentionPolicy":{"enabled":false}},"hourMetrics":{"version":"1.0","enabled":false,"retentionPolicy":{"enabled":false}},"minuteMetrics":{"version":"1.0","enabled":false,"retentionPolicy":{"enabled":false}},"cors":[{"allowedOrigins":"www.ab.com,www.bc.com","allowedMethods":"GET,PUT","allowedHeaders":"x-ms-meta-data*,x-ms-meta-target*,x-ms-meta-xyz,x-ms-meta-foo","exposedHeaders":"x-ms-meta-data*,x-ms-meta-source*,x-ms-meta-abc,x-ms-meta-bcd","maxAgeInSeconds":500},{"allowedOrigins":"www.xyz.com","allowedMethods":"GET","maxAgeInSeconds":0},{"allowedOrigins":"www.xyz.com","allowedMethods":"GET,HEAD,POST,PUT,DELETE,TRACE,OPTIONS,CONNECT,MERGE","maxAgeInSeconds":0},{"allowedOrigins":"www.ab.com","allowedMethods":"GET","exposedHeaders":"x-ms-meta-bcd","maxAgeInSeconds":0},{"allowedOrigins":"www.ab.com","allowedMethods":"GET","exposedHeaders":"x-ms-meta-data*","maxAgeInSeconds":0}]},"body":"ReadableStream"}
2019-12-20T02:11:17.995Z fb8fc6c7-2037-4984-bd04-ebbc4e9cf638 verbose: SerializerMiddleware: Start serializing...
2019-12-20T02:11:17.995Z fb8fc6c7-2037-4984-bd04-ebbc4e9cf638 info: EndMiddleware: End response. TotalTimeInMS=5 StatusCode=202 StatusMessage=undefined Headers={"server":"Azurite-Queue/3.3.0-preview","x-ms-client-request-id":"7d72fd2e-1e12-45a4-b14f-70dc28de0251","x-ms-request-id":"fb8fc6c7-2037-4984-bd04-ebbc4e9cf638","x-ms-version":"2019-02-02"}
blueww commented 4 years ago

@XiaoningLiu Please help to fix this with Cors issues together. As we discussed before, this negative case doesn't meet the GA bar, don't don't add ga label.

stale[bot] commented 2 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.