Giter VIP home page Giter VIP logo

statuscake's People

Contributors

bkvaluemeal avatar croman avatar doertedev-instana avatar edwardbetts avatar gaetanfl avatar gravityblast avatar gwhitelaw avatar ivanschwarz avatar jcalonso avatar jmherbst avatar kodieglosser avatar kodieglosseribm avatar longwave avatar matschaffer avatar saj avatar stack72 avatar tiagoboldt avatar yiwei-chen-bose avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

statuscake's Issues

What license does apply for this work?

Hi there,

Can you specify under what license is released the source code of this repository?

Having a license allow to people to know what they can do with your work and if the license allow to contribute then you may get interest of community to help to enhance it.

Many thanks.

Creating an SSL test sometimes fails with a checkrate type mismatch

So here's a weird one.

I received the following error when attempting to create a new StatusCake SSL test using this library:

json: cannot unmarshal number into Go struct field createSsl.Input.checkrate of type string

Indeed, after I patched my local clone of this library to dump HTTP requests and responses, upstream was observed to send a checkrate as an integer type:

---- response dump:
dump error: <nil>
HTTP/2.0 200 OK
Access-Control-Allow-Origin: *
Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0
Cf-Cache-Status: DYNAMIC
Cf-Ray: 5562eac079f8ca53-YUL
Content-Type: application/json
Date: Thu, 16 Jan 2020 20:42:37 GMT
Expect-Ct: max-age=604800, report-uri="https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct"
Expires: Thu, 19 Nov 1981 08:52:00 GMT
Pragma: no-cache
Server: cloudflare
Set-Cookie: REDACTED
Set-Cookie: REDACTED
X-Powered-By: PHP/5.6.26
X-Turbo-Charged-By: LiteSpeed

{"Success":true,"Message":165652,"Input":{"domain":"https:\/\/www.google.com\/","checkrate":86400,"contact_groups":"","alert_reminder":true,"alert_expiry":true,"alert_broken":true,"alert_mixed":false,"alert_at":"1,7,14"}}

Note this bit in particular:

"checkrate":86400

This was especially curious because I could not, at first, reproduce that behaviour with a simple user agent:

curl -Ssv \
  -H 'Accept: application/json' \
  -H 'Username: REDACTED' \
  -H 'API: REDACTED' \
  -X PUT \
  -d 'domain=https://www.google.com/' \
  -d 'checkrate=86400' \
  -d 'contact_groups=' \
  -d 'alert_at=1,2,3' \
  -d 'alert_expiry=false' \
  -d 'alert_reminder=false' \
  -d 'alert_broken=false' \
  -d 'alert_mixed=false' \
  'https://app.statuscake.com/API/SSL/Update' \
  | tee /tmp/checkrate-86400.json \
  | jq .

Response:

{
  "Success": true,
  "Message": 165653,
  "Input": {
    "domain": "https://www.google.com/",
    "checkrate": "86400",
    "contact_groups": "",
    "alert_reminder": false,
    "alert_expiry": false,
    "alert_broken": false,
    "alert_mixed": false,
    "alert_at": "1,2,3"
  }
}

Here, checkrate is a string, which is what this library expects.

It wasn't until some time later that I realised I was specifying different checkrate values in my requests. My test with curl used a checkrate of 86400, whereas my test with this library used a checkrate of 300.

Sure enough:

curl -Ssv \
  -H 'Accept: application/json' \
  -H 'Username: REDACTED' \
  -H 'API: REDACTED' \
  -X PUT \
  -d 'domain=https://www.google.com/' \
  -d 'checkrate=300' \
  -d 'contact_groups=' \
  -d 'alert_at=1,2,3' \
  -d 'alert_expiry=false' \
  -d 'alert_reminder=false' \
  -d 'alert_broken=false' \
  -d 'alert_mixed=false' \
  'https://app.statuscake.com/API/SSL/Update' \
  | tee /tmp/checkrate-300.json \
  | jq .

Response:

{
  "Success": true,
  "Message": 165654,
  "Input": {
    "domain": "https://www.google.com/",
    "checkrate": 86400,
    "contact_groups": "",
    "alert_reminder": false,
    "alert_expiry": false,
    "alert_broken": false,
    "alert_mixed": false,
    "alert_at": "1,2,3"
  }
}

Here, checkrate is an integer.

I have no words.

I know this library is not to blame, but would it make sense to flick createSsl.Checkrate over to the interface{} type and perform a conditional conversion to an intermediate int or string value at runtime? (And presumably updateSsl.Checkrate, too.)

Lest someone else in my position stumble upon this bug in the future, here's a summary of just some of the things that are entirely inaccurate in upstream's API documentation:

  • 300 is documented as a valid checkrate parameter value. In practice, that particular value will be silently discarded and substituted with another. (Unless, presumably, you are on the highest-tier StatusCake plan.)
  • The create operation is documented to respond with an integer-type checkrate value, but, as noted above, it is usually a string-type value in practice.
  • The update operation is documented to respond with an Input key. In practice, that key is nowhere to be found. Oh, and the Message value does not behave as documented, either. There is no resource ID in the response whatsoever.
  • The list operation is not documented to respond with a checkrate value. In practice, the response will include an integer-type checkrate value.

Wayback links to upstream documentation - captured today:

SSL Check support

Does this API client support the methods in the API for creating SSL checks? Upstream terraform provider for statuscake does not - so curious whether the blocker is here or there.

Run tests in CI

At the moment test tests are not working. Running test in CI would be great.

Credentials are not checked

Hey,
while playing around with this library I discovered that wrong credentials are silently accepted and the functions (like Tests().All()) just return an empty array.

It would be great if directly when creating a new client object, the credentials are checked against the Statuscake API to immediately raise some kind of InvalidCredentials exception. Assuming that there is some endpoint in the Statuscake API which can be used for this check...

Best regards,
Felix

Querystring for ContactID is missing, causing api calls to fail when attempting to add a contact group to a statuscake test

Hello, I noticed that it currently is not possible to add contact groups to status cake tests using the statuscake go client because the querystring, ContactGroup, is missing from the ContactID item in Test struct tests.go. This causes the api calls made by the client to fail when attempting to add a contact group. Once added, the calls work as expected.

Here is the snippet I am referring to in tests.go:

type Test struct {
// ThiTestID is an int, use this to get more details about this test. If not provided will insert a new check, else will update
TestID int json:"TestID" querystring:"TestID" querystringoptions:"omitempty"

// Sent tfalse To Unpause and true To Pause.
Paused bool `json:"Paused" querystring:"Paused"`

// Website name. Tags are stripped out
WebsiteName string `json:"WebsiteName" querystring:"WebsiteName"`

// Test location, either an IP (for TCP and Ping) or a fully qualified URL for other TestTypes
WebsiteURL string `json:"WebsiteURL" querystring:"WebsiteURL"`

// A Port to use on TCP Tests
Port int `json:"Port" querystring:"Port"`

// Contact group ID - will return int of contact group used else 0
ContactID int `json:"ContactID" querystring:"ContactGroup"`

//block continues in the code after this segment. End snippet

I wanted to let you know of this issue so that you could investigate. Thanks so much for your time!

Add SSL API support on client.go

Is it possible to add a method to initalize a client to interact with SSL API (/API/SSL endpoint of StatusCake API) on client.go file ?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.