How to automate BrowserStack screenshot API on my localhost? - testing

I tried to go through their Screenshots API & Local testing but got lost in between..
All I want is to test my front-end style guide (language agnostic), can someone direct me to a good direction please?

Generating screenshots for internal URL via Screenshots API is a two-step process:
a) Setup Local Testing using the BrowserStack Local binary. The command is as follows:
./BrowserStackLocal --key KEY
More details on Local Testing is available here.
b) Add the parameter "local" = true in your Rest API. For more information, refer.
Example for generating a screenshot for localhost on Windows 7-IE 8:
"UserName:KEY" -H "Content-Type: application/json" -H "Accept: application/json" -d '{"browsers": [{"os": "Windows", "os_version": "7", "browser_version": "8.0", "browser": "ie"}], "url": "http://localhost", "local": "true"}' https://www.browserstack.com/screenshots
Note: The access key for your account can be acquired from here.

Related

"INVALID" Service Account key on Google Cloud Platform

I use the GCP Text-to-Speech API to create greetings and interactive menus that are played to phone customers who call into businesses. I have successfully used the Text-to-Speech API in the past using this Google quick-start: Google Cloud Text-to-Speech
I used the same quick-start guide again for a new organization and project but I keep getting an invalid key error which I have been unable to debug.
Here are the commands I have used to invoke the service and the results:
# curl -X POST \
-H "Authorization: Bearer $(gcloud auth application-default print-access-token)”\
-H "Content-Type: application/json; charset=utf-8" \
-d #request.json \
https://texttospeech.googleapis.com/v1/text:synthesize > synthesize-output-base64.txt
{
"error": {
"code": 403,
"message": "The request is missing a valid API key.",
"status": "PERMISSION_DENIED"
}
}
I tried again with a different authentication header:
# curl -X POST \
-H "X-Goog-Api-Key:***my_API_key***.json" \
-H "Content-Type: application/json; charset=utf-8" \
-d #request.json \
https://texttospeech.googleapis.com/v1/text:synthesize > synthesize-output-base64.txt
{
"error": {
"code": 400,
"message": "API key not valid. Please pass a valid API key.",
"status": "INVALID_ARGUMENT",
"details": [
{
"#type": "type.googleapis.com/google.rpc.ErrorInfo",
"reason": "API_KEY_INVALID",
"domain": "googleapis.com",
"metadata": {
"service": "texttospeech.googleapis.com"
}
}
]
}
}
I have re-verified the following configurations:
The Text-to-Speech API is enabled for my project.
The credential (service account) I am attempting to use is listed with the Text-to-Speech API as compatible. I verified that that service account key is the key that was used in the attempted authentications.
I compared my configuration on GCP with another working configuration I manage for a different company. There are no differences I can see.
I compared my key and the other company's working key and they are identical except for the specific user data.
The billing account for the project is active with valid payment card in place.
These two links were helpful but did not clear up the problem:
Google Cloud Text-to-Speech API - permission error
Google Cloud Text to Speech INVALID API KEY
Any help on this issue would be very appreciated!
The solution to this problem is to install the Google Cloud SDK.
The CLI was missing so the returned output from gcloud auth application-default print-access-token was an error.
I enabled the Cloud Text-to-Speech API
I created a service account with Editor role.
Note: Ensure you have set the GOOGLE_APPLICATION_CREDENTIALS environment variable to your service account private key file path.
Save the request body in a file called request.json,
Execute the following command:
curl -X POST \
-H "Authorization: Bearer "$(gcloud auth application-default print-access-token) \
-H "Content-Type: application/json; charset=utf-8" \
-d #request.json \
https://texttospeech.googleapis.com/v1/text:synthesize
Response body
{
"audioContent": "//NExAARcrn0ABhEudAgAjuem7vohckY3IAFgWvxrBkAD//ARvqc/QhCZ/6EJO6E9Dvo2cjHPQhLfWQ/rTU7yEznsoGBn8hJz5xbQiOgEfwDzD1DVARLPlzGNXylbM8s//NExA0SCnoAAUIQAd8vlrM9DPR//6t5fpUpS
sk3MbzGUvMhqOpdSsjmcpeY2Zz ...................
}
Everything worked as expected

How to enable a kv secret engine in vault using HTTP APIs

I am trying to enable kv secret engine at secret path in my vault setup..
I can easily do it using CLI
vault secrets enable -path=secret kv
But I have to make it work using Vault's HTTP APIs.
I have gone through documentation but could not find any endpoint for the above command.
Thanks in advance
This is covered under the System Backend/sys/mounts API reference page.
Issue a POST request to /v1/sys/mounts/<mountpoint> with a payload containing the type (kv) and various configuration options. For KV, you probably want to specify version: 2 (or type kv-v2) unless you want to stick to V1.
See the above link for details on the possible parameters.
Here is the example from the docs:
payload.json:
{
"type": "aws",
"config": {
"force_no_cache": true
}
}
Request:
$ curl \
--header "X-Vault-Token: ..." \
--request POST \
--data #payload.json \
http://127.0.0.1:8200/v1/sys/mounts/my-mount

MongooseIm Rest API connection issue with local Setup

I have setup the mongooseim [3.3.0] ubuntu 14.04 & it works perfect with android client setup. Then I need to test the REST API for creating room , Then I have got this error when running the swagger documentation.
curl -X GET --header 'Accept: application/json' --header 'Authorization: Basic dXNlcjpwYXNzd29yZA==' 'http://localhost:8089/api/rooms'
curl: (52) Empty reply from server
This is the mongooseim configs which related to REST API.
{ 8089 , ejabberd_cowboy, [
{num_acceptors, 10},
{transport_options, [{max_connections, 1024}]},
{protocol_options, [{compress, true}]},
{ssl, [{certfile, "priv/ssl/fake_cert.pem"}, {keyfile, "priv/ssl/fake_key.pem"}, {password, ""}]},
{modules, [
{"_", "/api/sse", lasse_handler, [mongoose_client_api_sse]},
{"_", "/api/messages/[:with]", mongoose_client_api_messages, []},
{"_", "/api/contacts/[:jid]", mongoose_client_api_contacts, []},
{"_", "/api/rooms/[:id]", mongoose_client_api_rooms, []},
{"_", "/api/rooms/[:id]/config", mongoose_client_api_rooms_config, []},
{"_", "/api/rooms/:id/users/[:user]", mongoose_client_api_rooms_users, []},
{"_", "/api/rooms/[:id]/messages", mongoose_client_api_rooms_messages, []}
]}
]}
This is the swagger document I have referred. https://mongooseim.readthedocs.io/en/3.3.0/swagger/index.html
I noticed the following things:
The curl example you provided tries to send the request to MongooseIM over HTTP
Based on the part of the config file you provided I can see that MongooseIM expects HTTPS traffic.
It looks like changing the endpoint in your curl command to https://localhost:8089/api/rooms will help. Of course, if you run the command on the same machine as MongooseIM is running. Otherwise, please change the localhost to a proper name or IP address of the machine.
What's more, in the config file I can see that the REST API is configured with the default, fake and self-signed certificates. I strongly encourage you to change it to real certificates. For the sake of testing, you will need to add the option -k to your curl command in order to skip cert verification.

Is there a sample code for using IBM Bluemix Container API?

I'm trying to create container in bluemix with API as it in http://ccsapi-doc.mybluemix.net In the document it mentions:
When using the API with the new model, the following HTTP headers shall be provided:
X-Auth-Token = Bluemix JWT Token
X-Auth-Project-Id = Space GUID
But I have no idea how to get or generate the Bluemix JWT Token. Can someone help me ?
You can get X-Auth-Token by cf oauth-token command. Then copy and paste rest of the part after bearer. And you also can get X-Auth-Project-Id by cf space --guid <space Name>. Please see below commands;
$ cf login -a api.<region>.bluemix.net -u <space name> -o <org name> -s <space name>
$ cf ic login
$ cf oauth-token
$ cf space <space-name> --guid (space name where the container exists)
Try expanding the Authentication section on that page and the "Get TLS Certificate" to show more info
When you enter the values and click "try it out" you will see additional output generated with token info.
This is an alternative Method:
You can retrieve X-Auth-Token and X-Auth-Project-Id with this command:
cf login
CF_TRACE=true cf ic login
Copy all output in a .txt file and search for X-Auth-Token and X-Auth-Project-Id
here there is a simple example:
curl -X GET --header "Accept: application/json" --header "X-Auth-Token: asdlkfajdfdkaldkjfskl239049283049jsdfjksl29304" --header "X-Auth-Project-Id: sdfadf-0090-43ef-22932-23434234" "https://containers-api.ng.bluemix.net/v3/containers/quota"
Response:
The output of API is like this:
{
"account_type": "TRIAL",
"country_code": "ITA",
"org_quota": {
"floating_ips_max": "2",
"floating_ips_space_default": "2",
"floating_ips_usage": 2,
"ram_max": "2048",
"ram_space_default": "2048",
"ram_usage": 2048,
"subnet_usage": -1,
"subnets_default": "5",
"subnets_max": 0
},
"space_quota": {
"floating_ips_max": 2,
"ram_max": 2048,
"subnets_max": -1
}

Pushbullet: No notifications in official Chrome extension when pushing via API

The official Chrome extension isn't behaving as I'd expect (and is not what how it behaved before). I've uninstalled and reinstalled it from Chrome store before doing this.
Using the randomchars pushbullet python client (https://github.com/randomchars/pushbullet.py):
from pushbullet import PushBullet
$key=...
pb=PushBullet($key)
s,p=pb.push_note("title","body")
The above note should be pushed to all devices. But while it appears on the official android app, it does not appear on the official Chrome extension.
However, the following works and is displayed on the Chrome extension:
c=pb.devices[0] # Chrome client
s,p=c.push_note("title","body")
Tried a variant using curl. This push is displayed on the official Android client, but not the official Chrome extension:
curl -u "${key}:" -X POST --header 'Content-Type: application/json' https://api.pushbullet.com/v2/pushes --data-binary '{"type": "note", "title": "Note Title", "body": "Note Title"}'
But acting on a hunch after comparing the differences in metadata between displayed pushes and non-displayed notifications, I added a "source_device_iden" tag (matching my Android client), and this was displayed on the offical Chrome extension:
curl -u "${key}:" -X POST --header 'Content-Type: application/json' https://api.pushbullet.com/v2/pushes --data-binary '{"type": "note", "title": "Note Title", "body": "Note Title", "source_device_iden": "uSOMETHING"}'
Does the Chrome extension now require either source_device_iden or dest_device_iden to be populated or something?
This was a bug that we fixed yesterday. Thanks for letting us know!