Problem Authenticating requests with NEWMAN while building on TRAVIS CI - postman

I have made a POSTMAN COLLECTION that tests GOOGLE BOOKS API responses to POST requests.
I run this collection with NEWMAN and 2 environment variables : apiKey and dynamicToken.
I then push the project on github using TRAVIS CI to run the tests.
I am encountering remote authentification issues.
While locally (postman or newman cli) authentification works fine : responses status code 200
Once deployed and ran with TRAVIS authentification fails : responses status code 401
I have tried several ways to set the variables that handles authentification.
And finally to isolate the issue I ran the command with hard scripted apyKey and Token.
Here is the command that works locally but not on TRAVIS:
newman run gbook_test.postman_collection.json --env-var "apiKey=<apikeyValue>" --env-var "dynamicToken=<tokenValue>" -d gbook_test.postman_datas.json
Where
<apikeyValue>: is the valid value of my apikey,
<tokenValue>: is the valid value of my token.
What am I missing ?
Thanks.

Related

Postman test collection running well, all tests passed in Postman but all tests fails using Newman i comman line

My postman tests runs well and passes when i run the collection in postman. I've exported and saved my Postman collection.json into a folder, but when running the json file using Newman, all tests fails. some of the errors are:-
getaddrinfo ENOTFOUND {{baseurl}} at request
expected { Object (id, _details, ...) } to have property 'code' at assertion:0 in test-script
Unexpected token u in JSON at position 0 at test-script
Export your environment file as json. Pass it in the newman command line as "-e" parameter.
$ newman run yourcollectionfile.json -e yourenvironmentfile.json
When running postman, you also have to specify the environment file you are using. Documentation for this is found here: https://learning.postman.com/docs/running-collections/using-newman-cli/command-line-integration-with-newman/
you have to use a local variable in your exported collection . i was facing the simliar issue made all variables as local and my test passed.

How to run the graph-node in the rinkeby test rpc

I am trying to write a subgraph for the contract which is deployed in the rinkeby test network.
for that I need to run the graph-node in the same rinkeby test network.
With the reference of the below repo
https://github.com/graphprotocol/graph-node
I am running it in my local machine using the below cargo command
cargo run -p graph-node --release -- --postgres-url postgresql://postgres:postgres#localhost:5432/graph-node --ethereum-rpc 'rinkeby:https://rinkeby.infura.io/v3/2a46ac7cdb4c44acac4de87dadfd6e39' --ipfs 127.0.0.1:5001
I used infura.io for getting the rinkeby rpc url.
but its throws an error 401 Unauthorized. I don't know where i am making the mistake.
I m unable to connect the rinkeby network.
Kindly please help me to resolve the issue.
Thanks in advance.
It looks like your Infura endpoint is not set up correctly, check your project ID and the permissions you have set up in your account, some examples can be found here or via your Infura login: https://infura.io/docs/gettingStarted/chooseaNetwork
I did a blunder mistake in the command.
removing the single quote in the rpc url resolves the issue
cargo run -p graph-node --release -- --postgres-url postgresql://postgres:postgres#localhost:5432/graph-node --ethereum-rpc rinkeby:https://rinkeby.infura.io/v3/2a46ac7cdb4c44acac4de87dadfd6e39 --ipfs 127.0.0.1:5001

How do i continue working with Amplify on a new machine?

I'm using react native for my project. On my old machine, when i ran amplify status, i had Auth, Api and Storage services listed.
I moved to my new machine, installed node, watchman, brew etc... and then navigated to my react native project and ran: react-native run-ios, and voila, my app is running. All the calls to my AWS Api, Auth and Storage are working perfectly.
Now i can make some amplify commands. Such as amplify status. I tried: amplify env add: here's what i got:
Users-MBP-2:projectname username$ amplify env add
Note: It is recommended to run this command from the root of your app directory
? Do you want to use an existing environment? Yes
? Choose the environment you would like to use: dev
Using default provider awscloudformation
✖ There was an error initializing your environment.
init failed
Error: ENOENT: no such file or directory, open '/Users/username/.aws/credentials'
at Object.openSync (fs.js:462:3)
at Proxy.readFileSync (fs.js:364:35)
at Object.readFileSync (/usr/local/lib/node_modules/#aws-amplify/cli/node_modules/aws-sdk/lib/util.js:95:26)
at IniLoader.parseFile (/usr/local/lib/node_modules/#aws-amplify/cli/node_modules/aws-sdk/lib/shared-ini/ini-loader.js:6:47)
at IniLoader.loadFrom (/usr/local/lib/node_modules/#aws-amplify/cli/node_modules/aws-sdk/lib/shared-ini/ini-loader.js:56:30)
at Config.region (/usr/local/lib/node_modules/#aws-amplify/cli/node_modules/aws-sdk/lib/node_loader.js:100:36)
at Config.set (/usr/local/lib/node_modules/#aws-amplify/cli/node_modules/aws-sdk/lib/config.js:507:39)
at Config.<anonymous> (/usr/local/lib/node_modules/#aws-amplify/cli/node_modules/aws-sdk/lib/config.js:342:12)
at Config.each (/usr/local/lib/node_modules/#aws-amplify/cli/node_modules/aws-sdk/lib/util.js:507:32)
at new Config (/usr/local/lib/node_modules/#aws-amplify/cli/node_modules/aws-sdk/lib/config.js:341:19) {
errno: -2,
syscall: 'open',
code: 'ENOENT',
path: '/Users/username/.aws/credentials'
}
Do you think credentials info needs to be brought/configured to my new machine?
When i run amplify configure project it's like doing an amplify init and building a project from scratch. I'm being asked:
? Enter a name for the project: ProjectName
? Choose your default editor: Visual Studio Code
? Choose the type of app that you're building javascript
Please tell us about your project
? What javascript framework are you using (Use arrow keys)
angular
ember
ionic
react
❯ react-native
vue
none
etc....
I also already have a region, username and accessKey, secretAccess key etc..
I do not want to replace or ruin anything in my current backend or current project! Whats going on?
Ensure amplify-cli is installed and you're logged in with your AWS details.
npm install -g #aws-amplify/cli
amplify configure
Running amplify configure is mainly to give the cli knowledge of your AWS account so subsequent commands can have access to things.
If you get amplify: command not found errors try restarting your terminal. If still no luck, you will need to check amplify has been added to your PATH variable.
Run amplify env add , but choose an existing environment. This will let you choose the environment you created on your other machine so you can pull those settings down to your new machine.
amplify env add
? Do you want to use an existing environment? Yes
Production
Follow up with:
amplify pull
You don't need to run amplify add auth again or anything. All of that will pull down automatically after you've done the above.
You DO NOT need to do all config again, but some for sure
You have to install amplify cli npm install -g #aws-amplify/cli
use amplify pull
https://docs.amplify.aws/cli/start#amplify-pull
Follow the rest of steps -
-- provide the accessKeyId, secretAccessKey
-- region
-- select amplify project
and then rest of app related thing like IDE, directory......
I tried every solution then I found this. (in MacBook)
% sudo -i
Password:
~ root# npm install -g #aws-amplify/cli
-- Ctrl+D to exist from Root user
% amplify pull --appId xxxx --envName yyyy.
Note: To get --appId xxxx --envName yyyy
Log in to the AWS console. Choose AWS Amplify. Click your app. Go to Backend
environments. Find the backend environment you wish to pull. Click
Edit backend. See top right then click 'Local setup instructions
' ( amplify pull --appId
YOUR_APP_ID --envName YOUR_ENV_NAME )
Waiting until it request to verify your amplify.
✔ Successfully received Amplify Studio tokens.
? Choose your default editor: Visual Studio Code
? Choose the type of app that you're building javascript
Please tell us about your project
? What javascript framework are you using react
? Source Directory Path: src
? Distribution Directory Path: build
? Build Command: npm run-script build
? Start Command: npm run-script start
✔ Synced UI components.
? Do you plan on modifying this backend? Yes
⠴ Building resource api/xxxx✅ GraphQL schema compiled successfully.
Edit your schema at ....
✔ Successfully pulled backend environment yyyy from the cloud.
✅
Successfully pulled backend environment staging from the cloud.
Run 'amplify pull' to sync future upstream changes.
% amplify pull
% npm install
% npm start
Hope this help every one!!
Happy Coding :)

Get working package data from openProject API using Postman

I am trying to get working package data from openProject using api with the help of post man. As per their documentation user name = "apikey" and password = Token has been set but I am getting this error in the picture.
If you did not deactivate basic auth authentication through the configuration setting apiv3_enable_basic_auth, then this setup looks correct and I assume you are using an invalid API token.
Can you check whether the following command returns a user for you?
Packaged installation of OpenProject
openproject run bundle exec rails runner "puts User.find_by_api_key('your token').login"
Manual installation of OpenProject
In your OpenProject installation directory:
bundle exec rails runner "puts User.find_by_api_key('your token').login"
If this returns your username the token is valid, on error this means your token is invalid.

How to change an existing build status in Artifactory from a Jenkins job

Hi I am having a Jenkins build pipeline like this: 1. builds the app and deploys to Artifactory; 2. runs an SSH exec command on the test server (remote) to download the artifacts and deploys them into the right directory; 3. runs web tests against the test server, if passed, changes the build status in Artifactory to something like pre-staging for further manual UAT testing. My question is, how to change the build status in Artifactory from a Jenkins job. If using Artifactory's RESTAPI is necessary, can someone share an example? Much appreciated!
Yes, REST API is the easiest way.
You need to perform a Build Promotion call. Please note it requires Artifactory Pro.
It's a POST request, accepting simple json string, in which only two properties are mandatory: status and ciUser.
The call should look something like this:
curl -X POST -u admin:password -H "Content-Type: application/json" -d '{"status":"tests passed","ciUser":"jenkinsAdmin"}' "http://localhost:8081/artifactory/api/build/promote/buildName/buildNumber"