-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtest2.sh
executable file
·44 lines (32 loc) · 2.09 KB
/
test2.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#!/bin/bash
AUTH_TOKEN=`./okapi-login`
echo Got auth token $AUTH_TOKEN
echo Listing current entries
curl -sSL --header "X-Okapi-Tenant: diku" -H "X-Okapi-Token: $AUTH_TOKEN" -H "Content-Type: application/json" -X GET http://localhost:9130/directory/entry
echo
echo lookup the service for loopback-iso-18626
loopback_svc_rec=`curl -sSL --header "X-Okapi-Tenant: diku" -H "X-Okapi-Token: $AUTH_TOKEN" -H "Content-Type: application/json" -X GET http://localhost:9130/directory/service?filter=name%3dloopback-iso-18626`
loopback_svc_id=`echo $loopback_svc_rec | jq -r ".[0].id" | tr -d '\r'`
echo loopback svc $loopback_svc_id : $loopback_svc_rec
echo Create a directory entry for diku
diku_entry_rec=`curl -sSL -H "X-Okapi-Tenant: diku" -H "X-Okapi-Token: $AUTH_TOKEN" -H "Content-Type: application/json" -X POST http://localhost:9130/directory/entry -d ' {
"name":"diku",
"slug":"diku",
"description":"diku",
"tags":[
"Testdata"
]
}'`
diku_entry_id=`echo $diku_entry_rec | jq -r ".id" | tr -d '\r'`
echo $diku_entry_id : $diku_entry_rec
echo Create a serviceAccount entry for the loopback-iso-18626 service and entry diku
diku_loopback_rec=`curl -sSL -H "X-Okapi-Tenant: diku" -H "X-Okapi-Token: $AUTH_TOKEN" -H "Content-Type: application/json" -X POST http://localhost:9130/directory/serviceAccount -d ' {
"service": {id: "'"$loopback_svc_id"'" },
"accountHolder":{id: "'"$diku_entry_id"'" },
"accountDetails":"maybe_a_symbol"
}'`
echo Diku loopback service: $diku_loopback_rec
echo Look up the serviceAccount for diku and loopback-iso-18626
diku_iso_svc_lookup=`curl -sSL --header "X-Okapi-Tenant: diku" -H "X-Okapi-Token: $AUTH_TOKEN" -H "Content-Type: application/json" -X GET "http://localhost:9130/directory/serviceAccount?filter=service.name%3dloopback-iso-18626&accountHolder.name%3ddiku"`
echo "Visit FOAF URL for the OLF"
curl -sSL --header "X-Okapi-Tenant: diku" -H "X-Okapi-Token: $AUTH_TOKEN" -H "Content-Type: application/json" -X GET "http://localhost:9130/directory/api/addFriend?friendUrl=https%3a%2f%2fgithub.com%2fopenlibraryenvironment%2fmod-directory%2fblob%2fmaster%2fseed_data%2folf.json"