Skip to content

Commit

Permalink
Adding logo upload tests
Browse files Browse the repository at this point in the history
  • Loading branch information
superchilled committed Jul 11, 2023
1 parent b65527d commit e8c1c24
Showing 1 changed file with 82 additions and 4 deletions.
86 changes: 82 additions & 4 deletions test/vonage/meetings/themes_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ def list_response
}
end

def test_png_file
file = Tempfile.create(['logo', '.png'])
end

def test_list_method
stub_request(:get, themes_uri).to_return(list_response)

Expand Down Expand Up @@ -152,11 +156,85 @@ def test_list_rooms_method_with_optional_params
room_list.each { |room| assert_kind_of Vonage::Entity, room }
end

def test_upload_logo_method
skip
def test_set_logo_method
stub_request(:get, themes_uri + "/logos-upload-urls").to_return(get_logo_upload_credentials_response)
stub_request(:post, "https://storage-url.com").to_return(status: 204)
stub_request(:put, theme_uri + "/finalizeLogos").with(body: {keys: ["auto-expiring-temp/logos/white/ca63a155-d5f0-4131-9903-c59907e53df0"]}).to_return(response)

assert_kind_of Vonage::Response, themes.set_logo(theme_id: meetings_id, filepath: test_png_file.path, logo_type: 'white')
end

def test_set_logo_method_without_theme_id
assert_raises(ArgumentError) { themes.set_logo(filepath: test_png_file.path, logo_type: 'white') }
end

def test_set_logo_method_without_filepath
assert_raises(ArgumentError) { themes.set_logo(theme_id: meetings_id, logo_type: 'white') }
end

def test_set_logo_method_without_logo_type
assert_raises(ArgumentError) { themes.set_logo(theme_id: meetings_id, filepath: test_png_file.path) }
end

def test_upload_logo_method_without_theme_id
skip
def test_set_logo_method_with_invalid_filepath
assert_raises(ArgumentError) { themes.set_logo(theme_id: meetings_id, filepath: '/foo/bar/logo.png', logo_type: 'white') }
end

def test_set_logo_method_with_invalid_logo_type
assert_raises(ArgumentError) { themes.set_logo(theme_id: meetings_id, filepath: test_png_file.path, logo_type: 'foo') }
end

def get_logo_upload_credentials_response
{
body: '[
{
"url": "https://storage-url.com",
"fields": {
"Content-Type": "image/png",
"key": "auto-expiring-temp/logos/white/ca63a155-d5f0-4131-9903-c59907e53df0",
"logoType": "white",
"bucket": "roomservice-whitelabel-logos-prod",
"X-Amz-Algorithm": "AWS4-HMAC-SHA256",
"X-Amz-Credential": "ASSCSSQSAMKJISDGBW/20220410/us-east-1/s3/aws4_request",
"X-Amz-Date": "20220410T200246Z",
"X-Amz-Security-Token": "IQoJb3JpZ2luX2VjEBIaCXVzLWVhc3QtMSJHMEUCIDMxvPG4",
"Policy": "eyJleHBpcmF0aW9uIjoiMjAyMy0wNi0wN1QxMjo0Njo0MFo",
"X-Amz-Signature": "fcb46c1adfa98836f0533aadebedc6fb1edbd90aa583f3264c0ae5bb63d83123"
}
},
{
"url": "https://storage-url.com",
"fields": {
"Content-Type": "image/png",
"key": "auto-expiring-temp/logos/colored/ca63a155-d5f0-4131-9903-c59907e53df0",
"logoType": "colored",
"bucket": "roomservice-whitelabel-logos-prod",
"X-Amz-Algorithm": "AWS4-HMAC-SHA256",
"X-Amz-Credential": "ASSCSSQSAMKJISDGBW/20220410/us-east-1/s3/aws4_request",
"X-Amz-Date": "20220410T200246Z",
"X-Amz-Security-Token": "IQoJb3JpZ2luX2VjEBIaCXVzLWVhc3QtMSJHMEUCIDMxvPG4",
"Policy": "eyJleHBpcmF0aW9uIjoiMjAyMy0wNi0wN1QxMjo0Njo0MFo",
"X-Amz-Signature": "fcb46c1adfa98836f0533aadebedc6fb1edbd90aa583f3264c0ae5bb63d83123"
}
},
{
"url": "https://storage-url.com",
"fields": {
"Content-Type": "image/png",
"key": "auto-expiring-temp/logos/favicon/ca63a155-d5f0-4131-9903-c59907e53df0",
"logoType": "favicon",
"bucket": "roomservice-whitelabel-logos-prod",
"X-Amz-Algorithm": "AWS4-HMAC-SHA256",
"X-Amz-Credential": "ASSCSSQSAMKJISDGBW/20220410/us-east-1/s3/aws4_request",
"X-Amz-Date": "20220410T200246Z",
"X-Amz-Security-Token": "IQoJb3JpZ2luX2VjEBIaCXVzLWVhc3QtMSJHMEUCIDMxvPG4",
"Policy": "eyJleHBpcmF0aW9uIjoiMjAyMy0wNi0wN1QxMjo0Njo0MFo",
"X-Amz-Signature": "fcb46c1adfa98836f0533aadebedc6fb1edbd90aa583f3264c0ae5bb63d83123"
}
}
]',
headers: response_headers,
status: 200
}
end
end

0 comments on commit e8c1c24

Please sign in to comment.