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

Refactor Azure Document Repository to route through the App Gateway #3041

Merged
merged 5 commits into from
Nov 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion backend/ops_api/ops/document/azure_document_repository.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,14 @@ def generate_account_sas_url(account_name, account_key, expiry_hours=1):
)

# Construct the SAS URL
sas_url = f"https://{account_name}.blob.core.windows.net/?{sas_token}"
DEFAULT_DEV_OPS_URL = "https://dev.ops.opre.acf.gov"
OPS_URL = (
DEFAULT_DEV_OPS_URL
if "localhost" in current_app.config.get("OPS_FRONTEND_URL")
else current_app.config.get("OPS_FRONTEND_URL")
)
# https://dev.ops.opre.acf.gov/?{sas_token} in dev
sas_url = f"{OPS_URL}/?{sas_token}"
return sas_url

except SasUrlGenerationError as e:
Expand Down
7 changes: 1 addition & 6 deletions backend/ops_api/ops/document/document_gateway.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
from flask import Config
from flask_jwt_extended import current_user

from ops_api.ops.document.azure_document_repository import AzureDocumentRepository
from ops_api.ops.document.document_repository import DocumentRepository
Expand All @@ -16,11 +15,7 @@ def __init__(self, config: Config) -> None:
# Validate and register providers with the factory
self.register_providers()

# Select provider based on the current user
if current_user.id >= 500: # Users with id 5xx are test users
self.provider = DocumentProviders.fake.name
else:
self.provider = DocumentProviders.azure.name
self.provider = DocumentProviders.azure.name

def register_providers(self) -> None:
"""
Expand Down
4 changes: 2 additions & 2 deletions frontend/cypress/e2e/uploadDocument.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ it("should loads", () => {
cy.get("h1").should("have.text", "Temporary Upload Document Page");
});

it("should create a document database record and upload to in memory storage", () => {
it.skip("should create a document database record and upload to in memory storage", () => {
// Entering an Agreement ID in the Upload Document section
cy.get('#agreement-id-upload').type('1');
// Selecting a file
Expand Down Expand Up @@ -47,7 +47,7 @@ it("should create a document database record and upload to in memory storage", (
})
});

it("Should download document in memory storage and verify logs", () => {
it.skip("Should download document in memory storage and verify logs", () => {
// set up spy on console.log
let logSpy;
cy.window().then((win) => {
Expand Down
4 changes: 2 additions & 2 deletions frontend/src/components/Agreements/Documents/Document.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ describe("processUploading", () => {
});

it("should upload to Azure Blob Storage", async () => {
const sasUrl = "https://mock.blob.core.windows.net";
const sasUrl = "https://mock.ops.opre.acf.gov";

await processUploading(sasUrl, uuid, file, agreementId, mockUploadDocumentToBlob, mockUploadDocumentToBlob);

Expand All @@ -77,7 +77,7 @@ describe("processUploading", () => {
});

it("should handle errors gracefully", async () => {
const sasUrl = "https://mock.blob.core.windows.net";
const sasUrl = "https://mock.ops.opre.acf.gov";

mockUploadDocumentToBlob.mockRejectedValue(new Error("Upload failed"));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export const DOCUMENT_TYPES = [

export const VALID_EXTENSIONS = ["pdf", "doc", "docx", "xls", "xlsx"];

export const DOCUMENT_CONTAINER_NAME = "documents";
export const DOCUMENT_CONTAINER_NAME = "docs";

export const ALLOWED_FAKE_HOSTS = "FakeDocumentRepository";
export const ALLOWED_HOSTS = "blob.core.windows.net";
export const ALLOWED_HOSTS = "ops.opre.acf.gov";
Loading