Make Azure account name and bucket name configurable
This commit is contained in:
parent
94b6b320fb
commit
6405d9b958
@ -29,6 +29,10 @@ class MockUploader(Uploader):
|
|||||||
self.config = config
|
self.config = config
|
||||||
|
|
||||||
def get_token(self):
|
def get_token(self):
|
||||||
|
"""
|
||||||
|
Generates a pre-authenticated token and object name which we'll use to
|
||||||
|
upload the file to the CSP.
|
||||||
|
"""
|
||||||
return ({}, self.object_name())
|
return ({}, self.object_name())
|
||||||
|
|
||||||
|
|
||||||
@ -38,12 +42,13 @@ class AzureUploader(Uploader):
|
|||||||
|
|
||||||
def get_token(self):
|
def get_token(self):
|
||||||
account = CloudStorageAccount(
|
account = CloudStorageAccount(
|
||||||
account_name="atat", account_key=self.config["AZURE_STORAGE_KEY"]
|
account_name=self.config["AZURE_ACCOUNT_NAME"],
|
||||||
|
account_key=self.config["AZURE_STORAGE_KEY"],
|
||||||
)
|
)
|
||||||
bbs = account.create_block_blob_service()
|
bbs = account.create_block_blob_service()
|
||||||
object_name = self.object_name()
|
object_name = self.object_name()
|
||||||
sas_token = bbs.generate_container_shared_access_signature(
|
sas_token = bbs.generate_container_shared_access_signature(
|
||||||
"task-order-pdfs",
|
self.config["AZURE_TO_BUCKET_NAME"],
|
||||||
ContainerPermissions.WRITE,
|
ContainerPermissions.WRITE,
|
||||||
datetime.utcnow() + timedelta(minutes=15),
|
datetime.utcnow() + timedelta(minutes=15),
|
||||||
)
|
)
|
||||||
|
@ -11,7 +11,7 @@ const WrapperComponent = makeTestWrapper({
|
|||||||
templatePath: 'checkbox_input_template.html',
|
templatePath: 'checkbox_input_template.html',
|
||||||
data: function() {
|
data: function() {
|
||||||
return { initialvalue: this.initialData }
|
return { initialvalue: this.initialData }
|
||||||
}
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('CheckboxInput Renders Correctly', () => {
|
describe('CheckboxInput Renders Correctly', () => {
|
||||||
|
@ -9,7 +9,7 @@ const UploadWrapper = makeTestWrapper({
|
|||||||
templatePath: 'upload_input_template.html',
|
templatePath: 'upload_input_template.html',
|
||||||
data: function() {
|
data: function() {
|
||||||
return { initialvalue: this.initialData.initialvalue, token: this.token }
|
return { initialvalue: this.initialData.initialvalue, token: this.token }
|
||||||
}
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
const UploadErrorWrapper = makeTestWrapper({
|
const UploadErrorWrapper = makeTestWrapper({
|
||||||
@ -17,14 +17,14 @@ const UploadErrorWrapper = makeTestWrapper({
|
|||||||
templatePath: 'upload_input_error_template.html',
|
templatePath: 'upload_input_error_template.html',
|
||||||
data: function() {
|
data: function() {
|
||||||
return { initialvalue: null, token: null }
|
return { initialvalue: null, token: null }
|
||||||
}
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('UploadInput Test', () => {
|
describe('UploadInput Test', () => {
|
||||||
it('should show input and button when no attachment present', () => {
|
it('should show input and button when no attachment present', () => {
|
||||||
const wrapper = mount(UploadWrapper, {
|
const wrapper = mount(UploadWrapper, {
|
||||||
propsData: {
|
propsData: {
|
||||||
initialData: { initialvalue: null, token: "token" },
|
initialData: { initialvalue: null, token: 'token' },
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
@ -35,7 +35,7 @@ describe('UploadInput Test', () => {
|
|||||||
it('should show file name and hide input', () => {
|
it('should show file name and hide input', () => {
|
||||||
const wrapper = mount(UploadWrapper, {
|
const wrapper = mount(UploadWrapper, {
|
||||||
propsData: {
|
propsData: {
|
||||||
initialData: { initialvalue: "somepdf.pdf", token: "token" }
|
initialData: { initialvalue: 'somepdf.pdf', token: 'token' },
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
@ -49,8 +49,8 @@ describe('UploadInput Test', () => {
|
|||||||
it('should correctly display error treatment', () => {
|
it('should correctly display error treatment', () => {
|
||||||
const wrapper = mount(UploadErrorWrapper, {
|
const wrapper = mount(UploadErrorWrapper, {
|
||||||
propsData: {
|
propsData: {
|
||||||
initialData: { initialvalue: "somepdf.pdf", token: "token" }
|
initialData: { initialvalue: 'somepdf.pdf', token: 'token' },
|
||||||
}
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
const messageArea = wrapper.find('.usa-input__message')
|
const messageArea = wrapper.find('.usa-input__message')
|
||||||
|
@ -74,11 +74,15 @@ def test_make_checkbox_input_template(checkbox_input_macro, initial_value_form):
|
|||||||
|
|
||||||
|
|
||||||
def test_make_upload_input_template(upload_input_macro, task_order_form):
|
def test_make_upload_input_template(upload_input_macro, task_order_form):
|
||||||
rendered_upload_macro = upload_input_macro(task_order_form.pdf, token="token", object_name="object_name")
|
rendered_upload_macro = upload_input_macro(
|
||||||
|
task_order_form.pdf, token="token", object_name="object_name"
|
||||||
|
)
|
||||||
write_template(rendered_upload_macro, "upload_input_template.html")
|
write_template(rendered_upload_macro, "upload_input_template.html")
|
||||||
|
|
||||||
|
|
||||||
def test_make_upload_input_error_template(upload_input_macro, task_order_form):
|
def test_make_upload_input_error_template(upload_input_macro, task_order_form):
|
||||||
task_order_form.validate()
|
task_order_form.validate()
|
||||||
rendered_upload_macro = upload_input_macro(task_order_form.pdf, token="token", object_name="object_name")
|
rendered_upload_macro = upload_input_macro(
|
||||||
|
task_order_form.pdf, token="token", object_name="object_name"
|
||||||
|
)
|
||||||
write_template(rendered_upload_macro, "upload_input_error_template.html")
|
write_template(rendered_upload_macro, "upload_input_error_template.html")
|
||||||
|
Loading…
x
Reference in New Issue
Block a user