#!/usr/bin/env node
const https = require('https');
console.log('=== Testing why AWS works but MasterBilling doesn\'t ===\n');
// Configuration from the working curl tests
const authToken = 'eyJraWQiOiJoUFBoZTFRaWM4TklLU1dHcjQ4NEFHK3UwU2c5bCtmUHFWRWZUeCtcL0FcL1k9IiwiYWxnIjoiUlMyNTYifQ.eyJzdWIiOiI4YmQzOWFlNC1lYmVhLTQ0MjYtYmQyMi0wNzM0OWRkOGI5NjIiLCJhdWQiOiI3aTgyY25wdDQ2OXJjZDkzZmlmMWdsaG5rbSIsImVtYWlsX3ZlcmlmaWVkIjp0cnVlLCJldmVudF9pZCI6ImVmMjMyZTlhLWZmNTctNGJjYS04Y2RiLTkyNWMwN2JiNDA2MyIsInRva2VuX3VzZSI6ImlkIiwiYXV0aF90aW1lIjoxNzU5MDczNDAzLCJpc3MiOiJodHRwczpcL1wvY29nbml0by1pZHAudXMtZWFzdC0xLmFtYXpvbmF3cy5jb21cL3VzLWVhc3QtMV9VdjZBck5kU0siLCJjb2duaXRvOnVzZXJuYW1lIjoiOGJkMzlhZTQtZWJlYS00NDI2LWJkMjItMDczNDlkZDhiOTYyIiwiZXhwIjoxNzU5MTU5ODAzLCJpYXQiOjE3NTkwNzM0MDMsImVtYWlsIjoiZGF2aWQrc2FvbGFAdW1icmVsbGFjb3N0LmNvbSJ9.P1Uuu8ot0-5qNvrinz_bw6kPi0PvTyfW6mNop0Ew7NAPWC40JqkqUDCtrf6bCCxkllwIKNbipn_gIDVuKnr5k8HjlLYcG-9tMP9YdE04MZ1X0A5hIFkSOYViE49nSXAkMsHe_Cx-gjaco4RGrKp384T-ZFWpNEsPWDpTuqVe7xwsbzWcNliS0jZdQQhdy1RN0Joh3KoMz7gO7efX4-L31z6WZs96JWNyslPDjE99CNSQlQqtNkQ0qmMxZhAWyYTn0fd7UmenWGg06K5_SJp0-w2rNk5NIB89Z_-11xX6FO51SN3YtSzbAz0ks6FcaYnSDgFWWco6uWz0XWTgSc3Cgw';
async function makeRequest(name, apiKey, params = {}) {
return new Promise((resolve) => {
// Build URL with params
const queryString = Object.entries(params)
.map(([key, value]) => {
if (Array.isArray(value)) {
return value.map(v => `${key}=${encodeURIComponent(v)}`).join('&');
}
return `${key}=${encodeURIComponent(value)}`;
})
.join('&');
const url = `https://api.umbrellacost.io/api/v1/invoices/caui?${queryString}`;
console.log(`Testing: ${name}`);
console.log(`API Key: ${apiKey}`);
console.log(`URL: ${url}`);
const startTime = Date.now();
https.get(url, {
headers: {
'Authorization': authToken,
'apikey': apiKey,
'Accept': 'application/json'
}
}, (res) => {
let data = '';
res.on('data', chunk => data += chunk);
res.on('end', () => {
const responseTime = Date.now() - startTime;
try {
const json = JSON.parse(data);
const recordCount = Array.isArray(json) ? json.length : 0;
const hasData = recordCount > 0;
console.log(`Status: ${res.statusCode}`);
console.log(`Response Time: ${responseTime}ms`);
console.log(`Has Data: ${hasData ? '✅ YES' : '❌ NO'}`);
console.log(`Records: ${recordCount}`);
if (hasData) {
console.log(`First record:`, json[0]);
}
console.log('---\n');
resolve({ name, hasData, recordCount, status: res.statusCode });
} catch (e) {
console.log(`Error parsing: ${e.message}`);
console.log(`Raw response: ${data.substring(0, 200)}`);
console.log('---\n');
resolve({ name, hasData: false, error: e.message });
}
});
}).on('error', (e) => {
console.log(`Request error: ${e.message}`);
console.log('---\n');
resolve({ name, hasData: false, error: e.message });
});
});
}
async function runTests() {
const results = [];
// Test 1: AWS account with standard params
results.push(await makeRequest(
'AWS Account (932213950603)',
'8bd39ae4-ebea-4426-bd22-07349dd8b962:9350:0',
{
startDate: '2025-01-01',
endDate: '2025-09-30',
groupBy: 'none',
periodGranLevel: 'month',
costType: 'cost',
isUnblended: 'true',
'excludeFilters[chargetype][]': 'Tax'
}
));
// Test 2: MasterBilling with same params
results.push(await makeRequest(
'MasterBilling WITH isUnblended & excludeFilters',
'8bd39ae4-ebea-4426-bd22-07349dd8b962:21112:0',
{
startDate: '2025-01-01',
endDate: '2025-09-30',
groupBy: 'none',
periodGranLevel: 'month',
costType: 'cost',
isUnblended: 'true',
'excludeFilters[chargetype][]': 'Tax'
}
));
// Test 3: MasterBilling WITHOUT isUnblended & excludeFilters
results.push(await makeRequest(
'MasterBilling WITHOUT isUnblended & excludeFilters',
'8bd39ae4-ebea-4426-bd22-07349dd8b962:21112:0',
{
startDate: '2025-01-01',
endDate: '2025-09-30',
groupBy: 'none',
periodGranLevel: 'month',
costType: 'cost'
}
));
// Test 4: AWS WITHOUT isUnblended & excludeFilters (to see if it still works)
results.push(await makeRequest(
'AWS WITHOUT isUnblended & excludeFilters',
'8bd39ae4-ebea-4426-bd22-07349dd8b962:9350:0',
{
startDate: '2025-01-01',
endDate: '2025-09-30',
groupBy: 'none',
periodGranLevel: 'month',
costType: 'cost'
}
));
console.log('\n=== SUMMARY ===');
console.log('Test Results:');
results.forEach(r => {
console.log(`${r.hasData ? '✅' : '❌'} ${r.name}: ${r.hasData ? `${r.recordCount} records` : 'No data'}`);
});
console.log('\n=== ANALYSIS ===');
const awsWithParams = results.find(r => r.name.includes('AWS') && r.name.includes('WITH isUnblended'));
const awsWithoutParams = results.find(r => r.name.includes('AWS') && r.name.includes('WITHOUT isUnblended'));
const masterWithParams = results.find(r => r.name.includes('MasterBilling') && r.name.includes('WITH isUnblended'));
const masterWithoutParams = results.find(r => r.name.includes('MasterBilling') && r.name.includes('WITHOUT isUnblended'));
if (awsWithParams?.hasData && awsWithoutParams?.hasData) {
console.log('✅ AWS works with AND without isUnblended/excludeFilters');
}
if (masterWithParams?.hasData && !masterWithoutParams?.hasData) {
console.log('🤔 MasterBilling only works WITH isUnblended/excludeFilters');
} else if (!masterWithParams?.hasData && masterWithoutParams?.hasData) {
console.log('🤔 MasterBilling only works WITHOUT isUnblended/excludeFilters');
} else if (!masterWithParams?.hasData && !masterWithoutParams?.hasData) {
console.log('❌ MasterBilling doesn\'t work at all via direct API calls');
} else if (masterWithParams?.hasData && masterWithoutParams?.hasData) {
console.log('✅ MasterBilling works with AND without isUnblended/excludeFilters');
}
console.log('\nThis test shows the actual API behavior, independent of our MCP server implementation.');
}
runTests();