Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Issue 7409 (az storage cors list missing "Service" field) #7496

Merged

Conversation

earthquakesan
Copy link
Contributor

@earthquakesan earthquakesan commented Oct 5, 2018

This PR fixes the issue #7409 #7409.

Steps to reproduce the issue:

  1. Set AZURE_STORAGE_ACCOUNT and AZURE_STORAGE_KEY variables (refer to the documentation if necessary: https://docs.microsoft.com/en-us/azure/storage/blobs/storage-quickstart-blobs-cli)

  2. Add 2 or more CORS rules of same type (here are file rules from original issue).

#!/bin/bash

az storage cors clear --services f

az storage cors add \
	--allowed-headers "x-api-key" \
       	--methods GET \
       	--origins http://localhost:5000 \
       	--exposed-headers "x-ms-request-id, x-ms-lease-status" \
       	--max-age 10 \
       	--services f

az storage cors add \
	--allowed-headers "content-type" \
       	--methods GET \
       	--origins http://localhost:5001 \
       	--exposed-headers "x-*" \
       	--max-age 5 \
       	--services f

az storage cors add \
	--allowed-headers "x-api-key, x-app-*" \
       	--methods POST \
       	--origins http://localhost:5000 http://localhost:5001 \
       	--exposed-headers "*" \
       	--max-age 5 \
       	--services f

az storage cors add \
	--allowed-headers "*" \
       	--methods GET \
       	--origins "*" \
       	--exposed-headers "*" \
       	--max-age 30 \
       	--services f
  1. Execute az storage cors list

Example Output

[
  {
    "AllowedHeaders": "x-api-key",
    "AllowedMethods": "GET",
    "AllowedOrigins": "http://localhost:5000",
    "ExposedHeaders": "x-ms-request-id, x-ms-lease-status",
    "MaxAgeInSeconds": 10,
    "Rule": 1,
    "Service": "file"
  },
  {
    "AllowedHeaders": "content-type",
    "AllowedMethods": "GET",
    "AllowedOrigins": "http://localhost:5001",
    "ExposedHeaders": "x-*",
    "MaxAgeInSeconds": 5,
    "Rule": 2,
    "Service": ""
  },
  {
    "AllowedHeaders": "x-api-key, x-app-*",
    "AllowedMethods": "POST",
    "AllowedOrigins": "http://localhost:5000, http://localhost:5001",
    "ExposedHeaders": "*",
    "MaxAgeInSeconds": 5,
    "Rule": 3,
    "Service": ""
  },
  {
    "AllowedHeaders": "*",
    "AllowedMethods": "GET",
    "AllowedOrigins": "*",
    "ExposedHeaders": "*",
    "MaxAgeInSeconds": 30,
    "Rule": 4,
    "Service": ""
  }
]

Expected Output

[
  {
    "AllowedHeaders": "x-api-key",
    "AllowedMethods": "GET",
    "AllowedOrigins": "http://localhost:5000",
    "ExposedHeaders": "x-ms-request-id, x-ms-lease-status",
    "MaxAgeInSeconds": 10,
    "Rule": 1,
    "Service": "file"
  },
  {
    "AllowedHeaders": "content-type",
    "AllowedMethods": "GET",
    "AllowedOrigins": "http://localhost:5001",
    "ExposedHeaders": "x-*",
    "MaxAgeInSeconds": 5,
    "Rule": 2,
    "Service": "file"
  },
  {
    "AllowedHeaders": "x-api-key, x-app-*",
    "AllowedMethods": "POST",
    "AllowedOrigins": "http://localhost:5000, http://localhost:5001",
    "ExposedHeaders": "*",
    "MaxAgeInSeconds": 5,
    "Rule": 3,
    "Service": "file"
  },
  {
    "AllowedHeaders": "*",
    "AllowedMethods": "GET",
    "AllowedOrigins": "*",
    "ExposedHeaders": "*",
    "MaxAgeInSeconds": 30,
    "Rule": 4,
    "Service": "file"
  }
]

Comments

The problem was in the formatter function, which reset "Service" key output for each item except for the first one. I also removed unnecessary service_name variable

Checklists

  • The PR has modified HISTORY.rst describing any customer-facing, functional changes. Note that this does not include changes only to help content. (see Modifying change log).

This PR does not change or add any functionality, bugfix only.

This PR does not change or add any functionality, bugfix only.

@msftclas
Copy link

msftclas commented Oct 5, 2018

CLA assistant check
All CLA requirements met.

@troydai
Copy link
Contributor

troydai commented Oct 5, 2018

Thank you very much @earthquakesan . Looks good to me. @williexu can you come up with additional tests to cover this scenario?

Remove myself from the reviewers as I'm leaving the project.

@troydai troydai removed their request for review October 5, 2018 16:24
Copy link
Contributor

@williexu williexu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, I'll merge this and add some additional testing.

@williexu williexu merged commit f347080 into Azure:dev Oct 5, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants